[PATCH] net: skbuff: fix uninitialized memory use in pskb_expand_head()

Soham Metha posted 1 patch 3 weeks, 3 days ago
There is a newer version of this series
net/core/skbuff.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] net: skbuff: fix uninitialized memory use in pskb_expand_head()
Posted by Soham Metha 3 weeks, 3 days ago
pskb_expand_head() allocates a new skb data buffer using
kmalloc_reserve(), which does not initialize memory. skb helpers may
later copy or move padding bytes from the buffer.

Initialize the newly allocated skb buffer to avoid propagating
uninitialized memory.

Reported-by: syzbot+619b9ef527f510a57cfc@syzkaller.appspotmail.com
Signed-off-by: Soham Metha <sohammetha01@gmail.com>
---
#syz test

 net/core/skbuff.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index a56133902c0d..b0f0d3a0310b 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2282,6 +2282,9 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
 	data = kmalloc_reserve(&size, gfp_mask, NUMA_NO_NODE, NULL);
 	if (!data)
 		goto nodata;
+
+	memset(data, 0, size);
+
 	size = SKB_WITH_OVERHEAD(size);
 
 	/* Copy only real data... and, alas, header. This should be
-- 
2.34.1
Re: [syzbot] [bpf?] KMSAN: uninit-value in bpf_prog_test_run_skb
Posted by syzbot 3 weeks, 2 days ago
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+619b9ef527f510a57cfc@syzkaller.appspotmail.com
Tested-by: syzbot+619b9ef527f510a57cfc@syzkaller.appspotmail.com

Tested on:

commit:         c537e12d Merge tag 'bpf-fixes' of git://git.kernel.org..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12188522580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=46b5f80a6e7aaa5c
dashboard link: https://syzkaller.appspot.com/bug?extid=619b9ef527f510a57cfc
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
patch:          https://syzkaller.appspot.com/x/patch.diff?x=15f21d9a580000

Note: testing is done by a robot and is best-effort only.