summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_mbuf.c
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2019-01-08 13:01:50 +0000
committerbluhm <bluhm@openbsd.org>2019-01-08 13:01:50 +0000
commit023f2de55b6ae907b7699e27e768e0b1530a4bbf (patch)
tree54c065984048d967af83479b480aabfe701a4f07 /sys/kern/uipc_mbuf.c
parentsync (diff)
downloadwireguard-openbsd-023f2de55b6ae907b7699e27e768e0b1530a4bbf.tar.xz
wireguard-openbsd-023f2de55b6ae907b7699e27e768e0b1530a4bbf.zip
If the mbuf cluster in m_zero() is read only, propagate the M_ZEROIZE
flag to the other references. Then the final m_free() will clear the memory. OK claudio@
Diffstat (limited to '')
-rw-r--r--sys/kern/uipc_mbuf.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index a06d4be8c26..99c1fab9875 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.263 2019/01/07 07:49:38 claudio Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.264 2019/01/08 13:01:50 bluhm Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -1262,8 +1262,16 @@ m_devget(char *buf, int totlen, int off)
void
m_zero(struct mbuf *m)
{
- if (M_READONLY(m)) /* can't m_zero a shared buffer */
+ if (M_READONLY(m)) {
+ mtx_enter(&m_extref_mtx);
+ if ((m->m_flags & M_EXT) && MCLISREFERENCED(m)) {
+ m->m_ext.ext_nextref->m_flags |= M_ZEROIZE;
+ m->m_ext.ext_prevref->m_flags |= M_ZEROIZE;
+ }
+ mtx_leave(&m_extref_mtx);
return;
+ }
+
explicit_bzero(M_DATABUF(m), M_SIZE(m));
}