summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorPaul Moore <paul@paul-moore.com>2025-02-06 22:30:20 -0500
committerPaul Moore <paul@paul-moore.com>2025-02-07 15:30:54 -0500
commit5fc80fb5b776fa22b01472baecec4d26d1af811b (patch)
tree764542a17c3ce5ab3911da89e4a51162448124e6 /security
parent75eb39f2f50b8183fe7c14ca86acf6a1849d495a (diff)
downloadlinux-5fc80fb5b776fa22b01472baecec4d26d1af811b.tar.gz
linux-5fc80fb5b776fa22b01472baecec4d26d1af811b.tar.bz2
linux-5fc80fb5b776fa22b01472baecec4d26d1af811b.zip
selinux: always check the file label in selinux_kernel_read_file()
Commit 2039bda1fa8d ("LSM: Add "contents" flag to kernel_read_file hook") added a new flag to the security_kernel_read_file() LSM hook, "contents", which was set if a file was being read in its entirety or if it was the first chunk read in a multi-step process. The SELinux LSM callback was updated to only check against the file label if this "contents" flag was set, meaning that in multi-step reads the file label was not considered in the access control decision after the initial chunk. Thankfully the only in-tree user that performs a multi-step read is the "bcm-vk" driver and it is loading firmware, not a kernel module, so there are no security regressions to worry about. However, we still want to ensure that the SELinux code does the right thing, and *always* checks the file label, especially as there is a chance the file could change between chunk reads. Fixes: 2039bda1fa8d ("LSM: Add "contents" flag to kernel_read_file hook") Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security')
-rw-r--r--security/selinux/hooks.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 7b867dfec88b..a80e3f01153f 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -4134,7 +4134,7 @@ static int selinux_kernel_read_file(struct file *file,
switch (id) {
case READING_MODULE:
- rc = selinux_kernel_module_from_file(contents ? file : NULL);
+ rc = selinux_kernel_module_from_file(file);
break;
default:
break;