From nobody@FreeBSD.org  Fri Apr 13 12:50:03 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 84B0B16A402
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 13 Apr 2007 12:50:03 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id 73A8313C45E
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 13 Apr 2007 12:50:03 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l3DCo3xg095048
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 13 Apr 2007 12:50:03 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l3DCj2x3094100;
	Fri, 13 Apr 2007 12:45:02 GMT
	(envelope-from nobody)
Message-Id: <200704131245.l3DCj2x3094100@www.freebsd.org>
Date: Fri, 13 Apr 2007 12:45:02 GMT
From: Thomas Karcher<thkarcher@gmx.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] ip6_input() treats mbuf cluster wrong
X-Send-Pr-Version: www-3.0

>Number:         111537
>Category:       kern
>Synopsis:       [inet6] [patch] ip6_input() treats mbuf cluster wrong
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-net
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 13 13:00:09 GMT 2007
>Closed-Date:    
>Last-Modified:  Sun May 29 22:30:22 UTC 2011
>Originator:     Thomas Karcher
>Release:        RELENG_6_2_0_RELEASE
>Organization:
>Environment:
>Description:

In ip6_input() after line 294, a bunch of code takes care of copying the mbuf/mbuf cluster to a more KAME conform mbuf/mbuf cluster - but in my opinion, it does it not completely right ...

In line 318, the m_copydata() call works only if the new mbuf n is "just" an mbuf and not an mbuf cluster. See the solution what I mean.
>How-To-Repeat:

>Fix:
I think the code should look like this:

 318                 if (n && n->m_pkthdr.len > MHLEN) {
 319                         m_copydata(m, 0, n->m_pkthdr.len, n->m_ext.ext_buf);
 320                         n->m_data = n->m_ext.ext_buf;
 321                 } else {
 322                         m_copydata(m, 0, n->m_pkthdr.len, mtod(n, caddr_t));
 323                 }

Please find a diff attached.


Patch attached with submission follows:

Index: netinet6/ip6_input.c
===================================================================
--- netinet6/ip6_input.c	(revision 576)
+++ netinet6/ip6_input.c	(working copy)
@@ -315,7 +315,12 @@
 			return;	/* ENOBUFS */
 		}
 
-		m_copydata(m, 0, n->m_pkthdr.len, mtod(n, caddr_t));
+		if (n && n->m_pkthdr.len > MHLEN) {
+			m_copydata(m, 0, n->m_pkthdr.len, n->m_ext.ext_buf);
+			n->m_data = n->m_ext.ext_buf;
+		} else {
+			m_copydata(m, 0, n->m_pkthdr.len, mtod(n, caddr_t));
+		}
 		n->m_len = n->m_pkthdr.len;
 		m_freem(m);
 		m = n;

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->kmacy 
Responsible-Changed-By: kmacy 
Responsible-Changed-When: Mon Nov 19 08:46:30 UTC 2007 
Responsible-Changed-Why:  

Add to queue to verify that the submitter is correct. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=111537 
Responsible-Changed-From-To: kmacy->freebsd-net 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Sun May 29 22:26:57 UTC 2011 
Responsible-Changed-Why:  
kmacy has asked for all of his PRs to be reassigned back to the pool. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=111537 
>Unformatted:
