From: sashiko-bot@kernel.org
To: "Christian Brauner" <brauner@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH 14/21] selftests/exec: test the transparent binfmt_misc mode
Date: Mon, 20 Jul 2026 11:44:46 +0000 [thread overview]
Message-ID: <20260720114447.4F62A1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260720-work-bpf-binfmt_misc-ptinterp-v1-14-ddb76c9a508e@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Stack-based buffer overflow in binfmt_transparent_interp when concatenating strings into the `expect` array.
--
--- Patch [14]: [PATCH 14/21] selftests/exec: test the transparent binfmt_misc mode ---
commit 9d915ef86186ae5a0a73c74e07d46a93d08f7fe5
Author: Christian Brauner <brauner@kernel.org>
selftests/exec: test the transparent binfmt_misc mode
This commit introduces a transparent dispatch test for binfmt_misc from both
activation paths. The dispatch routes to a shared asserting interpreter that
validates the kernel's constructed identity from inside the process.
> diff --git a/tools/testing/selftests/exec/binfmt_transparent_interp.c b/tools/testing/selftests/exec/binfmt_transparent_interp.c
> new file mode 100644
> index 0000000000000..2a71c47067582
> --- /dev/null
> +++ b/tools/testing/selftests/exec/binfmt_transparent_interp.c
> @@ -0,0 +1,130 @@
[ ... ]
> +int main(int argc, char **argv)
> +{
> + const char *binary = getenv("BINFMT_TEST_BINARY");
> + const char *argv0 = getenv("BINFMT_TEST_ARGV0");
> + char exe[PATH_MAX], real[PATH_MAX], buf[PATH_MAX];
> + char expect[PATH_MAX + 32];
[ ... ]
> + /* Distinct from the binary path, so a classic argv splice is caught. */
> + want[0] = argv0 ? argv0 : binary;
> + want[1] = "argone";
> + want[2] = "argtwo";
[ ... ]
> + /* And so did the kernel's copy of it: the same strings, NUL separated. */
> + for (i = 0, expect_len = 0; i < ARRAY_SIZE(want); i++) {
> + size_t len = strlen(want[i]) + 1;
> +
> + memcpy(expect + expect_len, want[i], len);
[Severity: Medium]
Could this overflow the expect[] buffer?
If the user executes this test program with BINFMT_TEST_ARGV0 or
BINFMT_TEST_BINARY set to a string longer than PATH_MAX, expect_len + len
could exceed the size of the expect[] buffer. Since there is no bounds
checking before the memcpy(), this would result in a stack-based buffer
overflow.
> + expect_len += len;
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260720-work-bpf-binfmt_misc-ptinterp-v1-0-ddb76c9a508e@kernel.org?part=14
next prev parent reply other threads:[~2026-07-20 11:44 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 9:33 [PATCH 00/21] binfmt_misc: transparent interpreters and PT_INTERP loader substitution Christian Brauner
2026-07-20 9:33 ` [PATCH 01/21] exec: do not act on a stale execfd request without an executable Christian Brauner
2026-07-20 10:00 ` sashiko-bot
2026-07-20 11:30 ` Christian Brauner
2026-07-20 12:44 ` Christian Brauner
2026-07-20 9:33 ` [PATCH 02/21] docs, binfmt_misc: keep general usage out of the handler sections Christian Brauner
2026-07-20 9:33 ` [PATCH 03/21] binfmt_misc: table-drive the register string flags Christian Brauner
2026-07-20 9:33 ` [PATCH 04/21] binfmt_misc: normalize the per-exec invocation flags Christian Brauner
2026-07-20 9:33 ` [PATCH 05/21] binfmt_misc: split out entry_open_interpreter() Christian Brauner
2026-07-20 9:33 ` [PATCH 06/21] binfmt_misc: split out build_interp_argv() Christian Brauner
2026-07-20 9:33 ` [PATCH 07/21] exec: release the replaced file with do_close_execat() Christian Brauner
2026-07-20 9:33 ` [PATCH 08/21] exec: add AT_FLAGS_TRANSPARENT_INTERP Christian Brauner
2026-07-20 9:33 ` [PATCH 09/21] exec: label mm->exe_file with the binary for a transparent dispatch Christian Brauner
2026-07-20 9:33 ` [PATCH 10/21] binfmt_misc: add transparent interpreter dispatch Christian Brauner
2026-07-20 9:33 ` [PATCH 11/21] binfmt_misc: add a static transparent flag 'T' Christian Brauner
2026-07-20 9:33 ` [PATCH 12/21] binfmt_misc: let a bpf handler run the interpreter transparently Christian Brauner
2026-07-20 9:33 ` [PATCH 13/21] selftests/exec: convert the binfmt_misc bpf test to the kselftest harness Christian Brauner
2026-07-20 9:33 ` [PATCH 14/21] selftests/exec: test the transparent binfmt_misc mode Christian Brauner
2026-07-20 11:44 ` sashiko-bot [this message]
2026-07-20 12:17 ` Christian Brauner
2026-07-20 9:33 ` [PATCH 15/21] binfmt_misc: document the transparent identity contract Christian Brauner
2026-07-20 9:33 ` [PATCH 16/21] exec: carry a PT_INTERP substitute in struct linux_binprm Christian Brauner
2026-07-20 9:33 ` [PATCH 17/21] binfmt_elf: consume a stashed PT_INTERP substitute Christian Brauner
2026-07-20 9:33 ` [PATCH 18/21] binfmt_misc: add the 'L' loader substitution flag Christian Brauner
2026-07-20 9:33 ` [PATCH 19/21] binfmt_misc: let a bpf handler request loader substitution Christian Brauner
2026-07-20 9:33 ` [PATCH 20/21] selftests/exec: test binfmt_misc " Christian Brauner
2026-07-20 12:22 ` sashiko-bot
2026-07-20 9:33 ` [PATCH 21/21] binfmt_misc: document " Christian Brauner
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=20260720114447.4F62A1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brauner@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.