linux-stable/security/tomoyo
Alfred Piccioni 3dd76bebcd 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:25:15 +01:00
..
policy
.gitignore
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile tomoyo: fix broken dependency on *.conf.default 2023-02-06 07:52:35 +01:00
audit.c tomoyo: Coding style fix. 2019-01-24 14:50:27 -08:00
common.c tomoyo: Use atomic_t for statistics counter 2020-02-05 21:22:41 +00:00
common.h tomoyo: Bump version. 2019-02-19 14:17:25 -08:00
condition.c tomoyo: Coding style fix. 2019-01-24 14:50:27 -08:00
domain.c tomoyo: Suppress RCU warning at list_for_each_entry_rcu(). 2020-01-17 19:49:05 +01:00
environ.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
file.c tomoyo: Coding style fix. 2019-01-24 14:50:27 -08:00
gc.c tomoyo: Coding style fix. 2019-01-24 14:50:27 -08:00
group.c tomoyo: Suppress RCU warning at list_for_each_entry_rcu(). 2020-01-17 19:49:05 +01:00
load_policy.c TOMOYO: fix __setup handlers return values 2022-04-15 14:18:13 +02:00
memory.c tomoyo: Coding style fix. 2019-01-24 14:50:27 -08:00
mount.c tomoyo: Coding style fix. 2019-01-24 14:50:27 -08:00
network.c tomoyo: Check address length before reading address family 2019-05-10 14:58:25 -07:00
realpath.c tomoyo: Don't use nifty names on sockets. 2020-01-04 19:18:42 +01:00
securityfs_if.c tomoyo: Coding style fix. 2019-01-24 14:50:27 -08:00
tomoyo.c lsm: new security_file_ioctl_compat() hook 2024-02-23 08:25:15 +01:00
util.c tomoyo: Check exceeded quota early in tomoyo_domain_quota_is_ok(). 2022-01-05 12:37:43 +01:00