From: Christian Brauner <brauner@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [GIT PULL 10/18 for v7.3] vfs kthread
Date: Fri, 14 Aug 2026 15:12:59 +0200 [thread overview]
Message-ID: <20260814-vfs-7.3-rc1.kthread-f4580c1bc853@brauner> (raw)
In-Reply-To: <20260814-vfs-v73-6e884cb31ac9@brauner>
Hey Linus,
/* Summary */
This stops kernel threads from sharing filesystem state with userspace.
This work is about 3 cycles old and has been in -next for about that
time.
When the kernel boots init_task creates PID 1 and then kthreadd. From
that point every kthread and PID 1 share the same fs_struct. That is why
pivot_root() has to rewrite the fs_struct of all kthreads. The rewriting
exists so that kthreads can use init's filesystem state when they want
to. It also means userspace can move the ground out from under the
kernel.
PID 1 now gets a completely separate fs_struct. All kthreads are
anchored in a private SB_KERNMOUNT instance of nullfs that cannot be
mounted on and cannot be used to follow other mounts. Userspace init
can no longer affect kthread filesystem state and kthreads can no
longer affect userspace fs state without explicit opting in to that.
Path lookup from a kthread now fails by default. It makes it
deliberately hard to offload security sensitive operations into init's
filesystem state from a kthread.
Places that legitimately need to look something up there opt in through
the new scoped_with_init_fs() which temporarily overrides the caller's
fs_struct with init's. usermodehelpers remain the only kernel tasks that
genuinely share init's filesystem state, since they execute random
binaries in the root filesystem (excellent...).
The visible result is that /proc/2/root is a nullfs with an empty
mountinfo while /proc/1/root is the real root.
/* Testing */
No build failures or warnings were observed.
/* Conflicts */
Merge conflicts with mainline
=============================
No known conflicts.
Merge conflicts with other trees
================================
No known conflicts.
The following changes since commit dc59e4fea9d83f03bad6bddf3fa2e52491777482:
Linux 7.2-rc1 (2026-06-28 12:01:31 -0700)
are available in the Git repository at:
git@gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs tags/vfs-7.3-rc1.kthread
for you to fetch changes up to b4343aebd3a4dd255b15b2e5b1363d6399da302f:
initramfs_test: use test init/exit hooks to override init fs (2026-07-31 12:56:51 +0200)
----------------------------------------------------------------
vfs-7.3-rc1.kthread
Please consider pulling these changes from the signed vfs-7.3-rc1.kthread tag.
Thanks!
Christian
----------------------------------------------------------------
Christian Brauner (27):
fs: add switch_fs_struct()
fs: notice when init abandons fs sharing
fs: add scoped_with_init_fs()
fs: add real_fs to track task's actual fs_struct
fs: make userspace_init_fs a dynamically-initialized pointer
rnbd: use scoped_with_init_fs() for block device open
crypto: ccp: use scoped_with_init_fs() for SEV file access
scsi: target: use scoped_with_init_fs() for ALUA metadata
scsi: target: use scoped_with_init_fs() for APTPL metadata
btrfs: use scoped_with_init_fs() for update_dev_time()
coredump: use scoped_with_init_fs() for coredump path resolution
fs: use scoped_with_init_fs() for kernel_read_file_from_path_initns()
ksmbd: use scoped_with_init_fs() for share path resolution
ksmbd: use scoped_with_init_fs() for filesystem info path lookup
ksmbd: use scoped_with_init_fs() for VFS path operations
pnfs/blocklayout: use scoped_with_init_fs() for SCSI device lookup
initramfs: use scoped_with_init_fs() for rootfs unpacking
af_unix: use scoped_with_init_fs() for coredump socket lookup
fs: stop sharing fs_struct between init_task and pid 1
fs: add umh argument to struct kernel_clone_args
devtmpfs: create private mount namespace
nullfs: make nullfs multi-instance
fs: start all kthreads in nullfs
fs: stop rewriting kthread fs structs
fs: stop rewriting paths for PF_EXITING | PF_DUMPCORE
Merge patch series "fs,kthread: start all kthreads in nullfs"
initramfs_test: use test init/exit hooks to override init fs
drivers/base/devtmpfs.c | 2 +-
drivers/block/rnbd/rnbd-srv.c | 4 +-
drivers/char/misc_minor_kunit.c | 25 +++++----
drivers/crypto/ccp/sev-dev.c | 12 ++---
drivers/target/target_core_alua.c | 11 +++-
drivers/target/target_core_pr.c | 4 +-
fs/btrfs/volumes.c | 11 +++-
fs/coredump.c | 11 ++--
fs/fs_struct.c | 103 ++++++++++++++++++++++++++++++++++++--
fs/kernel_read_file.c | 9 +---
fs/namespace.c | 16 +++---
fs/nfs/blocklayout/dev.c | 15 ++++--
fs/nullfs.c | 12 ++---
fs/proc/array.c | 4 +-
fs/proc/base.c | 8 +--
fs/proc_namespace.c | 4 +-
fs/smb/server/mgmt/share_config.c | 4 +-
fs/smb/server/smb2pdu.c | 4 +-
fs/smb/server/vfs.c | 9 ++--
include/linux/fs_struct.h | 34 +++++++++++++
include/linux/init_task.h | 1 +
include/linux/sched.h | 1 +
include/linux/sched/task.h | 1 +
init/init_task.c | 1 +
init/initramfs.c | 14 ++++--
init/initramfs_test.c | 19 ++++++-
init/main.c | 10 +++-
kernel/fork.c | 53 ++++++++++++--------
kernel/kcmp.c | 2 +-
kernel/umh.c | 6 +--
net/unix/af_unix.c | 17 +++----
31 files changed, 311 insertions(+), 116 deletions(-)
next prev parent reply other threads:[~2026-08-14 13:13 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 13:07 [GIT PULL 00/18 for v7.3] v7.3 Christian Brauner
2026-08-14 13:10 ` [GIT PULL 01/18 for v7.3] ipc misc Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:11 ` [GIT PULL 02/18 for v7.3] kernel misc Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:11 ` [GIT PULL 03/18 for v7.3] vfs binfmt Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:11 ` [GIT PULL 04/18 for v7.3] vfs efs Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:11 ` [GIT PULL 05/18 for v7.3] vfs failfs Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:12 ` [GIT PULL 06/18 for v7.3] vfs fat Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:12 ` [GIT PULL 07/18 for v7.3] vfs freevxfs Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:12 ` [GIT PULL 08/18 for v7.3] vfs iomap Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:12 ` [GIT PULL 09/18 for v7.3] vfs kfunc Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:12 ` Christian Brauner [this message]
2026-08-17 22:25 ` [GIT PULL 10/18 for v7.3] vfs kthread pr-tracker-bot
2026-08-14 13:13 ` [GIT PULL 11/18 for v7.3] vfs lookup Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:13 ` [GIT PULL 12/18 for v7.3] vfs misc Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:13 ` [GIT PULL 13/18 for v7.3] vfs mount Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:14 ` [GIT PULL 14/18 for v7.3] vfs netfs Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:14 ` [GIT PULL 15/18 for v7.3] vfs nilfs2 Christian Brauner
2026-08-14 17:26 ` Viacheslav Dubeyko
2026-08-17 7:30 ` Christian Brauner
2026-08-14 13:14 ` [GIT PULL 16/18 for v7.3] vfs ovl Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:14 ` [GIT PULL 17/18 for v7.3] vfs super Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
2026-08-14 13:15 ` [GIT PULL 18/18 for v7.3] vfs sync Christian Brauner
2026-08-17 22:25 ` pr-tracker-bot
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=20260814-vfs-7.3-rc1.kthread-f4580c1bc853@brauner \
--to=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®