This is a follow-up to commit 9c572a83037a ("net/sched: fix potential stack infoleak in em_text_dump()"), which zero-initialised the dump-side struct. Sashiko separately pointed at the unaligned pattern tail on the same dump path. em_text_dump() appends the text pattern with nla_append(), which is a bare skb_put_data() and does not pad the attribute to a 4-byte boundary. When pattern_len is not a multiple of four the skb tail is left unaligned. tcf_em_tree_dump() records the raw span as the ematch entry's nla_len and then writes the next ematch's nlattr header at that unaligned tail. Userspace walks the list with RTA_NEXT()/NLA_NEXT(), which rounds each attribute length up to four bytes, so it looks for the next entry at an aligned offset the kernel did not write. The ematch list is therefore misparsed as soon as a text ematch has a pattern length that is not a multiple of four. Append the pattern with nla_put_nohdr(), which reserves NLA_ALIGN(attrlen) bytes and zero-fills the padding, so the following ematch stays aligned. The emitted ematch entry then carries the padding in its nla_len, which is what NLA_NEXT() already assumes. em_text_change() only checks that len covers the struct and the pattern, so a dump replayed as a request is still accepted. This also removes the last variable-length nla_append() caller (sch_gred's is a fixed-size, already aligned struct). Conditions to recreate the bug: - CAP_NET_ADMIN on the target netns (namespace-local via unshare -Urn is enough) - add a basic filter with two text ematches whose pattern_len is not a multiple of 4 (e.g. 1 and 2), then dump it with RTM_GETTFILTER - the first ematch entry comes back with an unaligned nla_len and the next entry's nlattr header is written at that raw offset, while RTA_NEXT() reads an aligned offset three bytes later Reported-by: Sashiko (gemini) Closes: https://sashiko.dev/#/patchset/20260918133953.12494-1-bernard.ladenthin%40gmail.com Reviewed-by: Jamal Hadi Salim Signed-off-by: Victor Nogueira --- net/sched/em_text.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/sched/em_text.c b/net/sched/em_text.c index 4132f8c3c5fc..fbf78d61f109 100644 --- a/net/sched/em_text.c +++ b/net/sched/em_text.c @@ -125,8 +125,8 @@ static int em_text_dump(struct sk_buff *skb, struct tcf_ematch *m) if (nla_put_nohdr(skb, sizeof(conf), &conf) < 0) goto nla_put_failure; - if (nla_append(skb, conf.pattern_len, - textsearch_get_pattern(tm->config)) < 0) + if (nla_put_nohdr(skb, conf.pattern_len, + textsearch_get_pattern(tm->config)) < 0) goto nla_put_failure; return 0; -- 2.43.0