From: Fang Xieyan <fangxy@xiaopeng.com>
To: jhs@mojatatu.com, jiri@resnulli.us
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, eyal.birger@gmail.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
liuwb@xiaopeng.com, zhugl3@xiaopeng.com
Subject: [PATCH] net: sched: em_ipt: validate hook value from netlink
Date: Mon, 26 Oct 2026 17:07:17 +0800 [thread overview]
Message-ID: <20261026090717.41597-1-fangxy@xiaopeng.com> (raw)
em_ipt_change() accepts the user-provided TCA_EM_IPT_HOOK value
without validating its range.
The value is later used in check_match() as "1 << im->hook". A hook
value of 32 or greater causes undefined behavior and may undermine the
xt match hook-mask validation. The value is also passed to
nf_hook_state_init() as a hook index.
Reject hook values outside the supported IPv4/IPv6 Netfilter hook
range after checking the required attributes, before loading the xt
match or allocating the match state.
Reviewed-by: Weibin Liu <liuwb@xiaopeng.com>
Signed-off-by: Fang Xieyan <fangxy@xiaopeng.com>
---
net/sched/em_ipt.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/sched/em_ipt.c b/net/sched/em_ipt.c
index 3650117da..e4a8c1f0a 100644
--- a/net/sched/em_ipt.c
+++ b/net/sched/em_ipt.c
@@ -142,6 +142,9 @@ static int em_ipt_change(struct net *net, void *data, int data_len,
!tb[TCA_EM_IPT_MATCH_DATA] || !tb[TCA_EM_IPT_NFPROTO])
return -EINVAL;
+ if (nla_get_u32(tb[TCA_EM_IPT_HOOK]) >= NF_INET_NUMHOOKS)
+ return -EINVAL;
+
nfproto = nla_get_u8(tb[TCA_EM_IPT_NFPROTO]);
switch (nfproto) {
case NFPROTO_IPV4:
--
2.50.1
next reply other threads:[~2026-10-26 9:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 9:07 Fang Xieyan [this message]
2026-10-26 9:10 ` netdev-bot+sinfo
2026-10-26 9:30 ` Fang Xieyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261026090717.41597-1-fangxy@xiaopeng.com \
--to=fangxy@xiaopeng.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=eyal.birger@gmail.com \
--cc=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuwb@xiaopeng.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=zhugl3@xiaopeng.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®