Skip to contentSkip to conversation

net/core : fix KMSAN: uninit value in tipc_rcv

PATCH Superseded [email protected] 3 participants 3 messages Sep 19, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/core : fix KMSAN: uninit value in tipc_rcv

From: HariKrishna Sagala <[email protected]>

Syzbot reported an uninit-value bug on at kmalloc_reserve for commit 320475fbd590 ("Merge tag 'mtd/fixes-for-6.17-rc6' of
git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux")'

Syzbot KMSAN reported use of uninitialized memory originating from functions "kmalloc_reserve()", where memory allocated via "kmem_cache_alloc_node()" or "kmalloc_node_track_caller()" was not explicitly initialized. This can lead to undefined behavior when the allocated buffer
is later accessed.

Fix this by requesting the initialized memory using the gfp flag appended with the option "__GFP_ZERO".

Reported-by [email protected]
Fixes 915d975b2ffa ("net: deal with integer overflows in

kmalloc_reserve()")

---
 net/core/skbuff.c | 1 +
 1 file changed, 1 insertion(+)
net/core/skbuff.c +1 -0
index ee0274417948..2308ebf99bbd 100644
@@ -573,6 +573,7 @@ static void *kmalloc_reserve(unsigned int *size, gfp_t flags, int node,
 	void *obj;
 
 	obj_size = SKB_HEAD_ALIGN(*size);
+	flags |= __GFP_ZERO;
 	if (obj_size <= SKB_SMALL_HEAD_CACHE_SIZE &&
 	    !(flags & KMALLOC_NOT_NORMAL_BITS)) {
 		obj = kmem_cache_alloc_node(net_hotdata.skb_small_head_cache,
Signature · 1 line
2.43.0
#1 lore raw
FYI: kernel test robot notices the stable kernel rule is not satisfied.

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH net] net/core : fix KMSAN: uninit value in tipc_rcv

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#2 lore raw
In reply to [email protected]
Quoted 31 lines · On Fri, Sep 19, 2025 at 11:06 AM <[email protected]> wrote:

From: HariKrishna Sagala <[email protected]>

Syzbot reported an uninit-value bug on at kmalloc_reserve for commit 320475fbd590 ("Merge tag 'mtd/fixes-for-6.17-rc6' of
git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux")'

Syzbot KMSAN reported use of uninitialized memory originating from functions "kmalloc_reserve()", where memory allocated via "kmem_cache_alloc_node()" or "kmalloc_node_track_caller()" was not explicitly initialized. This can lead to undefined behavior when the allocated buffer
is later accessed.

Fix this by requesting the initialized memory using the gfp flag appended with the option "__GFP_ZERO".

Reported-by [email protected]
Fixes 915d975b2ffa ("net: deal with integer overflows in

kmalloc_reserve()")

---
 net/core/skbuff.c | 1 +
 1 file changed, 1 insertion(+)
net/core/skbuff.c +0 -0
index ee0274417948..2308ebf99bbd 100644

net/core/skbuff.c static void *kmalloc_reserve(unsigned int *size, gfp_t flags, int node, · line 576

Quoted 4 lines
net/core/skbuff.c +1 -0
@@ -573,6 +573,7 @@ static void *kmalloc_reserve(unsigned int *size, gfp_t flags, int node,
        void *obj;
 
        obj_size = SKB_HEAD_ALIGN(*size);
+       flags |= __GFP_ZERO;

Certainly not.

Some of us care about performance.

Moreover, the bug will be still there for non linear skbs.

So please fix tipc.