public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: syzbot <syzbot+619b9ef527f510a57cfc@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] net: skbuff: fix KMSAN uninit-value in pskb_expand_head()
Date: Sat, 03 Jan 2026 19:48:36 -0800	[thread overview]
Message-ID: <6959e314.050a0220.a5285.0002.GAE@google.com> (raw)
In-Reply-To: <6954bc70.050a0220.a1b6.0310.GAE@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] net: skbuff: fix KMSAN uninit-value in pskb_expand_head()
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

When pskb_expand_head() allocates a new buffer with additional headroom,
the memcpy copies the entire old buffer including the old headroom which
contains uninitialized memory. KMSAN detects this when the garbage data
is copied, triggering uninit-value warnings.

The call chain is:
  bpf_skb_adjust_room()
    -> bpf_skb_net_grow()
      -> skb_cow_head()
        -> pskb_expand_head()  // copies uninit old headroom
      -> bpf_skb_net_hdr_push()
        -> bpf_skb_generic_push()
          -> skb_postpush_data_move()
            -> skb_data_move()  // moves uninit memory

Fix this by:
1. Zeroing the entire headroom region (new nhead + old headroom)
2. Copying only the actual packet data (from skb->data to skb->tail)
   instead of copying from skb->head which includes garbage headroom

This ensures no uninitialized memory is ever copied while maintaining
the same buffer layout with packet data in the correct location.

Reported-by: syzbot+619b9ef527f510a57cfc@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=619b9ef527f510a57cfc
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 net/core/skbuff.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index a00808f7be6a..ce3e335e4729 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2284,10 +2284,12 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
 		goto nodata;
 	size = SKB_WITH_OVERHEAD(size);
 
-	/* Copy only real data... and, alas, header. This should be
-	 * optimized for the cases when header is void.
+	/* Zero the headroom to avoid copying uninit memory.
+	 * Then copy only the actual packet data.
 	 */
-	memcpy(data + nhead, skb->head, skb_tail_pointer(skb) - skb->head);
+	memset(data, 0, nhead + skb_headroom(skb));
+	memcpy(data + nhead + skb_headroom(skb), skb->data,
+	       skb_tail_pointer(skb) - skb->data);
 
 	memcpy((struct skb_shared_info *)(data + size),
 	       skb_shinfo(skb),
-- 
2.43.0


  parent reply	other threads:[~2026-01-04  3:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-31  6:02 [syzbot] [bpf?] KMSAN: uninit-value in bpf_prog_test_run_skb syzbot
2026-01-02  2:20 ` Forwarded: [PATCH] net: skbuff: fix KMSAN uninit-value in pskb_expand_head() syzbot
2026-01-04  2:01 ` syzbot
2026-01-04  3:48 ` syzbot [this message]
2026-01-04  3:58 ` syzbot
2026-01-14 12:09 ` Forwarded: [PATCH] net: skbuff: fix uninitialized memory use " syzbot
2026-01-14 12:33 ` syzbot
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
2026-01-26 13:26   ` Eric Dumazet
2026-03-30  2:37 ` Forwarded: Re: [syzbot] [bpf?] KMSAN: uninit-value in bpf_prog_test_run_skb syzbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6959e314.050a0220.a5285.0002.GAE@google.com \
    --to=syzbot+619b9ef527f510a57cfc@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox