[REGRESSION] fs: validate_fs_switch() rewrites fs_struct under PID 1 threads
From: Akisaira
Date: Wed Nov 18 2026 - 08:30:41 EST
Hi Christian,
Booting Android (AOSP system/core/init, android-17.0.0_r1) fails since
v7.3 and still fails on v7.4-rc3. Right after dmesg logs:
VFS: Pid 1 stopped sharing filesystem state
second-stage init stalls because every property write is rejected:
init: Unable to set property 'init.svc.<name>' from uid:0 gid:0 pid:1:
SELinux permission check failed (...)
v7.2 gets past this point with the same userspace. Bisecting mainline
between v7.2 and v7.3 landed on:
14adbd5341aa ("fs: stop sharing fs_struct between init_task and pid 1")
During second-stage startup, StartPropertyService() in Android's init
spawns two helper threads via std::thread, which clone with CLONE_FS and
share PID 1's fs_struct (userspace_init_fs). Later in the same startup
sequence, SetupMountNamespaces() calls unshare(CLONE_NEWNS) on the main
thread, implicitly unsharing CLONE_FS for PID 1 while both property
threads remain on userspace_init_fs.
As noted in the comment above validate_fs_switch(), resetting
userspace_init_fs to init_fs.root is meant to stop kworkers and
usermodehelpers from operating on stale filesystem state after PID 1
unshares. However, mutating userspace_init_fs in place via
set_fs_root()/set_fs_pwd() also rewrites root and pwd underneath any
CLONE_FS threads that PID 1 already created, moving live userspace
threads into nullfs (or empty rootfs at 14adbd5341aa). Once that
happens, libselinux in the property threads can no longer open
/sys/fs/selinux/access and treats every permission check as a denial.
Prior to 14adbd5341aa, PID 1 still shared init_fs with init_task, so
first-stage init's chroot had already updated init_fs.root to the real
root and set_fs_root(userspace_init_fs, &init_fs.root) was a no-op.
Skipping the set_fs_root()/set_fs_pwd() reset when old_fs->users > 1
(one reference is held by userspace_init_fs itself) clears the denials
and lets init proceed on v7.4-rc3 (tested on arm64, Qualcomm SC8280XP),
though that leaves kthreads using the old fs_struct via
scoped_with_init_fs() rather than switching them to nullfs. Happy to
test a proper fix.
#regzbot introduced: 14adbd5341aae18e7e14bc3786b49007c26b2503
Thanks,
Akisaira