selinux: prune deprecated interfaces
Stephen Smalley
maintainerv2 cover selinux: prune deprecated interfaces
*** BLURB HERE ***
Stephen Smalley (3):
selinux: prune /sys/fs/selinux/checkreqprot
selinux: prune /sys/fs/selinux/disable
selinux: prune /sys/fs/selinux/user
.../{obsolete => removed}/sysfs-selinux-user | 0
security/selinux/include/security.h | 2 -
security/selinux/selinuxfs.c | 145 ++----------------
security/selinux/ss/services.c | 125 ---------------
4 files changed, 13 insertions(+), 259 deletions(-)
rename Documentation/ABI/{obsolete => removed}/sysfs-selinux-user (100%)Signature · 1 line
2.54.0
Stephen Smalley
maintainerPATCH v2 1/3 selinux: prune /sys/fs/selinux/checkreqprot
commit a7e4676e8e2cb ("selinux: remove the 'checkreqprot' functionality") removed the ability to modify the checkreqprot setting but left everything except the updating of the checkreqprot value intact. Aside from unnecessary processing, this could produce a local DoS from log spam and incorrectly calls selinux_ima_measure_state() on each write even though no state has changed. Prune it to just return count (i.e. all bytes written successfully) so that userspace never breaks.
--- security/selinux/selinuxfs.c | 45 ++++-------------------------------- 1 file changed, 5 insertions(+), 40 deletions(-)
security/selinux/selinuxfs.c +5 -40
@@ -689,46 +689,11 @@ static ssize_t sel_read_checkreqprot(struct file *filp, char __user *buf,static ssize_t sel_write_checkreqprot (struct file *file,const char __user *buf,size_t count,loff_t *ppos) { -char *page; -ssize_t length; -unsigned int new_value; - - length =avc_has_perm (current_sid (),SECINITSID_SECURITY , -SECCLASS_SECURITY ,SECURITY__SETCHECKREQPROT , -NULL ); -if (length) -return length; - -if (count >=PAGE_SIZE ) -return -ENOMEM ; - -/* No partial writes. */ -if (*ppos !=0 ) -return -EINVAL ; - - page =memdup_user_nul (buf, count); -if (IS_ERR (page)) -return PTR_ERR (page); - -if (sscanf (page,"%u" , &new_value) !=1 ) { - length = -EINVAL ; - goto out; - } - length = count; - -if (new_value) { -char comm[sizeof (current->comm)]; - -strscpy (comm, current->comm); -pr_err ("SELinux: %s (%d) set checkreqprot to 1. This is no longer supported.\n" , - comm, current->pid); - } - -selinux_ima_measure_state (); - -out: -kfree (page); -return length; +/* +* Setting checkreqprot is no longer supported, see +* https://github.com/SELinuxProject/selinux-kernel/wiki/DEPRECATE-checkreqprot +*/ +return count; }static const struct file_operations sel_checkreqprot_ops = { .read = sel_read_checkreqprot,
Signature · 1 line
2.54.0
Re: [PATCH v2 1/3] selinux: prune /sys/fs/selinux/checkreqprot
Quoted 9 lines · Stephen Smalley
commit
a7e4676e8e2cb("selinux: remove the 'checkreqprot' functionality") removed the ability to modify the checkreqprot setting but left everything except the updating of the checkreqprot value intact. Aside from unnecessary processing, this could produce a local DoS from log spam and incorrectly callsselinux_ima_measure_state()on each write even though no state has changed. Prune it to just return count (i.e. all bytes written successfully) so that userspace never breaks.
The log spam could also be addressed by switching to pr_err_once(), but a full removal is also fine with me.
Quoted 5 lines
Signed-off-by Stephen Smalley <[email protected]>--- security/selinux/selinuxfs.c | 45 ++++-------------------------------- 1 file changed, 5 insertions(+), 40 deletions(-)
--
Ondrej Mosnacek
Senior Software Engineer, Linux Security - SELinux kernel Red Hat, Inc.
Paul Moore
maintainerRe: [PATCH v2 1/3] selinux: prune /sys/fs/selinux/checkreqprot
In reply to Stephen SmalleyQuoted 47 lines · On Apr 29, 2026 Stephen Smalley <[email protected]> wrote:
commit
a7e4676e8e2cb("selinux: remove the 'checkreqprot' functionality") removed the ability to modify the checkreqprot setting but left everything except the updating of the checkreqprot value intact. Aside from unnecessary processing, this could produce a local DoS from log spam and incorrectly callsselinux_ima_measure_state()on each write even though no state has changed. Prune it to just return count (i.e. all bytes written successfully) so that userspace never breaks.Signed-off-by Stephen Smalley <[email protected]>--- security/selinux/selinuxfs.c | 45 ++++-------------------------------- 1 file changed, 5 insertions(+), 40 deletions(-)security/selinux/selinuxfs.c +0
-24@@ -689,46 +689,11 @@ static ssize_t sel_read_checkreqprot(struct file *filp, char __user *buf,static ssize_t sel_write_checkreqprot (struct file *file,const char __user *buf,size_t count,loff_t *ppos) { -char *page; -ssize_t length; -unsigned int new_value; - - length =avc_has_perm (current_sid (),SECINITSID_SECURITY , -SECCLASS_SECURITY ,SECURITY__SETCHECKREQPROT , -NULL ); -if (length) -return length; - -if (count >=PAGE_SIZE ) -return -ENOMEM ; - -/* No partial writes. */ -if (*ppos !=0 ) -return -EINVAL ; - - page =memdup_user_nul (buf, count); -if (IS_ERR (page)) -return PTR_ERR (page); - -if (sscanf (page,"%u" , &new_value) !=1 ) { - length = -EINVAL ; - goto out;
security/selinux/selinuxfs.c static ssize_t sel_read_checkreqprot(struct file *filp, char __user *buf, · line 725
Quoted 10 lines
security/selinux/selinuxfs.c +0
-10- } - length = count; - -if (new_value) { -char comm[sizeof (current->comm)]; - -strscpy (comm, current->comm); -pr_err ("SELinux: %s (%d) set checkreqprot to 1. This is no longer supported.\n" , - comm, current->pid); - }
I agree with Ondrej's comment that the log spam problem could be resolved with pr_err_once() while still preserving the notification. Since it will only be reported once, you can probably skip the read/parsing/etc. and just report that checkreqprot is no longer supported:
static ssize_t swl_write_checkreqprot(...)
{
/*
* Setting ... <deprecation url>
*/
pr_err_once(...);
return count;
}Quoted 15 lines
security/selinux/selinuxfs.c +5
-5-selinux_ima_measure_state (); - -out: -kfree (page); -return length; +/* +* Setting checkreqprot is no longer supported, see +* https://github.com/SELinuxProject/selinux-kernel/wiki/DEPRECATE-checkreqprot +*/ +return count; }static const struct file_operations sel_checkreqprot_ops = { .read = sel_read_checkreqprot,Signature · 1 line
2.54.0
--
paul-moore.com
Stephen Smalley
maintainerPATCH v2 2/3 selinux: prune /sys/fs/selinux/disable
In reply to Stephen SmalleyCommit f22f9aaf6c3d ("selinux: remove the runtime disable functionality") removed the SELinux runtime disable functionality but left everything except the actual runtime disable functionality intact and started logging an error message to warn any residual users.
Prune it to just return count (i.e. all bytes written successfully) to avoid breaking userspace. This also fixes a local DoS from logspam.
--- security/selinux/selinuxfs.c | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-)
security/selinux/selinuxfs.c +5 -29
@@ -272,35 +272,11 @@ static ssize_t sel_write_disable(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { - char *page; -ssize_t length; -int new_value; - -if (count >=PAGE_SIZE ) -return -ENOMEM ; - -/* No partial writes. */ -if (*ppos !=0 ) -return -EINVAL ; - - page =memdup_user_nul (buf, count); -if (IS_ERR (page)) -return PTR_ERR (page); - -if (sscanf (page,"%d" , &new_value) !=1 ) { - length = -EINVAL ; - goto out; - } - length = count; - -if (new_value) { -pr_err ("SELinux: https://github.com/SELinuxProject/selinux-kernel/wiki/DEPRECATE-runtime-disable\n" ); -pr_err ("SELinux: Runtime disable is not supported, use selinux=0 on the kernel cmdline.\n" ); - } - -out: -kfree (page); -return length; +/* +* Setting disable is no longer supported, see +* https://github.com/SELinuxProject/selinux-kernel/wiki/DEPRECATE-runtime-disable +*/ +return count; }static const struct file_operations sel_disable_ops = {
Signature · 1 line
2.54.0
Paul Moore
maintainerRe: [PATCH v2 2/3] selinux: prune /sys/fs/selinux/disable
Quoted 6 lines · On Apr 29, 2026 Stephen Smalley <[email protected]> wrote:
Commit
f22f9aaf6c3d("selinux: remove the runtime disable functionality") removed the SELinux runtime disable functionality but left everything except the actual runtime disable functionality intact and started logging an error message to warn any residual users.
Quoted 7 lines
Prune it to just return count (i.e. all bytes written successfully) to avoid breaking userspace. This also fixes a local DoS from logspam.
Signed-off-by Stephen Smalley <[email protected]>--- security/selinux/selinuxfs.c | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-)
Please do the same thing here that was suggested in patch 1/3.
--
paul-moore.com
Stephen Smalley
maintainerPATCH v2 3/3 selinux: prune /sys/fs/selinux/user
In reply to Stephen SmalleyFinish removal of the /sys/fs/selinux/user interface aside from a residual stub for userspace compatibility.
Commit d7b6918e22c7 ("selinux: Deprecate /sys/fs/selinux/user") started the deprecation process for /sys/fs/selinux/user:
The selinuxfs "user" node allows userspace to request a list of security contexts that can be reached for a given SELinux user from a given starting context. This was used by libselinux when various login-style programs requested contexts for users, but libselinux stopped using it in 2020. Kernel support will be removed no sooner than Dec 2025.
A pr_warn() message has been in place since Linux v6.13, and a 5 second sleep was introduced since Linux v6.17 to help make it more noticeable.
We are now past the stated deadline of Dec 2025, so remove the underlying functionality and replace it with a stub that returns a '0\0' buffer to avoid breaking userspace. This also avoids a local DoS from logspam.
---
.../{obsolete => removed}/sysfs-selinux-user | 0
security/selinux/include/security.h | 2 -
security/selinux/selinuxfs.c | 66 +--------
security/selinux/ss/services.c | 125 ------------------
4 files changed, 3 insertions(+), 190 deletions(-)
rename Documentation/ABI/{obsolete => removed}/sysfs-selinux-user (100%)Documentation/ABI/removed/sysfs-selinux-user renamed from Documentation/ABI/obsolete/sysfs-selinux-user +0 -0
security/selinux/include/security.h +0 -2
@@ -312,8 +312,6 @@ int security_context_to_sid_default(const char *scontext, u32 scontext_len,int security_context_to_sid_force (const char *scontext,u32 scontext_len,u32 *sid); -int security_get_user_sids (u32 fromsid,const char *username,u32 **sids,u32 *nel); -int security_port_sid (u8 protocol,u16 port,u32 *out_sid);int security_ib_pkey_sid (u64 subnet_prefix,u16 pkey_num,u32 *out_sid);
security/selinux/selinuxfs.c +3 -63
72 lines not on this page · raw message
security/selinux/ss/services.c +0 -125
131 lines not on this page · raw message
Signature · 1 line
2.54.0
Paul Moore
maintainerRe: [PATCH v2 3/3] selinux: prune /sys/fs/selinux/user
Quoted 23 lines · On Apr 29, 2026 Stephen Smalley <[email protected]> wrote:
Finish removal of the
/sys/fs/selinux/userinterface aside from a residual stub for userspace compatibility.Commit
d7b6918e22c7("selinux: Deprecate/sys/fs/selinux/user") started the deprecation process for/sys/fs/selinux/user:The selinuxfs "user" node allows userspace to request a list of security contexts that can be reached for a given SELinux user from a given starting context. This was used by libselinux when various login-style programs requested contexts for users, but libselinux stopped using it in 2020. Kernel support will be removed no sooner than Dec 2025.
A
pr_warn()message has been in place since Linux v6.13, and a 5 second sleep was introduced since Linux v6.17 to help make it more noticeable.We are now past the stated deadline of Dec 2025, so remove the underlying functionality and replace it with a stub that returns a '0\0' buffer to avoid breaking userspace. This also avoids a local DoS from logspam.
Quoted 8 lines
Signed-off-by Stephen Smalley <[email protected]>--- .../{obsolete => removed}/sysfs-selinux-user | 0 security/selinux/include/security.h | 2 - security/selinux/selinuxfs.c | 66 +-------- security/selinux/ss/services.c | 125 ------------------ 4 files changed, 3 insertions(+), 190 deletions(-) rename Documentation/ABI/{obsolete => removed}/sysfs-selinux-user (100%)
Again, please do the same thing here that was suggested in patch 1/3.
--
paul-moore.com
Paul Moore
maintainerQuoted 2 lines · Stephen Smalley
*** BLURB HERE ***
*** REPLY HERE ***
Quoted 14 lines
Stephen Smalley (3):
selinux: prune/sys/fs/selinux/checkreqprot
selinux: prune/sys/fs/selinux/disable
selinux: prune/sys/fs/selinux/user.../{obsolete => removed}/sysfs-selinux-user | 0 security/selinux/include/security.h | 2 - security/selinux/selinuxfs.c | 145 ++---------------- security/selinux/ss/services.c | 125 --------------- 4 files changed, 13 insertions(+), 259 deletions(-) rename Documentation/ABI/{obsolete => removed}/sysfs-selinux-user (100%)--
2.54.0
Signature · 1 line
paul-moore.com
Stephen Smalley
maintainerQuoted 7 lines · Paul Moore
Quoted 2 lines · Stephen Smalley
*** BLURB HERE ***
*** REPLY HERE ***
Sorry about that - thought it would pick up the same cover note that I used previously. Don't think it is worth re-posting just for the cover letter.
As before, this series prunes already deprecated selinuxfs interfaces but unlike the previous version leaves the selinuxfs nodes intact and just returns a non-error status of the appropriate form to avoid breaking userspace. Only one I'm not 100% sure about is /sys/fs/selinux/user;
I didn't have a system with an old enough libselinux to test its effect on e.g. pam_selinux and friends.
Quoted 18 lines
Quoted 13 lines
Stephen Smalley (3):
selinux: prune/sys/fs/selinux/checkreqprot
selinux: prune/sys/fs/selinux/disable
selinux: prune/sys/fs/selinux/user.../{obsolete => removed}/sysfs-selinux-user | 0 security/selinux/include/security.h | 2 - security/selinux/selinuxfs.c | 145 ++---------------- security/selinux/ss/services.c | 125 --------------- 4 files changed, 13 insertions(+), 259 deletions(-) rename Documentation/ABI/{obsolete => removed}/sysfs-selinux-user (100%)Quoted 2 lines
--
2.54.0--
paul-moore.com
Stephen Smalley
maintainerQuoted 10 lines · Stephen Smalley
Sorry about that - thought it would pick up the same cover note that I used previously. Don't think it is worth re-posting just for the cover letter.
As before, this series prunes already deprecated selinuxfs interfaces but unlike the previous version leaves the selinuxfs nodes intact and just returns a non-error status of the appropriate form to avoid breaking userspace. Only one I'm not 100% sure about is/sys/fs/selinux/user;
I didn't have a system with an old enough libselinux to test its effect on e.g.pam_selinuxand friends.
I've confirmed that even RHEL 8 has stopped using /sys/fs/selinux/user, so I don't believe there are any still-supported versions of RHEL
that were depending on it.