selinux: prune deprecated interfaces
Stephen Smalley
maintainerv3 cover selinux: prune deprecated interfaces
This series prunes deprecated selinuxfs interfaces, reducing them to a pr_err_once() and to providing a trivial non-error return to avoid breaking userspace.
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 | 151 +++---------------
security/selinux/ss/services.c | 125 ---------------
4 files changed, 19 insertions(+), 259 deletions(-)
rename Documentation/ABI/{obsolete => removed}/sysfs-selinux-user (100%)Signature · 1 line
2.54.0
Stephen Smalley
maintainerPATCH v3 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 log an error message once and return count (i.e. all bytes written successfully) so that userspace never breaks.
---
v3 adds a pr_err_once() call as requested. Note that we do not need to copy current->comm when using it in pr_*() calls; this is only necessary when acting on another task (get_task_comm) or saving for later use.
security/selinux/selinuxfs.c | 47 ++++++------------------------------ 1 file changed, 7 insertions(+), 40 deletions(-)
security/selinux/selinuxfs.c +7 -40
@@ -687,46 +687,13 @@ 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 +*/ +pr_err_once ("SELinux: %s (%d) wrote to checkreqprot. This is no longer supported.\n" , + current->comm, current->pid); +return count; }static const struct file_operations sel_checkreqprot_ops = { .read = sel_read_checkreqprot,
Signature · 1 line
2.54.0
Re: [PATCH v3 1/3] selinux: prune /sys/fs/selinux/checkreqprot
Quoted 11 lines · On May 5, 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 log an error message once and return count (i.e. all bytes written successfully) so that userspace never breaks.Signed-off-by Stephen Smalley <[email protected]>
Quoted 8 lines
---
v3 adds apr_err_once()call as requested. Note that we do not need to copycurrent->commwhen using it in pr_*() calls; this is only necessary when acting on another task (get_task_comm) or saving for later use.security/selinux/selinuxfs.c | 47 ++++++------------------------------ 1 file changed, 7 insertions(+), 40 deletions(-)
Merged into selinux/stable-7.1, thanks.
--
paul-moore.com
Stephen Smalley
maintainerPATCH v3 2/3 selinux: prune /sys/fs/selinux/disable
In reply to Stephen SmalleyCommit f22f9aaf6c3d ("selinux: remove the runtime disable functionality") removed the underlying SELinux runtime disable functionality but left everything else intact and started logging an error message to warn any residual users.
Prune it to just log an error message once and to return count (i.e. all bytes written successfully) to avoid breaking userspace. This also fixes a local DoS from logspam.
---
v3 adds a pr_err_once() call as requested. Note that we do not need to copy current->comm when using it in pr_*() calls; this is only necessary when acting on another task (get_task_comm) or saving for later use.
security/selinux/selinuxfs.c | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-)
security/selinux/selinuxfs.c +7 -29
@@ -270,35 +270,13 @@ 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 + */ + pr_err_once("SELinux: %s (%d) wrote to disable. This is no longer supported.\n", + current->comm, current->pid); +return count; } static const struct file_operations sel_disable_ops = {
Signature · 1 line
2.54.0
Re: [PATCH v3 2/3] selinux: prune /sys/fs/selinux/disable
Quoted 11 lines · On May 5, 2026 Stephen Smalley <[email protected]> wrote:
Commit
f22f9aaf6c3d("selinux: remove the runtime disable functionality") removed the underlying SELinux runtime disable functionality but left everything else intact and started logging an error message to warn any residual users.Prune it to just log an error message once and to 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]>
Quoted 8 lines
---
v3 adds apr_err_once()call as requested. Note that we do not need to copycurrent->commwhen using it in pr_*() calls; this is only necessary when acting on another task (get_task_comm) or saving for later use.security/selinux/selinuxfs.c | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-)
Merged into selinux/stable-7.1, thanks.
--
paul-moore.com
Stephen Smalley
maintainerPATCH v3 3/3 selinux: prune /sys/fs/selinux/user
In reply to Stephen SmalleyRemove the previously deprecated /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 and an uninterruptible sleep delay.
---
v3 adds a pr_err_once() call as requested. Note that we do not need to copy current->comm when using it in pr_*() calls; this is only necessary when acting on another task (get_task_comm) or saving for later use.
.../{obsolete => removed}/sysfs-selinux-user | 0
security/selinux/include/security.h | 2 -
security/selinux/selinuxfs.c | 68 +---------
security/selinux/ss/services.c | 125 ------------------
4 files changed, 5 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 +5 -63
74 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
Re: [PATCH v3 3/3] selinux: prune /sys/fs/selinux/user
Quoted 30 lines · On May 5, 2026 Stephen Smalley <[email protected]> wrote:
Remove the previously deprecated
/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 and an uninterruptible sleep delay.
Signed-off-by Stephen Smalley <[email protected]>---
v3 adds apr_err_once()call as requested. Note that we do not need to copycurrent->commwhen using it in pr_*() calls; this is only necessary when acting on another task (get_task_comm) or saving for later use.
Quoted 6 lines
.../{obsolete => removed}/sysfs-selinux-user | 0
security/selinux/include/security.h | 2 -
security/selinux/selinuxfs.c | 68 +---------
security/selinux/ss/services.c | 125 ------------------
4 files changed, 5 insertions(+), 190 deletions(-)
rename Documentation/ABI/{obsolete => removed}/sysfs-selinux-user (100%)Merged into selinux/stable-7.1, thanks.
--
paul-moore.com