[PATCH OLK-5.10] net/sched: cls_u32: validate offshift to prevent shift-out-of-bounds
From: "Cen Zhang (Microsoft)" <blbllhy@gmail.com> mainline inclusion from mainline-v7.2-rc6 commit aef96eead2860cbfa371e4471d4f04412213b958 category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/17793 CVE: CVE-2026-74544 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- u32_change() copies the user-provided tc_u32_sel.offshift (unsigned char, 0-255) into the kernel knode object without bounds validation. When a packet later hits u32_classify() with TC_U32_VAROFFSET set, it evaluates `ntohs(offmask & *data) >> offshift` where the left operand is a 16-bit value promoted to a 32-bit int. Any offshift >= 32 is undefined behavior per C11 6.5.7p3, triggerable by an unprivileged user via user/network namespaces. UBSAN: shift-out-of-bounds in net/sched/cls_u32.c:236:43 shift exponent 32 is too large for 32-bit type int Fix this by rejecting offshift >= 16 during filter creation in u32_change(). Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: AutonomousCodeSecurity@microsoft.com Link: https://lore.kernel.org/all/20260720034514.23053-1-blbllhy@gmail.com Signed-off-by: Cen Zhang (Microsoft) <blbllhy@gmail.com> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Tested-by: Jamal Hadi Salim <jhs@mojatatu.com> Tested-by: Victor Nogueira <victor@mojatatu.com> Link: https://patch.msgid.link/20260723044955.89471-1-blbllhy@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Conflicts: net/sched/cls_u32.c [commit 69050f8d6d07 is not backport, which lead to context conflict] Signed-off-by: Dong Chenchen <dongchenchen2@huawei.com> --- net/sched/cls_u32.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index e501390ccd75..0db59ea65e48 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -1067,6 +1067,13 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, goto erridr; } + if (s->offshift >= 16) { + NL_SET_ERR_MSG_MOD(extack, + "offshift must be less than 16"); + err = -EINVAL; + goto erridr; + } + n = kzalloc(struct_size(n, sel.keys, s->nkeys), GFP_KERNEL); if (n == NULL) { err = -ENOBUFS; -- 2.43.0
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/27106 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/X6G... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/27106 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/X6G...
participants (2)
-
patchwork bot -
superdcc97@163.com