Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Zhiqi Zhang
Sun, 01 Nov 2026 08:17
Re: [PATCH] lib/ts_fsm: preserve token types when exporting patterns
Author: Zhiqi Zhang
Date: Sun, 01 Nov 2026 08:17
Date: Sun, 01 Nov 2026 08:17
64 lines
14068 bytes
14068 bytes
Hi Andrew, > The main user of textsearch appears to be netfilter, so please let's > keep the relevant developers in the loop. Thanks for bringing them in. The affected userspace export path I verified is tc's text ematch in net/sched/em_text.c. I have also copied the tc maintainers and netdev. xt_string retains its original pattern, so I am not claiming an iptables-save/restore regression. > Zhiqi, a thing which is missing from the changelog, and it's really > important, is a description of the userspace-visible runtime effects of > the bug. Agreed; the changelog should have explained the tc consequence directly. I have added it for v2. There is a runtime effect: restoring an FSM text ematch from its rtnetlink dump can change which packets match, or return EINVAL when an exported character-class mask is not a valid token type. The additional automated test uses a tc basic filter on loopback in an isolated ARM64 QEMU guest, a DIGIT/MULTI token, and four-byte UDP payloads. The original rule matches "7777" and rejects "AAAA". Before the fix, a rule recreated from its dump matches both; after the fix it still rejects "AAAA". This is measured with the classifier's evaluated/matched counters. A PRINT/MULTI rule also fails restoration with EINVAL before the fix and restores successfully afterwards. > once the issue is out there, LLM-using bad actors might be able to find > ways of exploiting the bug, so please discuss that aspect also. The trigger is reuse of an affected exported pattern when configuring a rule; dumping alone does not change the running rule. Creating/restoring the rule requires CAP_NET_ADMIN in the relevant network namespace. Where matching selects a filtering action, changed matches can make the restored policy differ from the administrator's intent. The tests establish the matching error, not a privilege escalation or memory-corruption exploit. I have not established a production deployment or a wider exploit path. The test source and detailed logs are available if useful. > : Related finding: BM/KMP also export transformed patterns. With > : TS_IGNORECASE, repeated folding of 0xff changes it again Thanks for the pointer. I have kept that separate from this FSM series; I have not independently validated that additional finding. > : One small test improvement: after copying the exported pattern, add > : KUNIT_EXPECT_MEMEQ(test, exported, pattern, len). Added. The updated suite fails 13/15 tests before the fix and passes 15/15 after it on ARM64 GCC, with 15/15 also passing on ARM32 GCC and ARM64 Clang. > And I'm thinking that a cc:stable is justified here. Added to the fix. I split the fix and KUnit coverage into two patches so the small production change can be backported independently. The matcher change itself is unchanged from v1. I am sending v2 as a separate series with the v1 and review links. The additional v2 tests and revised text were prepared with OpenAI Codex; the recorded automated runs were driven by Codex. Thanks, Zhiqi
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads