linux-stable/security
Roberto Sassu 3307dd6c10 smack: Record transmuting in smk_transmuted
commit 2c085f3a8f upstream.

smack_dentry_create_files_as() determines whether transmuting should occur
based on the label of the parent directory the new inode will be added to,
and not the label of the directory where it is created.

This helps for example to do transmuting on overlayfs, since the latter
first creates the inode in the working directory, and then moves it to the
correct destination.

However, despite smack_dentry_create_files_as() provides the correct label,
smack_inode_init_security() does not know from passed information whether
or not transmuting occurred. Without this information,
smack_inode_init_security() cannot set SMK_INODE_CHANGED in smk_flags,
which will result in the SMACK64TRANSMUTE xattr not being set in
smack_d_instantiate().

Thus, add the smk_transmuted field to the task_smack structure, and set it
in smack_dentry_create_files_as() to smk_task if transmuting occurred. If
smk_task is equal to smk_transmuted in smack_inode_init_security(), act as
if transmuting was successful but without taking the label from the parent
directory (the inode label was already set correctly from the current
credentials in smack_inode_alloc_security()).

Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
[4.19: adjusted for the lack of helper functions]
Fixes: d6d80cb57b ("Smack: Base support for overlayfs")
Signed-off-by: Munehisa Kamata <kamatam@amazon.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-10-10 21:44:59 +02:00
..
apparmor apparmor: Fix abi check to include v8 abi 2023-01-18 11:30:21 +01:00
integrity IMA: allow/fix UML builds 2023-08-30 16:31:43 +02:00
keys security: keys: perform capable check only on privileged operations 2023-09-23 10:47:58 +02:00
loadpin
selinux selinux: don't use make's grouped targets feature yet 2023-06-09 10:24:03 +02:00
smack smack: Record transmuting in smk_transmuted 2023-10-10 21:44:59 +02:00
tomoyo tomoyo: fix broken dependency on *.conf.default 2023-02-06 07:49:37 +01:00
yama
commoncap.c capabilities: fix potential memleak on error path from vfs_getxattr_alloc() 2022-11-10 17:46:55 +01:00
device_cgroup.c device_cgroup: Roll back to original exceptions after copy failure 2023-01-18 11:30:44 +01:00
inode.c
Kconfig fortify: Explicitly disable Clang support 2021-11-26 11:36:18 +01:00
lsm_audit.c dump_common_audit_data(): fix racy accesses to ->d_name 2021-01-19 18:22:37 +01:00
Makefile
min_addr.c
security.c ima: Align ima_file_mmap() parameters with mmap_file LSM hook 2023-03-11 16:31:51 +01:00