Source-Changes-HG archive

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

[src/trunk]: src m_prepend does not tolerate being given len > MHLEN, so add ...



details:   https://anonhg.NetBSD.org/src/rev/09463bb7d540
branches:  trunk
changeset: 358910:09463bb7d540
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Jan 22 10:26:38 2018 +0000

description:
m_prepend does not tolerate being given len > MHLEN, so add a panic, and
document this behavior.

diffstat:

 share/man/man9/mbuf.9 |  8 ++++++--
 sys/kern/uipc_mbuf.c  |  8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diffs (58 lines):

diff -r bfbe1e754f54 -r 09463bb7d540 share/man/man9/mbuf.9
--- a/share/man/man9/mbuf.9     Mon Jan 22 09:51:06 2018 +0000
+++ b/share/man/man9/mbuf.9     Mon Jan 22 10:26:38 2018 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: mbuf.9,v 1.53 2018/01/01 12:46:49 wiz Exp $
+.\"    $NetBSD: mbuf.9,v 1.54 2018/01/22 10:26:38 maxv Exp $
 .\"
 .\" Copyright (c) 1997 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 1, 2018
+.Dd January 22, 2018
 .Dt MBUF 9
 .Os
 .Sh NAME
@@ -431,6 +431,10 @@
 parameter is a choice of
 .Dv M_WAIT / M_DONTWAIT
 from caller.
+It is illegal for the
+.Fa len
+parameter to be greater than
+.Dv MHLEN .
 .It Fn m_pulldown "struct mbuf *m" "int off" "int len" "int *offp"
 Rearranges an mbuf chain so that
 .Fa len
diff -r bfbe1e754f54 -r 09463bb7d540 sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c      Mon Jan 22 09:51:06 2018 +0000
+++ b/sys/kern/uipc_mbuf.c      Mon Jan 22 10:26:38 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_mbuf.c,v 1.179 2018/01/22 09:06:40 maxv Exp $     */
+/*     $NetBSD: uipc_mbuf.c,v 1.180 2018/01/22 10:26:38 maxv 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.179 2018/01/22 09:06:40 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.180 2018/01/22 10:26:38 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -661,6 +661,10 @@
 {
        struct mbuf *mn;
 
+       if (__predict_false(len > MHLEN)) {
+               panic("%s: len > MHLEN", __func__);
+       }
+
        KASSERT(len != M_COPYALL);
        mn = m_get(how, m->m_type);
        if (mn == NULL) {



Home | Main Index | Thread Index | Old Index