From: sashiko-bot@kernel.org
To: "Alexis Lothoré (eBPF Foundation)" <alexis.lothore@bootlin.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 10/10] selftests/bpf: add tests to validate KASAN on JIT programs
Date: Thu, 09 Jul 2026 11:52:56 +0000 [thread overview]
Message-ID: <20260709115256.EE4A51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709-kasan-v5-10-1c64af8e4e1e@bootlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Infinite loop in `read_kernel_logs` if `read()` returns 0.
--
--- Patch [10]: [PATCH bpf-next v5 10/10] selftests/bpf: add tests to validate KASAN on JIT programs ---
commit f689181d893dcf7bbac97d28845dc342a1fe71e5
Author: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
selftests/bpf: add tests to validate KASAN on JIT programs
This commit adds a basic KASAN test runner that loads and runs BPF programs
designed to trigger memory management bugs. The tests capture kernel logs to
verify that the expected KASAN splats are emitted, ensuring the JIT compiler
has correctly inserted KASAN instrumentation.
> diff --git a/tools/testing/selftests/bpf/prog_tests/kasan.c b/tools/testing/selftests/bpf/prog_tests/kasan.c
> new file mode 100644
> index 0000000000000..2bc545e962595
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/kasan.c
> @@ -0,0 +1,430 @@
[ ... ]
> +static int read_kernel_logs(int fd, char *buf, size_t max_len)
> +{
> + size_t total = 0;
> + ssize_t n;
> +
> + buf[0] = '\0';
> + while (1) {
> + char *msg, *eol;
> + size_t len;
> +
> + n = read(fd, record, sizeof(record) - 1);
> + if (n < 0) {
> + if (errno == EAGAIN)
> + break;
> + return n;
> + }
> + record[n] = '\0';
> +
> + /*
> + * Each kmsg record starts with some metadata, separated
> + * from the actual content by a semi-colon
> + */
> + msg = strchr(record, ';');
> + if (!msg)
> + continue;
[Severity: Low]
Will this loop indefinitely if read() returns 0?
If n == 0, record is null-terminated at index 0, making strchr() return NULL.
The continue statement then restarts the loop, causing read() to be called
again. While /dev/kmsg typically returns -EAGAIN when no data is available,
should an unexpected 0 return from read() be explicitly handled to prevent a
potential infinite loop?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-kasan-v5-0-1c64af8e4e1e@bootlin.com?part=10
next prev parent reply other threads:[~2026-07-09 11:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 10:01 [PATCH bpf-next v5 00/10] bpf: add support for KASAN checks in JITed programs Alexis Lothoré (eBPF Foundation)
2026-07-09 10:01 ` [PATCH bpf-next v5 01/10] bpf: propagate original instruction offset when patching program Alexis Lothoré (eBPF Foundation)
2026-07-09 10:25 ` sashiko-bot
2026-07-09 10:01 ` [PATCH bpf-next v5 02/10] bpf: mark instructions accessing program stack Alexis Lothoré (eBPF Foundation)
2026-07-09 10:35 ` sashiko-bot
2026-07-09 10:01 ` [PATCH bpf-next v5 03/10] bpf: add BPF_JIT_KASAN for KASAN instrumentation of JITed programs Alexis Lothoré (eBPF Foundation)
2026-07-09 10:01 ` [PATCH bpf-next v5 04/10] bpf, x86: add helper to emit kasan checks in x86 " Alexis Lothoré (eBPF Foundation)
2026-07-09 10:54 ` sashiko-bot
2026-07-09 10:01 ` [PATCH bpf-next v5 05/10] bpf, x86: refactor BPF_ST management in do_jit Alexis Lothoré (eBPF Foundation)
2026-07-09 11:08 ` sashiko-bot
2026-07-09 10:01 ` [PATCH bpf-next v5 06/10] bpf, x86: emit KASAN checks into x86 JITed programs Alexis Lothoré (eBPF Foundation)
2026-07-09 11:20 ` sashiko-bot
2026-07-09 10:01 ` [PATCH bpf-next v5 07/10] bpf, x86: enable KASAN for JITed programs on x86 Alexis Lothoré (eBPF Foundation)
2026-07-09 11:29 ` sashiko-bot
2026-07-09 10:01 ` [PATCH bpf-next v5 08/10] selftests/bpf: add helpers for KASAN in JIT testing Alexis Lothoré (eBPF Foundation)
2026-07-09 11:35 ` sashiko-bot
2026-07-09 10:01 ` [PATCH bpf-next v5 09/10] selftests/bpf: move bpf_jit_harden helper into testing_helpers Alexis Lothoré (eBPF Foundation)
2026-07-09 10:01 ` [PATCH bpf-next v5 10/10] selftests/bpf: add tests to validate KASAN on JIT programs Alexis Lothoré (eBPF Foundation)
2026-07-09 11:52 ` sashiko-bot [this message]
2026-07-09 18:53 ` [PATCH bpf-next v5 00/10] bpf: add support for KASAN checks in JITed programs Borislav Petkov
2026-07-09 19:09 ` Alexis Lothoré
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260709115256.EE4A51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexis.lothore@bootlin.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox