Skip to content

Commit 02e9578

Browse files
author
Paolo Abeni
committed
Merge branch 'net-sched-initialize-struct-tc_ife-to-fix-kernel-infoleak'
Ranganath says: ==================== 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. v3: https://lore.kernel.org/lkml/20251106195635.2438-1-vnranganath.20@gmail.com/#t v2: https://lore.kernel.org/r/20251101-infoleak-v2-0-01a501d41c09@gmail.com v1: https://lore.kernel.org/r/20251031-infoleak-v1-1-9f7250ee33aa@gmail.com Signed-off-by: Ranganath V N <vnranganath.20@gmail.com> Acked-by: Cong Wang <xiyou.wangcong@gmail.com> ==================== Link: https://patch.msgid.link/20251109091336.9277-1-vnranganath.20@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2 parents 60e6489 + ce50039 commit 02e9578

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

net/sched/act_connmark.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,15 @@ static inline int tcf_connmark_dump(struct sk_buff *skb, struct tc_action *a,
195195
const struct tcf_connmark_info *ci = to_connmark(a);
196196
unsigned char *b = skb_tail_pointer(skb);
197197
const struct tcf_connmark_parms *parms;
198-
struct tc_connmark opt = {
199-
.index = ci->tcf_index,
200-
.refcnt = refcount_read(&ci->tcf_refcnt) - ref,
201-
.bindcnt = atomic_read(&ci->tcf_bindcnt) - bind,
202-
};
198+
struct tc_connmark opt;
203199
struct tcf_t t;
204200

201+
memset(&opt, 0, sizeof(opt));
202+
203+
opt.index = ci->tcf_index;
204+
opt.refcnt = refcount_read(&ci->tcf_refcnt) - ref;
205+
opt.bindcnt = atomic_read(&ci->tcf_bindcnt) - bind;
206+
205207
rcu_read_lock();
206208
parms = rcu_dereference(ci->parms);
207209

net/sched/act_ife.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -644,13 +644,15 @@ static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind,
644644
unsigned char *b = skb_tail_pointer(skb);
645645
struct tcf_ife_info *ife = to_ife(a);
646646
struct tcf_ife_params *p;
647-
struct tc_ife opt = {
648-
.index = ife->tcf_index,
649-
.refcnt = refcount_read(&ife->tcf_refcnt) - ref,
650-
.bindcnt = atomic_read(&ife->tcf_bindcnt) - bind,
651-
};
647+
struct tc_ife opt;
652648
struct tcf_t t;
653649

650+
memset(&opt, 0, sizeof(opt));
651+
652+
opt.index = ife->tcf_index,
653+
opt.refcnt = refcount_read(&ife->tcf_refcnt) - ref,
654+
opt.bindcnt = atomic_read(&ife->tcf_bindcnt) - bind,
655+
654656
spin_lock_bh(&ife->tcf_lock);
655657
opt.action = ife->tcf_action;
656658
p = rcu_dereference_protected(ife->params,

0 commit comments

Comments
 (0)