netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix KMSAN infoleak, initialize unused data in pskb_expand_head
@ 2024-10-02  5:38 Daniel Yang
  2024-10-02  7:27 ` Eric Dumazet
  2024-10-04  7:59 ` kernel test robot
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Yang @ 2024-10-02  5:38 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	GitAuthor: Daniel Yang, netdev, linux-kernel
  Cc: syzbot+346474e3bf0b26bd3090

pskb_expand_head doesn't initialize extra nhead bytes in header and
tail bytes, leading to KMSAN infoleak error. Fix by initializing data to
0 with memset.

Reported-by: syzbot+346474e3bf0b26bd3090@syzkaller.appspotmail.com
Tested-by: Daniel Yang <danielyangkang@gmail.com>
Signed-off-by: Daniel Yang <danielyangkang@gmail.com>
---
 net/core/skbuff.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 74149dc4e..348161dcb 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2286,6 +2286,11 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
 	       skb_shinfo(skb),
 	       offsetof(struct skb_shared_info, frags[skb_shinfo(skb)->nr_frags]));
 
+	/* Initialize newly allocated headroom and tailroom
+	 */
+	memset(data, 0, nhead);
+	memset(data + nhead + skb->tail, 0, skb_tailroom(skb) + ntail);
+
 	/*
 	 * if shinfo is shared we must drop the old head gracefully, but if it
 	 * is not we can just drop the old head and let the existing refcount
-- 
2.39.2


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

end of thread, other threads:[~2024-10-05  4:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-02  5:38 [PATCH] Fix KMSAN infoleak, initialize unused data in pskb_expand_head Daniel Yang
2024-10-02  7:27 ` Eric Dumazet
2024-10-02 11:55   ` Daniel Borkmann
2024-10-03  4:42     ` Daniel Yang
2024-10-03  7:56       ` Eric Dumazet
2024-10-05  4:59         ` Daniel Yang
2024-10-04  7:59 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).