Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: correctly move 'log' upon successful match

Suppose log="foo bar buz" and msg->substr="bar".
In such case current match processing logic would update 'log' as
follows: log += strlen(msg->substr); -> log += 3 -> log=" bar".
However, the intent behind the 'log' update is to make it point after
the successful match, e.g. to make log=" buz" in the example above.

Fixes: 4ef5d6af4935 ("selftests/bpf: no need to track next_match_pos in struct test_loader")
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20240820102357.3372779-3-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Eduard Zingerman and committed by
Alexei Starovoitov
d0a29cdb 7d41dad1

+1 -1
+1 -1
tools/testing/selftests/bpf/test_loader.c
··· 522 522 if (msg->substr) { 523 523 match = strstr(log, msg->substr); 524 524 if (match) 525 - log += strlen(msg->substr); 525 + log = match + strlen(msg->substr); 526 526 } else { 527 527 err = regexec(&msg->regex, log, 1, reg_match, 0); 528 528 if (err == 0) {