fs,sched: add chroot() filesystem jail - #19900
Open
Abhishekmishra2808 wants to merge 4 commits into
Open
Conversation
Abhishekmishra2808
requested review from
Donny9,
anchao,
btashton,
jerpelea,
masayuki2009,
pkarashchenko,
pussuw,
raiden00pl and
xiaoxiang781216
as code owners
August 19, 2026 08:27
acassis
reviewed
Aug 19, 2026
Contributor
|
Nice work @Abhishekmishra2808 ! |
|
Abhishekmishra2808
force-pushed
the
feature/fs-chroot
branch
2 times, most recently
from
August 24, 2026 03:39
5b250cc to
d3ea539
Compare
Contributor
Author
|
@acassis PTAL ! |
acassis
previously approved these changes
Aug 24, 2026
Contributor
Abhishekmishra2808
force-pushed
the
feature/fs-chroot
branch
2 times, most recently
from
August 26, 2026 19:48
1dbd097 to
82821d6
Compare
Contributor
|
ci was fixed, please rebase your change to the last master. @Abhishekmishra2808, many code can be simplified with #19991. |
Abhishekmishra2808
force-pushed
the
feature/fs-chroot
branch
from
August 27, 2026 13:01
82821d6 to
3f75a6c
Compare
Contributor
Author
|
@xiaoxiang781216 done |
Contributor
@Abhishekmishra2808 please fix the conflict. |
Abhishekmishra2808
force-pushed
the
feature/fs-chroot
branch
from
August 29, 2026 07:50
3f75a6c to
0647bd2
Compare
Abhishekmishra2808
force-pushed
the
feature/fs-chroot
branch
from
August 29, 2026 19:28
0647bd2 to
330134a
Compare
Abhishekmishra2808
requested review from
GUIDINGLI,
Ouss4,
gustavonihei,
hartmannathan and
yamt
as code owners
August 29, 2026 19:28
Abhishekmishra2808
force-pushed
the
feature/fs-chroot
branch
from
August 30, 2026 09:01
330134a to
8a93d1f
Compare
Store the jail as an absolute path on the task group, copy it to children, and free it when the last member leaves. Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
Add CONFIG_FS_CHROOT and POSIX chroot(). Store the jail as an absolute path on the task group, and require euid 0 when user identity is enabled. Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
Abhishekmishra2808
force-pushed
the
feature/fs-chroot
branch
from
August 30, 2026 19:00
8a93d1f to
62982eb
Compare
Abhishekmishra2808
force-pushed
the
feature/fs-chroot
branch
from
September 2, 2026 21:48
62982eb to
83df4a9
Compare
acassis
previously approved these changes
Sep 2, 2026
Prepare paths in inode_search_setup(): prepend tg_root, canonicalize with a jail-floor dst_min, then walk from g_root_inode. Replace SETUP_SEARCH / RELEASE_SEARCH with inode_search_setup() / inode_search_release(). Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
Describe the jail, leftover pre-opened fds, the NSH command-form scrub, and the flat-build trust boundary shared with credentials. Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
Abhishekmishra2808
force-pushed
the
feature/fs-chroot
branch
from
September 3, 2026 07:46
83df4a9 to
c3d257b
Compare
| fs_truncate.c | ||
| fs_link.c) | ||
|
|
||
| if(CONFIG_FS_CHROOT) |
Contributor
There was a problem hiding this comment.
move this patch after fs: start absolute lookups at the jail root
| return OK; | ||
| } | ||
|
|
||
| newroot = strdup(abspath); |
| @@ -440,7 +446,7 @@ static int automount_findinode(FAR const char *path) | |||
| /* Relinquish our exclusive access to the inode try and return the result */ | |||
|
|
|||
| inode_runlock(); | |||
| } | ||
| else | ||
| { | ||
| newinode = NULL; |
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
CONFIG_FS_CHROOTadds POSIXchroot()so a task group can pin a directory as its filesystem root. The jail is stored astg_root(an absolute host path, orNULLif none). Children inherit a copy viastrdup; leaving the group frees it.Lookups stay inside the jail in
inode_search_setup(): join$PWDfor relative paths, prependtg_root, then canonicalize with a jail-floordst_minso..cannot climb out.chroot()does not rewritePWD.chroot("/")from the host root clears the jail; from inside a jail,/is still the jail, so it cannot be used to escape.This is a filesystem jail, not a container: descriptors opened before
chroot()that already point outside the tree remain usable, and the new root is not populated with/devor/proc.Impact
The option is off by default. When enabled,
chroot()is a new syscall and, withSCHED_USER_IDENTITY, requires effective UID 0. Companion apps change: apache/nuttx-apps#3735 (merged).Testing
Host: WSL2 x86_64. Board:
sim(CONFIG_FS_CHROOT=y). Companion apps: apache/nuttx-apps#3735.NSH jail session (syscall from userspace;
chrootbuiltin from apache/nuttx-apps#3735):