kernel_samsung_a53x/security
Ondrej Mosnacek 0e74b22926 lsm: fix the logic in security_inode_getsecctx()
commit 99b817c173cd213671daecd25ca27f56b0c7c4ec upstream.

The inode_getsecctx LSM hook has previously been corrected to have
-EOPNOTSUPP instead of 0 as the default return value to fix BPF LSM
behavior. However, the call_int_hook()-generated loop in
security_inode_getsecctx() was left treating 0 as the neutral value, so
after an LSM returns 0, the loop continues to try other LSMs, and if one
of them returns a non-zero value, the function immediately returns with
said value. So in a situation where SELinux and the BPF LSMs registered
this hook, -EOPNOTSUPP would be incorrectly returned whenever SELinux
returned 0.

Fix this by open-coding the call_int_hook() loop and making it use the
correct LSM_RET_DEFAULT() value as the neutral one, similar to what
other hooks do.

Cc: stable@vger.kernel.org
Reported-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Link: https://lore.kernel.org/selinux/CAEjxPJ4ev-pasUwGx48fDhnmjBnq_Wh90jYPwRQRAqXxmOKD4Q@mail.gmail.com/
Link: https://bugzilla.redhat.com/show_bug.cgi?id=2257983
Fixes: b36995b8609a ("lsm: fix default return value for inode_getsecctx")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
[PM: subject line tweak]
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-18 12:13:29 +01:00
..
apparmor apparmor: avoid crash when parsed profile name is empty 2024-11-18 12:12:50 +01:00
bpf Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
integrity ima: detect changes to the backing overlay file 2024-11-18 11:43:25 +01:00
keys keys, dns: Allow key types (eg. DNS) to be reclaimed immediately on expiry 2024-11-18 12:11:59 +01:00
loadpin Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lockdown Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
safesetid Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
samsung security: samsung: defex_lsm: nuke 2024-06-15 16:20:49 -03:00
sdp Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selinux lsm: new security_file_ioctl_compat() hook 2024-11-18 12:12:58 +01:00
smack lsm: new security_file_ioctl_compat() hook 2024-11-18 12:12:58 +01:00
tomoyo lsm: new security_file_ioctl_compat() hook 2024-11-18 12:12:58 +01:00
yama Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
commoncap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
device_cgroup.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inode.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig security: samsung: defex_lsm: nuke 2024-06-15 16:20:49 -03:00
Kconfig.hardening Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lsm_audit.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile security: samsung: defex_lsm: nuke 2024-06-15 16:20:49 -03:00
min_addr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
security.c lsm: fix the logic in security_inode_getsecctx() 2024-11-18 12:13:29 +01:00