mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 13:23:02 -04:00
af_unix: use scoped_with_init_fs() for coredump socket lookup
Use scoped_with_init_fs() to temporarily override current->fs for the coredump unix socket path resolution. This replaces the init_root() + vfs_path_lookup() pattern with scoped_with_init_fs() + kern_path(). The old code used LOOKUP_BENEATH to confine the lookup beneath init's root. This is dropped because the coredump socket path is absolute and resolved from root (where ".." is a no-op), and LOOKUP_NO_SYMLINKS already blocks any symlink-based escape. LOOKUP_BENEATH was redundant in this context. unix_find_bsd(SOCK_COREDUMP) ← coredump_sock_connect() ← do_coredump() — same crashing userspace process Same security rationale as coredump. Link: https://patch.msgid.link/20260601-work-kthread-nullfs-v4-18-77ee053060e0@kernel.org Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
@@ -1196,17 +1196,12 @@ static struct sock *unix_find_bsd(struct sockaddr_un *sunaddr, int addr_len,
|
||||
unix_mkname_bsd(sunaddr, addr_len);
|
||||
|
||||
if (flags & SOCK_COREDUMP) {
|
||||
struct path root;
|
||||
|
||||
task_lock(&init_task);
|
||||
get_fs_root(init_task.fs, &root);
|
||||
task_unlock(&init_task);
|
||||
|
||||
scoped_with_kernel_creds()
|
||||
err = vfs_path_lookup(root.dentry, root.mnt, sunaddr->sun_path,
|
||||
LOOKUP_BENEATH | LOOKUP_NO_SYMLINKS |
|
||||
LOOKUP_NO_MAGICLINKS, &path);
|
||||
path_put(&root);
|
||||
scoped_with_init_fs() {
|
||||
scoped_with_kernel_creds()
|
||||
err = kern_path(sunaddr->sun_path,
|
||||
LOOKUP_NO_SYMLINKS |
|
||||
LOOKUP_NO_MAGICLINKS, &path);
|
||||
}
|
||||
if (err)
|
||||
goto fail;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user