* [PATCH] net/sched: ematch: check nla_put_nohdr() return value in tcf_em_tree_dump()
@ 2026-09-19 21:06 Hui Peng
0 siblings, 0 replies; only message in thread
From: Hui Peng @ 2026-09-19 21:06 UTC (permalink / raw)
To: jhs, jiri, davem, edumazet, kuba, pabeni; +Cc: horms, netdev, linux-kernel
When tcf_em_tree_dump() was converted from the legacy rtnetlink
`RTA_PUT_NOHDR` macro (which contained an implicit `goto
rtattr_failure;`) to `nla_put_nohdr()`, the return value check on
`nla_put_nohdr()` was omitted for container/simple matches and raw match
payloads.
If the netlink dump skb runs out of tailroom at `nla_put_nohdr()`, the
error is silently ignored and `match_start->nla_len` is finalized
without the match payload, emitting a malformed/truncated
TCA_EMATCH_TREE_LIST attribute to userspace instead of returning `-1`
via `nla_put_failure` so rtnetlink can reallocate and retry the dump.
Check the return value of `nla_put_nohdr()` in both branches and jump to
`nla_put_failure` on error.
Fixes: add93b610a4e ("[NET_SCHED]: Convert classifiers from rtnetlink to new netlink API")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
net/sched/ematch.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/net/sched/ematch.c b/net/sched/ematch.c
index 5c1235e6076a..563feb1011f2 100644
--- a/net/sched/ematch.c
+++ b/net/sched/ematch.c
@@ -470,9 +470,12 @@ int tcf_em_tree_dump(struct sk_buff *skb, struct tcf_ematch_tree *tree, int tlv)
goto nla_put_failure;
} else if (tcf_em_is_container(em) || tcf_em_is_simple(em)) {
u32 u = em->data;
- nla_put_nohdr(skb, sizeof(u), &u);
- } else if (em->datalen > 0)
- nla_put_nohdr(skb, em->datalen, (void *) em->data);
+ if (nla_put_nohdr(skb, sizeof(u), &u))
+ goto nla_put_failure;
+ } else if (em->datalen > 0) {
+ if (nla_put_nohdr(skb, em->datalen, (void *)em->data))
+ goto nla_put_failure;
+ }
tail = skb_tail_pointer(skb);
match_start->nla_len = tail - (u8 *)match_start;
--
2.55.0.1082.g2b9226bbc0-goog
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-19 21:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-19 21:06 [PATCH] net/sched: ematch: check nla_put_nohdr() return value in tcf_em_tree_dump() Hui Peng
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®