Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Correct m_len calculation for m_dup() with mbuf clu...



details:   https://anonhg.NetBSD.org/src/rev/2761b4f368f3
branches:  trunk
changeset: 806186:2761b4f368f3
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Feb 08 14:46:30 2015 +0000

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

diffstat:

 sys/kern/uipc_mbuf.c |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r 855c72136fad -r 2761b4f368f3 sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c      Sun Feb 08 14:10:28 2015 +0000
+++ b/sys/kern/uipc_mbuf.c      Sun Feb 08 14:46:30 2015 +0000
@@ -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 @@
                                /*
                                 * 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);



Home | Main Index | Thread Index | Old Index