Module Name:    src
Committed By:   jdolecek
Date:           Fri Apr 24 22:50:55 UTC 2020

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

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.238 -r1.239 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.238 src/sys/kern/uipc_mbuf.c:1.239
--- src/sys/kern/uipc_mbuf.c:1.238	Fri Apr 24 22:07:12 2020
+++ src/sys/kern/uipc_mbuf.c	Fri Apr 24 22:50:55 2020
@@ -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 @@ m_get(int how, int type)
 	    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 @@ m_clget(struct mbuf *m, int how)
 	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) |

Reply via email to