linux-stable/security
Alfred Piccioni f8f51085b4 lsm: new security_file_ioctl_compat() hook
commit f1bb47a31d upstream.

Some ioctl commands do not require ioctl permission, but are routed to
other permissions such as FILE_GETATTR or FILE_SETATTR. This routing is
done by comparing the ioctl cmd to a set of 64-bit flags (FS_IOC_*).

However, if a 32-bit process is running on a 64-bit kernel, it emits
32-bit flags (FS_IOC32_*) for certain ioctl operations. These flags are
being checked erroneously, which leads to these ioctl operations being
routed to the ioctl permission, rather than the correct file
permissions.

This was also noted in a RED-PEN finding from a while back -
"/* RED-PEN how should LSM module know it's handling 32bit? */".

This patch introduces a new hook, security_file_ioctl_compat(), that is
called from the compat ioctl syscall. All current LSMs have been changed
to support this hook.

Reviewing the three places where we are currently using
security_file_ioctl(), it appears that only SELinux needs a dedicated
compat change; TOMOYO and SMACK appear to be functional without any
change.

Cc: stable@vger.kernel.org
Fixes: 0b24dcb7f2 ("Revert "selinux: simplify ioctl checking"")
Signed-off-by: Alfred Piccioni <alpic@google.com>
Reviewed-by: Stephen Smalley <stephen.smalley.work@gmail.com>
[PM: subject tweak, line length fixes, and alignment corrections]
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-02-23 08:12:58 +01:00
..
apparmor apparmor: avoid crash when parsed profile name is empty 2024-01-25 14:33:38 -08:00
integrity ima: detect changes to the backing overlay file 2023-12-08 08:43:26 +01:00
keys security: keys: perform capable check only on privileged operations 2023-09-23 10:47:58 +02:00
loadpin
selinux lsm: new security_file_ioctl_compat() hook 2024-02-23 08:12:58 +01:00
smack lsm: new security_file_ioctl_compat() hook 2024-02-23 08:12:58 +01:00
tomoyo lsm: new security_file_ioctl_compat() hook 2024-02-23 08:12:58 +01:00
yama
Kconfig fortify: Explicitly disable Clang support 2021-11-26 11:36:18 +01:00
Makefile
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
lsm_audit.c
min_addr.c
security.c lsm: new security_file_ioctl_compat() hook 2024-02-23 08:12:58 +01:00