Repository navigation
Conversation
casaroli
requested review from
Donny9,
jerpelea and
xiaoxiang781216
as code owners
November 4, 2026 17:01
|
casaroli
force-pushed
the
builtin-loader-path-up
branch
from
November 4, 2026 18:20
5574ca0 to
a1b2e6f
Compare
…cifies.
The builtin binary format looks up only the last part of a path, so
exec("/nonexistent/hello") starts the builtin "hello", and so does
exec("/tmp/hello") for a file that is not a program. POSIX wants ENOENT
and ENOEXEC.
With the new option CONFIG_BINFMT_BUILTIN_STRICT_PATH (default n), a
name with a '/' matches a builtin only if it names a file in a mounted
BINFS. A bare name still matches. Without the option nothing changes.
The default stays, because code depends on it: without a BINFS at /bin,
popen() without LIBC_ENVPATH uses "/bin/sh" and that path starts the
builtin "sh". The help text lists what the option breaks.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
…infs. Say how exec() matches a path to a builtin application, and what the option changes. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
casaroli
force-pushed
the
builtin-loader-path-up
branch
from
November 4, 2026 22:10
a1b2e6f to
d379864
Compare
casaroli
marked this pull request as draft
November 4, 2026 22:10
casaroli
marked this pull request as ready for review
November 5, 2026 03:17
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s): CI run: https://github.com/apache/nuttx/actions/runs/41922851921 |
xiaoxiang781216
approved these changes
Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The builtin binary format looks up only the last part of a path.
exec("/nonexistent/hello")starts the builtinhello, and so doesexec("/tmp/hello")for a file that is not a program. POSIX wants ENOENT and ENOEXEC.This PR adds
CONFIG_BINFMT_BUILTIN_STRICT_PATH, default n. With the option, a name with a/matches a builtin only if it names a file in a mounted BINFS. A bare name still matches. Without the option nothing changes. A name that does not match is "not my format", andload_absmodule()of #21454 gives the error: a missing file ENOENT, and a file that exists ENOEXEC.Impact
Default off: no behaviour change, and the new code is not compiled. The option depends on
CONFIG_BUILTIN, so it cannot be set in a kernel build. WithoutCONFIG_FS_BINFS, a name with a/never matches a builtin.The default stays because code depends on the old match. With the option and no BINFS at
/bin, these fail:posix_spawn("/bin/sh")gives ENOENT.popen("echo x")withoutCONFIG_LIBC_ENVPATHuses/bin/shand fails with ENOENT. A#!/bin/shscript gives ENOENT.execl("/bin/sh")in appsinterpreters/bas, the shell/bin/shof appsnetutils/dropbear, the default ofCONFIG_ADBD_SHELL_SERVICE_PATHin appssystem/adb, the shell/bin/nshthatgetpwnam()reports for root (ROOT_SHELL), andpopen()of a command that is a builtin (it starts with no shell).Not changed by this PR: these callers and apps. A BINFS mounted at
/binshould avoid the/bin/shfailures, but this was not run.Documentation:
Documentation/os/filesystem/binfs.rstnames the option, in its own commit.Testing
Test program on qemu-armv8a:nsh (flat, HVF) with
FS_BINFS PIPES SCHED_WAITPID, as a builtin. Theretvalue is the result ofposix_spawn()./nonexistent/execbuiltin/tmp/execbuiltin, a text fileexecbuiltin, a bare name/ebbin/execbuiltinin a mounted BINFS./execbuiltinwith the cwd in the BINFS/ebbin/nosuchprogram/ebbin/sub/execbuiltinThe option was also run without
FS_BINFS, and withELFandBINFMT_SCRIPT: missing, text file and bare name as above, ostest 0.Build only, with
EXTRAFLAGS="-Wno-cpp -Werror", no compiler warnings: option off and on: qemu-armv8a:nsh (flat), mps2-an500:knsh (protected), rv-virt:citest (flat); option on withoutFS_BINFS: qemu-armv8a:nsh, mps2-an500:knsh; qemu-armv8a:knsh (kernel, the option cannot be set). The change has no arch code.