All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] selinux: reject writable opens of status file, drop mmap write checks
@ 2026-09-11 14:58 Stephen Smalley
  2026-09-11 15:08 ` sashiko-bot
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Stephen Smalley @ 2026-09-11 14:58 UTC (permalink / raw)
  To: selinux
  Cc: paul, omosnacek, Stephen Smalley, ljs, jannh, jack, cgzones,
	brauner

Similar to what
https://lore.kernel.org/selinux/aqPUqU3eZeFrykj3@gremlin/ does for the
policy file, update the .open handler for the status file to reject
writable opens, and update the .mmap handler to stop clearing
VM_MAYWRITE and checking for VM_WRITE. This does NOT prevent
truncation via open(O_RDONLY|O_TRUNC) or truncate(), which is
left to another patch.

Link: https://lore.kernel.org/selinux/aqPUqU3eZeFrykj3@gremlin/
cc: ljs@kernel.org
cc: jannh@google.com
cc: jack@suse.cz
cc: cgzones@googlemail.com
cc: brauner@kernel.org
Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com>
---
v2 corrects my previous incorrect claim re preventing truncation,
deferring that to a separate patch like the still-pending one
from cgzones, and also moves the FMODE_WRITE check before the
status page allocation.

 security/selinux/selinuxfs.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 292302eb60f3..835594d221fc 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -214,8 +214,12 @@ static const struct file_operations sel_handle_unknown_ops = {
 
 static int sel_open_handle_status(struct inode *inode, struct file *filp)
 {
-	struct page    *status = selinux_kernel_status_page();
+	struct page    *status;
 
+	if (filp->f_mode & FMODE_WRITE)
+		return -EACCES;
+
+	status = selinux_kernel_status_page();
 	if (!status)
 		return -ENOMEM;
 
@@ -247,11 +251,6 @@ static int sel_mmap_handle_status(struct file *filp,
 	/* only allows one page from the head */
 	if (vma->vm_pgoff > 0 || size != PAGE_SIZE)
 		return -EIO;
-	/* disallow writable mapping */
-	if (vma->vm_flags & VM_WRITE)
-		return -EPERM;
-	/* disallow mprotect() turns it into writable */
-	vm_flags_clear(vma, VM_MAYWRITE);
 
 	return remap_pfn_range(vma, vma->vm_start,
 			       page_to_pfn(status),
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-14  7:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-11 14:58 [PATCH v2] selinux: reject writable opens of status file, drop mmap write checks Stephen Smalley
2026-09-11 15:08 ` sashiko-bot
2026-09-11 15:12 ` Lorenzo Stoakes (ARM)
2026-09-11 15:23 ` Jan Kara
2026-09-11 16:14   ` Stephen Smalley
2026-09-14  7:46     ` Jan Kara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.