]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
kernel: fix execve after pivot_root via vfs_lookup_initrd(); fork execve test
authorTulio A M Mendes <[email protected]>
Mon, 27 Apr 2026 00:28:10 +0000 (21:28 -0300)
committerTulio A M Mendes <[email protected]>
Mon, 27 Apr 2026 00:28:10 +0000 (21:28 -0300)
commit0f374eee1be7c0f13d153bdfce0aabb161bdba38
tree43a1e055f8603f136a2e2c805f695749bd81e30b
parent1b6b07a7b168b8d784758dfc8d06b8330bf8cabe
kernel: fix execve after pivot_root via vfs_lookup_initrd(); fork execve test

pivot_root changes the global fs_root and '/' mount entry to a tmpfs,
which breaks subsequent execve calls because vfs_lookup('/bin/echo')
fails in the new root.  This caused the 'echo execve' flaky test
failure (it always failed when run after the pivot_root test).

Fix: save the original initrd overlayfs root at boot and add
vfs_lookup_initrd() which does a direct finddir traversal from that
saved root, bypassing the VFS mount table.  Use it in:
- elf32_load_user_from_initrd (binary lookup)
- elf32_load_interp (ld.so lookup)
- elf32_load_shared_lib_at (libc.so lookup)
- syscall_execve_impl (early ENOENT check)

Also change the execve test to fork a child (like execveat), so PID 1
is not replaced and the test harness can verify the output.

Tests: 120/120 smoke, 33/33 battery, 69/69 host, cppcheck clean.
include/fs.h
src/arch/x86/elf.c
src/kernel/fs.c
src/kernel/init.c
src/kernel/syscall.c
user/cmds/fulltest/fulltest.c