public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH] net: skbuff: fix uninitialized memory use in pskb_expand_head()
       [not found] <6954bc70.050a0220.a1b6.0310.GAE@google.com>
@ 2026-01-14 13:56 ` Soham Metha
  2026-01-14 15:06   ` [syzbot] [bpf?] KMSAN: uninit-value in bpf_prog_test_run_skb syzbot
  2026-01-26 11:43 ` [PATCH v2] net: skbuff: fix uninitialized memory use in pskb_expand_head() Soham Metha
  1 sibling, 1 reply; 4+ messages in thread
From: Soham Metha @ 2026-01-14 13:56 UTC (permalink / raw)
  To: linux-kernel-mentees
  Cc: shuah, syzbot+619b9ef527f510a57cfc, syzkaller-bugs, andrii, ast,
	bpf, daniel, eddyz87, haoluo, john.fastabend, jolsa, kpsingh,
	linux-kernel, martin.lau, sdf, song, yonghong.song, Soham Metha

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [syzbot] [bpf?] KMSAN: uninit-value in bpf_prog_test_run_skb
  2026-01-14 13:56 ` [PATCH] net: skbuff: fix uninitialized memory use in pskb_expand_head() Soham Metha
@ 2026-01-14 15:06   ` syzbot
  0 siblings, 0 replies; 4+ messages in thread
From: syzbot @ 2026-01-14 15:06 UTC (permalink / raw)
  To: andrii, ast, bpf, daniel, eddyz87, haoluo, john.fastabend, jolsa,
	kpsingh, linux-kernel-mentees, linux-kernel, martin.lau, sdf,
	shuah, sohammetha01, song, syzkaller-bugs, yonghong.song

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] net: skbuff: fix uninitialized memory use in pskb_expand_head()
       [not found] <6954bc70.050a0220.a1b6.0310.GAE@google.com>
  2026-01-14 13:56 ` [PATCH] net: skbuff: fix uninitialized memory use in pskb_expand_head() Soham Metha
@ 2026-01-26 11:43 ` Soham Metha
  2026-01-26 13:26   ` Eric Dumazet
  1 sibling, 1 reply; 4+ messages in thread
From: Soham Metha @ 2026-01-26 11:43 UTC (permalink / raw)
  To: linux-kernel-mentees
  Cc: shuah, skhan, linux-kernel, syzbot+619b9ef527f510a57cfc,
	syzkaller-bugs, andrii, ast, bpf, daniel, eddyz87, haoluo,
	john.fastabend, jolsa, kpsingh, martin.lau, sdf, song,
	yonghong.song, Soham Metha, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Jason Xing,
	Kuniyuki Iwashima, Michal Luczaj, Mina Almasry, Eric Biggers,
	Alexander Lobakin, netdev

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
Closes: https://syzkaller.appspot.com/bug?extid=619b9ef527f510a57cfc
Tested-by: syzbot+619b9ef527f510a57cfc@syzkaller.appspotmail.com
Signed-off-by: Soham Metha <sohammetha01@gmail.com>
---

v2:
- No code changes
- Resent to netdev list
- Added Closes tag
- Added Tested-by tag

 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] net: skbuff: fix uninitialized memory use in pskb_expand_head()
  2026-01-26 11:43 ` [PATCH v2] net: skbuff: fix uninitialized memory use in pskb_expand_head() Soham Metha
@ 2026-01-26 13:26   ` Eric Dumazet
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2026-01-26 13:26 UTC (permalink / raw)
  To: Soham Metha
  Cc: linux-kernel-mentees, shuah, skhan, linux-kernel,
	syzbot+619b9ef527f510a57cfc, syzkaller-bugs, andrii, ast, bpf,
	daniel, eddyz87, haoluo, john.fastabend, jolsa, kpsingh,
	martin.lau, sdf, song, yonghong.song, David S. Miller,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Jason Xing,
	Kuniyuki Iwashima, Michal Luczaj, Mina Almasry, Eric Biggers,
	Alexander Lobakin, netdev

On Mon, Jan 26, 2026 at 2:22 PM Soham Metha <sohammetha01@gmail.com> wrote:
>
> 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
> Closes: https://syzkaller.appspot.com/bug?extid=619b9ef527f510a57cfc
> Tested-by: syzbot+619b9ef527f510a57cfc@syzkaller.appspotmail.com
> Signed-off-by: Soham Metha <sohammetha01@gmail.com>
> ---
>
> v2:
> - No code changes
> - Resent to netdev list
> - Added Closes tag
> - Added Tested-by tag
>
>  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);
> +
>


Certainly not.

You might wonder why we have GFP_ZERO ?

Answer : we do not generally want to pay the price of zeroing memory
_unless_ absolutely needed.

Fix the caller instead, ie root-cause the issue, thank you

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-26 13:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <6954bc70.050a0220.a1b6.0310.GAE@google.com>
2026-01-14 13:56 ` [PATCH] net: skbuff: fix uninitialized memory use in pskb_expand_head() Soham Metha
2026-01-14 15:06   ` [syzbot] [bpf?] KMSAN: uninit-value in bpf_prog_test_run_skb syzbot
2026-01-26 11:43 ` [PATCH v2] net: skbuff: fix uninitialized memory use in pskb_expand_head() Soham Metha
2026-01-26 13:26   ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox