Source-Changes-HG archive

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

[src/trunk]: src/sys/sys Add KASSERTs in *_ALIGN: ensure the mbuf is of the c...



details:   https://anonhg.NetBSD.org/src/rev/b660d7068494
branches:  trunk
changeset: 358904:b660d7068494
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Jan 22 07:11:45 2018 +0000

description:
Add KASSERTs in *_ALIGN: ensure the mbuf is of the correct type, and
also make sure m->m_data points at the beginning of the mbuf.

diffstat:

 sys/sys/mbuf.h |  7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diffs (28 lines):

diff -r 80689344199b -r b660d7068494 sys/sys/mbuf.h
--- a/sys/sys/mbuf.h    Mon Jan 22 06:56:25 2018 +0000
+++ b/sys/sys/mbuf.h    Mon Jan 22 07:11:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mbuf.h,v 1.174 2018/01/14 17:16:58 maxv Exp $  */
+/*     $NetBSD: mbuf.h,v 1.175 2018/01/22 07:11:45 maxv Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -604,6 +604,8 @@
  */
 #define        M_ALIGN(m, len)                                                 \
 do {                                                                   \
+       KASSERT(((m)->m_flags & (M_PKTHDR|M_EXT)) == 0);                \
+       KASSERT(M_LEADINGSPACE(m) == 0);                                \
        (m)->m_data += (MLEN - (len)) &~ (sizeof(long) - 1);            \
 } while (/* CONSTCOND */ 0)
 
@@ -613,6 +615,9 @@
  */
 #define        MH_ALIGN(m, len)                                                \
 do {                                                                   \
+       KASSERT(((m)->m_flags & M_PKTHDR) != 0);                        \
+       KASSERT(((m)->m_flags & M_EXT) == 0);                           \
+       KASSERT(M_LEADINGSPACE(m) == 0);                                \
        (m)->m_data += (MHLEN - (len)) &~ (sizeof(long) - 1);           \
 } while (/* CONSTCOND */ 0)
 



Home | Main Index | Thread Index | Old Index