linux-stable/security
Mickaël Salaün 59ed284c7b landlock: Fix asymmetric private inodes referring
commit d9818b3e90 upstream.

When linking or renaming a file, if only one of the source or
destination directory is backed by an S_PRIVATE inode, then the related
set of layer masks would be used as uninitialized by
is_access_to_paths_allowed().  This would result to indeterministic
access for one side instead of always being allowed.

This bug could only be triggered with a mounted filesystem containing
both S_PRIVATE and !S_PRIVATE inodes, which doesn't seem possible.

The collect_domain_accesses() calls return early if
is_nouser_or_private() returns false, which means that the directory's
superblock has SB_NOUSER or its inode has S_PRIVATE.  Because rename or
link actions are only allowed on the same mounted filesystem, the
superblock is always the same for both source and destination
directories.  However, it might be possible in theory to have an
S_PRIVATE parent source inode with an !S_PRIVATE parent destination
inode, or vice versa.

To make sure this case is not an issue, explicitly initialized both set
of layer masks to 0, which means to allow all actions on the related
side.  If at least on side has !S_PRIVATE, then
collect_domain_accesses() and is_access_to_paths_allowed() check for the
required access rights.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Günther Noack <gnoack@google.com>
Cc: Jann Horn <jannh@google.com>
Cc: Shervin Oloumi <enlightened@chromium.org>
Cc: stable@vger.kernel.org
Fixes: b91c3e4ea7 ("landlock: Add support for file reparenting with LANDLOCK_ACCESS_FS_REFER")
Link: https://lore.kernel.org/r/20240219190345.2928627-1-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-03-06 14:45:10 +00:00
..
apparmor apparmor: Free up __cleanup() name 2024-02-23 09:12:51 +01:00
bpf bpf: Implement task local storage 2020-11-06 08:08:37 -08:00
integrity ima: detect changes to the backing overlay file 2023-11-28 17:07:12 +00:00
keys Revert "KEYS: encrypted: Add check for strsep" 2024-01-25 15:27:52 -08:00
landlock landlock: Fix asymmetric private inodes referring 2024-03-06 14:45:10 +00:00
loadpin LoadPin: Ignore the "contents" argument of the LSM hooks 2022-12-31 13:33:07 +01:00
lockdown lockdown: ratelimit denial messages 2022-09-14 07:37:50 -04:00
safesetid LSM: SafeSetID: Add setgroups() security policy handling 2022-07-15 18:24:42 +00:00
selinux lsm: new security_file_ioctl_compat() hook 2024-01-31 16:17:00 -08:00
smack lsm: new security_file_ioctl_compat() hook 2024-01-31 16:17:00 -08:00
tomoyo tomoyo: fix UAF write bug in tomoyo_write_control() 2024-03-06 14:45:09 +00:00
yama task_work: cleanup notification modes 2020-10-17 15:05:30 -06:00
Kconfig x86/retbleed: Add fine grained Kconfig knobs 2022-06-29 17:43:41 +02:00
Kconfig.hardening randstruct: disable Clang 15 support 2023-02-25 11:25:43 +01:00
Makefile security: remove unneeded subdir-$(CONFIG_...) 2021-09-03 08:17:20 +09:00
commoncap.c capabilities: fix potential memleak on error path from vfs_getxattr_alloc() 2022-10-28 06:44:33 -04:00
device_cgroup.c device_cgroup: Roll back to original exceptions after copy failure 2023-01-07 11:11:56 +01:00
inode.c
lsm_audit.c lsm: clean up redundant NULL pointer check 2022-08-15 22:44:01 -04:00
min_addr.c
security.c lsm: fix the logic in security_inode_getsecctx() 2024-02-23 09:12:37 +01:00