mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net: sched: em_ipt: validate hook value from netlink
@ 2026-10-26  9:07 Fang Xieyan
  2026-10-26  9:10 ` netdev-bot+sinfo
  2026-10-26  9:30 ` Fang Xieyan
  0 siblings, 2 replies; 3+ messages in thread
From: Fang Xieyan @ 2026-10-26  9:07 UTC (permalink / raw)
  To: jhs, jiri
  Cc: davem, edumazet, kuba, pabeni, horms, eyal.birger, netdev,
	linux-kernel, liuwb, zhugl3

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-26  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26  9:07 [PATCH] net: sched: em_ipt: validate hook value from netlink Fang Xieyan
2026-10-26  9:10 ` netdev-bot+sinfo
2026-10-26  9:30 ` Fang Xieyan

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®