summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2018-03-12 23:38:43 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2018-03-12 23:38:43 +0000
commitc00a96d579b9d3862021a72d5dd290100c0a8b8f (patch)
treebfc05354abf708f23b141cc0be7315901069155f /sys
parent167f49617df84eb257a060c7c996b1fd6dd5447b (diff)
make m_adj keep m_data aligned when removing all the data in an mbuf.
previously it took a shortcut when emptying an mbuf by only setting m_len to 0, but leaving m_data alone. this interacts badly with m_pullup, which tries to maintain the alignment of the data payload. if there was a 14 byte ethernet header on its own that was m_adjed off, and then the stack wants an ip header, m_pullup would put the ip header on the ethernet header alignment, which is off by 2 bytes. found by stsp@ with pair(4) on sparc64. ok stsp@ too
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_mbuf.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 13a1a3fad53..5535225f60f 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.253 2018/01/16 19:44:34 benno Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.254 2018/03/12 23:38:42 dlg Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -812,11 +812,12 @@ m_adj(struct mbuf *mp, int req_len)
while (m != NULL && len > 0) {
if (m->m_len <= len) {
len -= m->m_len;
+ m->m_data += m->m_len;
m->m_len = 0;
m = m->m_next;
} else {
- m->m_len -= len;
m->m_data += len;
+ m->m_len -= len;
len = 0;
}
}