Source-Changes-HG archive

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

[src/trunk]: src/sys/kern add KASSERT() that the while data buffer in a mbuf ...



details:   https://anonhg.NetBSD.org/src/rev/6b02311b2cc3
branches:  trunk
changeset: 1009500:6b02311b2cc3
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Apr 24 22:50:55 2020 +0000

description:
add KASSERT() that the while data buffer in a mbuf or the mbuf
cluster fits within the same page

pools actually never return items whose memory cross page boundary for item
sizes smaller than PAGE_SIZE

diffstat:

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

diffs (36 lines):

diff -r df8cc59db654 -r 6b02311b2cc3 sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c      Fri Apr 24 22:31:35 2020 +0000
+++ b/sys/kern/uipc_mbuf.c      Fri Apr 24 22:50:55 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_mbuf.c,v 1.238 2020/04/24 22:07:12 jdolecek Exp $ */
+/*     $NetBSD: uipc_mbuf.c,v 1.239 2020/04/24 22:50:55 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1999, 2001, 2018 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.238 2020/04/24 22:07:12 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.239 2020/04/24 22:50:55 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -534,6 +534,7 @@
            how == M_WAIT ? PR_WAITOK|PR_LIMITFAIL : PR_NOWAIT);
        if (m == NULL)
                return NULL;
+       KASSERT(((vaddr_t)m->m_dat & PAGE_MASK) + MLEN <= PAGE_SIZE);
 
        mbstat_type_add(type, 1);
 
@@ -587,6 +588,9 @@
        if (m->m_ext_storage.ext_buf == NULL)
                return;
 
+       KASSERT(((vaddr_t)m->m_ext_storage.ext_buf & PAGE_MASK) + mclbytes
+           <= PAGE_SIZE);
+
        MCLINITREFERENCE(m);
        m->m_data = m->m_ext.ext_buf;
        m->m_flags = (m->m_flags & ~M_EXTCOPYFLAGS) |



Home | Main Index | Thread Index | Old Index