From: Eduard Zingerman <eddyz87@xxxxxxxxx> commit d0a29cdb6ef95d8a175e09ab2d1334271f047e60 upstream. 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@xxxxxxxxx> Link: https://lore.kernel.org/r/20240820102357.3372779-3-eddyz87@xxxxxxxxx Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- tools/testing/selftests/bpf/test_loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/testing/selftests/bpf/test_loader.c +++ b/tools/testing/selftests/bpf/test_loader.c @@ -545,7 +545,7 @@ static void validate_msgs(char *log_buf, if (msg->substr) { match = strstr(log, msg->substr); if (match) - log += strlen(msg->substr); + log = match + strlen(msg->substr); } else { err = regexec(&msg->regex, log, 1, reg_match, 0); if (err == 0) { Patches currently in stable-queue which might be from eddyz87@xxxxxxxxx are queue-6.10/selftests-bpf-allow-checking-xlated-programs-in-veri.patch queue-6.10/bpf-correctly-handle-malformed-bpf_core_type_id_loca.patch queue-6.10/bpf-x64-fix-tailcall-hierarchy.patch queue-6.10/selftests-bpf-__arch_-macro-to-limit-test-cases-to-s.patch queue-6.10/bpf-fail-verification-for-sign-extension-of-packet-d.patch queue-6.10/selftests-bpf-correctly-move-log-upon-successful-match.patch queue-6.10/selftests-bpf-no-need-to-track-next_match_pos-in-str.patch queue-6.10/selftests-bpf-fix-wrong-binary-in-makefile-log-outpu.patch queue-6.10/libbpf-fix-bpf_object__open_skeleton-s-mishandling-o.patch queue-6.10/selftests-bpf-fix-to-avoid-__msg-tag-de-duplication-.patch queue-6.10/selftests-bpf-support-checks-against-a-regular-expre.patch queue-6.10/selftests-bpf-extract-test_loader-expect_msgs-as-a-d.patch queue-6.10/bpf-lsm-add-check-for-bpf-lsm-return-value.patch