linux-stable/security/selinux
Alfred Piccioni c014490c0b 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-31 16:17:00 -08:00
..
include lsm/stable-6.1 PR 20221003 2022-10-03 17:51:52 -07:00
ss selinux: set next pointer before attaching to list 2023-08-30 16:11:07 +02:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
Kconfig Documentation,selinux: deprecate setting checkreqprot to 1 2020-02-10 10:49:01 -05:00
Makefile selinux: don't use make's grouped targets feature yet 2023-06-09 10:34:24 +02:00
avc.c selinux: declare data arrays const 2022-05-03 15:53:49 -04:00
hooks.c lsm: new security_file_ioctl_compat() hook 2024-01-31 16:17:00 -08:00
ibpkey.c selinux: various sparse fixes 2022-02-01 19:08:28 -05:00
ima.c selinux/stable-5.18 PR 20220321 2022-03-21 20:47:54 -07:00
netif.c selinux: remove unused global variables 2021-01-12 09:49:01 -05:00
netlabel.c security: pass asoc to sctp_assoc_request and sctp_sk_clone 2021-11-03 11:09:20 +00:00
netlink.c selinux: mark some global variables __ro_after_init 2021-01-12 10:08:55 -05:00
netnode.c selinux: various sparse fixes 2022-02-01 19:08:28 -05:00
netport.c selinux: various sparse fixes 2022-02-01 19:08:28 -05:00
nlmsgtab.c selinux: resolve checkpatch errors 2022-05-03 13:59:15 -04:00
selinuxfs.c selinux: use int arrays for boolean values 2022-08-30 17:03:33 -04:00
status.c selinux: move status variables out of selinux_ss 2020-02-10 10:49:01 -05:00
xfrm.c selinux: use correct type for context length 2022-02-18 10:45:54 -05:00