Module Name:    src
Committed By:   mlelstv
Date:           Sun Feb  8 14:46:30 UTC 2015

Modified Files:
        src/sys/kern: uipc_mbuf.c

Log Message:
Correct m_len calculation for m_dup() with mbuf clusters.
Fixes kern/49650.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 src/sys/kern/uipc_mbuf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.160 src/sys/kern/uipc_mbuf.c:1.161
--- src/sys/kern/uipc_mbuf.c:1.160	Tue Dec  2 04:43:35 2014
+++ src/sys/kern/uipc_mbuf.c	Sun Feb  8 14:46:30 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.160 2014/12/02 04:43:35 ozaki-r Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.161 2015/02/08 14:46:30 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.160 2014/12/02 04:43:35 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.161 2015/02/08 14:46:30 mlelstv Exp $");
 
 #include "opt_mbuftrace.h"
 #include "opt_nmbclusters.h"
@@ -777,8 +777,13 @@ m_copym0(struct mbuf *m, int off0, int l
 				/*
 				 * we are unsure about the way m was allocated.
 				 * copy into multiple MCLBYTES cluster mbufs.
+				 *
+				 * recompute m_len, it is no longer valid if MCLGET()
+				 * fails to allocate a cluster. Then we try to split
+				 * the source into normal sized mbufs.
 				 */
 				MCLGET(n, wait);
+				n->m_len = 0;
 				n->m_len = M_TRAILINGSPACE(n);
 				n->m_len = m_copylen(len, n->m_len);
 				n->m_len = min(n->m_len, m->m_len - off);

Reply via email to