net: sched: initialize struct tc_ife to fix kernel-infoleak
v4 cover net: sched: initialize struct tc_ife to fix kernel-infoleak
This series addresses the uninitialization of the struct which has 2 bytes of padding. And copying this uninitialized data to userspace can leak info from kernel memory.
This series ensures all members and padding are cleared prior to begin copied.
This change silences the KMSAN report and prevents potential information leaks from the kernel memory.
---
Changes in v4:
- including net in the subject.
- added the Fixes,closes,tested-by and Reported-by tags for patch(1/2)
- Link to v3: https://lore.kernel.org/lkml/[email protected]/#t
Changes in v3:
- updated the commit messages and subject.
- corrected the code misisng ";" in v2
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- removed memset(&t, 0, sizeof(t)) from previous patch.
- added the new patch series to address the issue.
- Link to v1: https://lore.kernel.org/r/[email protected]
Ranganath V N (2):
net: sched: act_connmark: initialize struct tc_ife to fix kernel leak
net: sched: act_ife: initialize struct tc_ife to fix KMSAN
kernel-infoleak
net/sched/act_connmark.c | 12 +++++++----- net/sched/act_ife.c | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-)
Signature · 1 line
2.43.0
PATCH v4 1/2 net: sched: act_connmark: initialize struct tc_ife to fix kernel leak
In tcf_connmark_dump(), the variable 'opt' was partially initialized using a designatied initializer. While the padding bytes are reamined uninitialized. nla_put() copies the entire structure into a netlink message, these uninitialized bytes leaked to userspace.
Initialize the structure with memset before assigning its fields to ensure all members and padding are cleared prior to beign copied.
--- net/sched/act_connmark.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/sched/act_connmark.c +7 -5
@@ -195,13 +195,15 @@ static inline int tcf_connmark_dump(struct sk_buff *skb, struct tc_action *a,const struct tcf_connmark_info *ci =to_connmark (a);unsigned char *b =skb_tail_pointer (skb);const struct tcf_connmark_parms *parms; -struct tc_connmark opt = { - .index = ci->tcf_index, - .refcnt =refcount_read (&ci->tcf_refcnt) - ref, - .bindcnt =atomic_read (&ci->tcf_bindcnt) - bind, - }; +struct tc_connmark opt;struct tcf_t t; +memset (&opt,0 ,sizeof (opt)); + + opt.index = ci->tcf_index; + opt.refcnt =refcount_read (&ci->tcf_refcnt) - ref; + opt.bindcnt =atomic_read (&ci->tcf_bindcnt) - bind; +rcu_read_lock (); parms =rcu_dereference (ci->parms);
Signature · 1 line
2.43.0
Re: [PATCH net v4 1/2] net: sched: act_connmark: initialize struct tc_ife to fix kernel leak
Quoted 9 lines · Ranganath V N
In
tcf_connmark_dump(), the variable 'opt' was partially initialized using a designatied initializer. While the padding bytes are reamined uninitialized.nla_put()copies the entire structure into a netlink message, these uninitialized bytes leaked to userspace.Initialize the structure with memset before assigning its fields to ensure all members and padding are cleared prior to beign copied.
Quoted 6 lines
Reported-by [email protected]Tested-by [email protected]Fixes 22a5dc0e5e3e ("net: sched: Introduce connmark action")Signed-off-by Ranganath V N <[email protected]>---
PATCH v4 2/2 net: sched: act_ife: initialize struct tc_ife to fix KMSAN kernel-infoleak
In reply to Ranganath V NFix a KMSAN kernel-infoleak detected by the syzbot .
[net?] KMSAN: kernel-infoleak in __skb_datagram_iter
In tcf_ife_dump(), the variable 'opt' was partially initialized using a designatied initializer. While the padding bytes are reamined uninitialized. nla_put() copies the entire structure into a netlink message, these uninitialized bytes leaked to userspace.
Initialize the structure with memset before assigning its fields to ensure all members and padding are cleared prior to beign copied.
This change silences the KMSAN report and prevents potential information leaks from the kernel memory.
This fix has been tested and validated by syzbot. This patch closes the bug reported at the following syzkaller link and ensures no infoleak.
--- net/sched/act_ife.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/sched/act_ife.c +7 -5
@@ -644,13 +644,15 @@ static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind,unsigned char *b =skb_tail_pointer (skb);struct tcf_ife_info *ife =to_ife (a);struct tcf_ife_params *p; -struct tc_ife opt = { - .index = ife->tcf_index, - .refcnt =refcount_read (&ife->tcf_refcnt) - ref, - .bindcnt =atomic_read (&ife->tcf_bindcnt) - bind, - }; +struct tc_ife opt;struct tcf_t t; +memset (&opt,0 ,sizeof (opt)); + + opt.index = ife->tcf_index, + opt.refcnt =refcount_read (&ife->tcf_refcnt) - ref, + opt.bindcnt =atomic_read (&ife->tcf_bindcnt) - bind, +spin_lock_bh (&ife->tcf_lock); opt.action = ife->tcf_action; p = rcu_dereference_protected(ife->params,
Signature · 1 line
2.43.0
Re: [PATCH net v4 2/2] net: sched: act_ife: initialize struct tc_ife to fix KMSAN kernel-infoleak
Quoted 16 lines · Ranganath V N
Fix a KMSAN kernel-infoleak detected by the syzbot .
[net?] KMSAN: kernel-infoleak in
__skb_datagram_iterIn
tcf_ife_dump(), the variable 'opt' was partially initialized using a designatied initializer. While the padding bytes are reamined uninitialized.nla_put()copies the entire structure into a netlink message, these uninitialized bytes leaked to userspace.Initialize the structure with memset before assigning its fields to ensure all members and padding are cleared prior to beign copied.
This change silences the KMSAN report and prevents potential information leaks from the kernel memory.
Quoted 8 lines
This fix has been tested and validated by syzbot. This patch closes the bug reported at the following syzkaller link and ensures no infoleak.
Reported-by [email protected]Tested-by [email protected]Fixes ef6980b6becb ("introduce IFE action")Signed-off-by Ranganath V N <[email protected]>
Re: [PATCH net v4 2/2] net: sched: act_ife: initialize struct tc_ife to fix KMSAN kernel-infoleak
In reply to Ranganath V NQuoted 38 lines · Ranganath V N
Fix a KMSAN kernel-infoleak detected by the syzbot .
[net?] KMSAN: kernel-infoleak in
__skb_datagram_iterIn
tcf_ife_dump(), the variable 'opt' was partially initialized using a designatied initializer. While the padding bytes are reamined uninitialized.nla_put()copies the entire structure into a netlink message, these uninitialized bytes leaked to userspace.Initialize the structure with memset before assigning its fields to ensure all members and padding are cleared prior to beign copied.
This change silences the KMSAN report and prevents potential information leaks from the kernel memory.
This fix has been tested and validated by syzbot. This patch closes the bug reported at the following syzkaller link and ensures no infoleak.
Reported-by [email protected]Tested-by [email protected]Fixes ef6980b6becb ("introduce IFE action")Signed-off-by Ranganath V N <[email protected]>--- net/sched/act_ife.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)net/sched/act_ife.c +0
-3@@ -644,13 +644,15 @@ static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind,unsigned char *b =skb_tail_pointer (skb);struct tcf_ife_info *ife =to_ife (a);struct tcf_ife_params *p; -struct tc_ife opt = { - .index = ife->tcf_index, - .refcnt =refcount_read (&ife->tcf_refcnt) - ref,
net/sched/act_ife.c static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind, · line 654
Quoted 10 lines
net/sched/act_ife.c +6
-2- .bindcnt = atomic_read(&ife->tcf_bindcnt) - bind, - }; +struct tc_ife opt;struct tcf_t t; +memset (&opt,0 ,sizeof (opt)); + + opt.index = ife->tcf_index, + opt.refcnt =refcount_read (&ife->tcf_refcnt) - ref, + opt.bindcnt = atomic_read(&ife->tcf_bindcnt) - bind,
Are you sure this is correct to delimit with commas instead of semicolons?
This already causes build failures of 5.10.247-rt141 kernel, because their spin_lock_bh unrolls into do { .. } while (0):
CC [M] net/sched/act_ife.o
In file included from ./include/linux/spinlock.h:329,
from ./include/linux/mmzone.h:8,
from ./include/linux/gfp.h:6,
from ./include/linux/mm.h:10,
from ./include/linux/bvec.h:14,
from ./include/linux/skbuff.h:17,
from net/sched/act_ife.c:20:
net/sched/act_ife.c: In function 'tcf_ife_dump':
./include/linux/spinlock_rt.h:44:2: error: expected expression before 'do'
44 | do { \
| ^~
net/sched/act_ife.c:655:2: note: in expansion of macro 'spin_lock_bh'
655 | spin_lock_bh(&ife->tcf_lock);
| ^~~~~~~~~~~~ make[2]: *** [scripts/Makefile.build:286: net/sched/act_ife.o] Error 1 make[2]: *** Waiting for unfinished jobs....
Thanks,
Quoted 7 lines
net/sched/act_ife.c +1
-0+spin_lock_bh (&ife->tcf_lock); opt.action = ife->tcf_action; p = rcu_dereference_protected(ife->params,Signature · 1 line
2.43.0
Jamal Hadi Salim
maintainerRe: [PATCH net v4 2/2] net: sched: act_ife: initialize struct tc_ife to fix KMSAN kernel-infoleak
Quoted 54 lines · Vitaly Chikunov
Quoted 38 lines · Ranganath V N
Fix a KMSAN kernel-infoleak detected by the syzbot .
[net?] KMSAN: kernel-infoleak in
__skb_datagram_iterIn
tcf_ife_dump(), the variable 'opt' was partially initialized using a designatied initializer. While the padding bytes are reamined uninitialized.nla_put()copies the entire structure into a netlink message, these uninitialized bytes leaked to userspace.Initialize the structure with memset before assigning its fields to ensure all members and padding are cleared prior to beign copied.
This change silences the KMSAN report and prevents potential information leaks from the kernel memory.
This fix has been tested and validated by syzbot. This patch closes the bug reported at the following syzkaller link and ensures no infoleak.
Reported-by [email protected]Tested-by [email protected]Fixes ef6980b6becb ("introduce IFE action")Signed-off-by Ranganath V N <[email protected]>--- net/sched/act_ife.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)net/sched/act_ife.c +0
-3@@ -644,13 +644,15 @@ static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind,unsigned char *b =skb_tail_pointer (skb);struct tcf_ife_info *ife =to_ife (a);struct tcf_ife_params *p; -struct tc_ife opt = { - .index = ife->tcf_index, - .refcnt =refcount_read (&ife->tcf_refcnt) - ref,net/sched/act_ife.c static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind, · line 654
Quoted 10 lines
net/sched/act_ife.c +6
-2- .bindcnt = atomic_read(&ife->tcf_bindcnt) - bind, - }; +struct tc_ife opt;struct tcf_t t; +memset (&opt,0 ,sizeof (opt)); + + opt.index = ife->tcf_index, + opt.refcnt =refcount_read (&ife->tcf_refcnt) - ref, + opt.bindcnt = atomic_read(&ife->tcf_bindcnt) - bind,Are you sure this is correct to delimit with commas instead of semicolons?
Quoted 3 lines
This already causes build failures of 5.10.247-rt141 kernel, because their
spin_lock_bhunrolls into do { .. } while (0):
Do you have access to this?
commit 205305c028ad986d0649b8b100bab6032dcd1bb5
Author: Chen Ni <[email protected]> Date: Wed Nov 12 15:27:09 2025 +0800
net/sched: act_ife: convert comma to semicolon
cheers,
jamal
Quoted 28 lines
CC [M]
net/sched/act_ife.o
In file included from./include/linux/spinlock.h:329,from ./include/linux/mmzone.h:8, from ./include/linux/gfp.h:6, from ./include/linux/mm.h:10, from ./include/linux/bvec.h:14, from ./include/linux/skbuff.h:17, from net/sched/act_ife.c:20: net/sched/act_ife.c: In function 'tcf_ife_dump': ./include/linux/spinlock_rt.h:44:2: error: expected expression before 'do' 44 | do { \ | ^~ net/sched/act_ife.c:655:2: note: in expansion of macro 'spin_lock_bh' 655 | spin_lock_bh(&ife->tcf_lock); | ^~~~~~~~~~~~ make[2]: *** [scripts/Makefile.build:286: net/sched/act_ife.o] Error 1 make[2]: *** Waiting for unfinished jobs....Thanks,
Quoted 7 lines
net/sched/act_ife.c +1
-1+spin_lock_bh (&ife->tcf_lock); opt.action = ife->tcf_action; p = rcu_dereference_protected(ife->params, --2.43.0
Jamal Hadi Salim
maintainerRe: [PATCH net v4 2/2] net: sched: act_ife: initialize struct tc_ife to fix KMSAN kernel-infoleak
Quoted 60 lines · Jamal Hadi Salim
Quoted 54 lines · Vitaly Chikunov
Quoted 38 lines · Ranganath V N
Fix a KMSAN kernel-infoleak detected by the syzbot .
[net?] KMSAN: kernel-infoleak in
__skb_datagram_iterIn
tcf_ife_dump(), the variable 'opt' was partially initialized using a designatied initializer. While the padding bytes are reamined uninitialized.nla_put()copies the entire structure into a netlink message, these uninitialized bytes leaked to userspace.Initialize the structure with memset before assigning its fields to ensure all members and padding are cleared prior to beign copied.
This change silences the KMSAN report and prevents potential information leaks from the kernel memory.
This fix has been tested and validated by syzbot. This patch closes the bug reported at the following syzkaller link and ensures no infoleak.
Reported-by [email protected]Tested-by [email protected]Fixes ef6980b6becb ("introduce IFE action")Signed-off-by Ranganath V N <[email protected]>--- net/sched/act_ife.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)net/sched/act_ife.c +0
-3@@ -644,13 +644,15 @@ static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind,unsigned char *b =skb_tail_pointer (skb);struct tcf_ife_info *ife =to_ife (a);struct tcf_ife_params *p; -struct tc_ife opt = { - .index = ife->tcf_index, - .refcnt =refcount_read (&ife->tcf_refcnt) - ref,net/sched/act_ife.c static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind, · line 654
Quoted 10 lines
net/sched/act_ife.c +6
-2- .bindcnt = atomic_read(&ife->tcf_bindcnt) - bind, - }; +struct tc_ife opt;struct tcf_t t; +memset (&opt,0 ,sizeof (opt)); + + opt.index = ife->tcf_index, + opt.refcnt =refcount_read (&ife->tcf_refcnt) - ref, + opt.bindcnt = atomic_read(&ife->tcf_bindcnt) - bind,Are you sure this is correct to delimit with commas instead of semicolons?
Quoted 3 lines
This already causes build failures of 5.10.247-rt141 kernel, because their
spin_lock_bhunrolls into do { .. } while (0):
Quoted 7 lines
Do you have access to this?
commit205305c028ad986d0649b8b100bab6032dcd1bb5Author: Chen Ni <[email protected]> Date: Wed Nov 12 15:27:09 2025 +0800net/sched:
act_ife: convert comma to semicolon
Sigh. I see the problem: that patch did not have a Fixes tag; otherwise, it would have been backported.
cheers,
jamal
Re: [PATCH net v4 2/2] net: sched: act_ife: initialize struct tc_ife to fix KMSAN kernel-infoleak
Jamal, and linux-rt-devel,
Quoted 66 lines · Jamal Hadi Salim
Quoted 65 lines · Jamal Hadi Salim
Quoted 54 lines · Vitaly Chikunov
Quoted 38 lines · Ranganath V N
Fix a KMSAN kernel-infoleak detected by the syzbot .
[net?] KMSAN: kernel-infoleak in
__skb_datagram_iterIn
tcf_ife_dump(), the variable 'opt' was partially initialized using a designatied initializer. While the padding bytes are reamined uninitialized.nla_put()copies the entire structure into a netlink message, these uninitialized bytes leaked to userspace.Initialize the structure with memset before assigning its fields to ensure all members and padding are cleared prior to beign copied.
This change silences the KMSAN report and prevents potential information leaks from the kernel memory.
This fix has been tested and validated by syzbot. This patch closes the bug reported at the following syzkaller link and ensures no infoleak.
Reported-by [email protected]Tested-by [email protected]Fixes ef6980b6becb ("introduce IFE action")Signed-off-by Ranganath V N <[email protected]>--- net/sched/act_ife.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)net/sched/act_ife.c +0
-3@@ -644,13 +644,15 @@ static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind,unsigned char *b =skb_tail_pointer (skb);struct tcf_ife_info *ife =to_ife (a);struct tcf_ife_params *p; -struct tc_ife opt = { - .index = ife->tcf_index, - .refcnt =refcount_read (&ife->tcf_refcnt) - ref,net/sched/act_ife.c static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind, · line 654
Quoted 10 lines
net/sched/act_ife.c +6
-2- .bindcnt = atomic_read(&ife->tcf_bindcnt) - bind, - }; +struct tc_ife opt;struct tcf_t t; +memset (&opt,0 ,sizeof (opt)); + + opt.index = ife->tcf_index, + opt.refcnt =refcount_read (&ife->tcf_refcnt) - ref, + opt.bindcnt = atomic_read(&ife->tcf_bindcnt) - bind,Are you sure this is correct to delimit with commas instead of semicolons?
Quoted 3 lines
This already causes build failures of 5.10.247-rt141 kernel, because their
spin_lock_bhunrolls into do { .. } while (0):Do you have access to this?
commit205305c028ad986d0649b8b100bab6032dcd1bb5Author: Chen Ni <[email protected]> Date: Wed Nov 12 15:27:09 2025 +0800
Quoted 5 lines
Quoted 2 lines
net/sched:
act_ife: convert comma to semicolonSigh. I see the problem: that patch did not have a Fixes tag; otherwise, it would have been backported.
Thanks! I will pick this for the local builds. But, perhaps, someone should send it to [email protected] to fix the older -rt kernels too.
Thanks,
Quoted 3 lines
cheers,
jamal
Jamal Hadi Salim
maintainerRe: [PATCH net v4 2/2] net: sched: act_ife: initialize struct tc_ife to fix KMSAN kernel-infoleak
Quoted 70 lines · Vitaly Chikunov
Jamal, and linux-rt-devel,
Quoted 66 lines · Jamal Hadi Salim
Quoted 65 lines · Jamal Hadi Salim
Quoted 54 lines · Vitaly Chikunov
Quoted 38 lines · Ranganath V N
Fix a KMSAN kernel-infoleak detected by the syzbot .
[net?] KMSAN: kernel-infoleak in
__skb_datagram_iterIn
tcf_ife_dump(), the variable 'opt' was partially initialized using a designatied initializer. While the padding bytes are reamined uninitialized.nla_put()copies the entire structure into a netlink message, these uninitialized bytes leaked to userspace.Initialize the structure with memset before assigning its fields to ensure all members and padding are cleared prior to beign copied.
This change silences the KMSAN report and prevents potential information leaks from the kernel memory.
This fix has been tested and validated by syzbot. This patch closes the bug reported at the following syzkaller link and ensures no infoleak.
Reported-by [email protected]Tested-by [email protected]Fixes ef6980b6becb ("introduce IFE action")Signed-off-by Ranganath V N <[email protected]>--- net/sched/act_ife.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)net/sched/act_ife.c +0
-3@@ -644,13 +644,15 @@ static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind,unsigned char *b =skb_tail_pointer (skb);struct tcf_ife_info *ife =to_ife (a);struct tcf_ife_params *p; -struct tc_ife opt = { - .index = ife->tcf_index, - .refcnt =refcount_read (&ife->tcf_refcnt) - ref,net/sched/act_ife.c static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind, · line 654
Quoted 10 lines
net/sched/act_ife.c +6
-2- .bindcnt = atomic_read(&ife->tcf_bindcnt) - bind, - }; +struct tc_ife opt;struct tcf_t t; +memset (&opt,0 ,sizeof (opt)); + + opt.index = ife->tcf_index, + opt.refcnt =refcount_read (&ife->tcf_refcnt) - ref, + opt.bindcnt = atomic_read(&ife->tcf_bindcnt) - bind,Are you sure this is correct to delimit with commas instead of semicolons?
Quoted 3 lines
This already causes build failures of 5.10.247-rt141 kernel, because their
spin_lock_bhunrolls into do { .. } while (0):Do you have access to this?
commit205305c028ad986d0649b8b100bab6032dcd1bb5Author: Chen Ni <[email protected]> Date: Wed Nov 12 15:27:09 2025 +0800
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
net/sched:
act_ife: convert comma to semicolonSigh. I see the problem: that patch did not have a Fixes tag; otherwise, it would have been backported.
Thanks! I will pick this for the local builds. But, perhaps, someone should send it to [email protected] to fix the older -rt kernels too.
+ @stable
Not sure if this is enough. Let me know if @stable needs something more formal.
cheers,
jamal
Quoted 11 lines · Ranganath V N
This series addresses the uninitialization of the struct which has 2 bytes of padding. And copying this uninitialized data to userspace can leak info from kernel memory.
This series ensures all members and padding are cleared prior to begin copied.
This change silences the KMSAN report and prevents potential information leaks from the kernel memory.
Signed-off-by Ranganath V N <[email protected]>
Looks good to me too.
Thanks!
This series was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 8 lines · On Sun, 9 Nov 2025 14:43:34 +0530 you wrote:
This series addresses the uninitialization of the struct which has 2 bytes of padding. And copying this uninitialized data to userspace can leak info from kernel memory.
This series ensures all members and padding are cleared prior to begin copied.
[...]
Here is the summary with links:
- [net,v4,1/2] net: sched: act_connmark: initialize struct tc_ife to fix kernel leak
https://git.kernel.org/netdev/net/c/62b656e43eae - [net,v4,2/2] net: sched: act_ife: initialize struct tc_ife to fix KMSAN kernel-infoleak https://git.kernel.org/netdev/net/c/ce50039be49e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html