linux-stable/security/selinux
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
..
include selinux: fall back to ref-walk if audit is required 2020-02-14 16:34:20 -05:00
ss selinux: Add boundary check in put_entry() 2022-08-25 11:17:32 +02:00
.gitignore
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile selinux: don't use make's grouped targets feature yet 2023-06-09 10:29:02 +02:00
avc.c selinux: use __GFP_NOWARN with GFP_NOWAIT in the AVC 2021-07-19 08:53:10 +02:00
hooks.c lsm: new security_file_ioctl_compat() hook 2024-02-23 08:25:15 +01:00
ibpkey.c selinux: Fix error return code in sel_ib_pkey_sid_slow() 2020-11-18 19:20:30 +01:00
netif.c selinux/stable-5.4 PR 20190917 2019-09-23 11:21:04 -07:00
netlabel.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 13 2019-05-21 11:28:45 +02:00
netlink.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
netnode.c selinux/stable-5.4 PR 20190917 2019-09-23 11:21:04 -07:00
netport.c selinux/stable-5.4 PR 20190917 2019-09-23 11:21:04 -07:00
nlmsgtab.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-06-22 08:59:24 -04:00
selinuxfs.c selinux: sel_avc_get_stat_idx should increase position index 2020-10-01 13:17:32 +02:00
xfrm.c selinux: use correct type for context length 2022-04-15 14:18:22 +02:00