Skip to content

Commit 058a5e7

Browse files
stephensmalleygregkh
authored andcommitted
selinux: prune /sys/fs/selinux/disable
commit 19cfa00 upstream. Commit f22f9aa ("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. Cc: stable@vger.kernel.org Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com> Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 52a5d96 commit 058a5e7

1 file changed

Lines changed: 7 additions & 29 deletions

File tree

security/selinux/selinuxfs.c

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -272,35 +272,13 @@ static ssize_t sel_write_disable(struct file *file, const char __user *buf,
272272
size_t count, loff_t *ppos)
273273

274274
{
275-
char *page;
276-
ssize_t length;
277-
int new_value;
278-
279-
if (count >= PAGE_SIZE)
280-
return -ENOMEM;
281-
282-
/* No partial writes. */
283-
if (*ppos != 0)
284-
return -EINVAL;
285-
286-
page = memdup_user_nul(buf, count);
287-
if (IS_ERR(page))
288-
return PTR_ERR(page);
289-
290-
if (sscanf(page, "%d", &new_value) != 1) {
291-
length = -EINVAL;
292-
goto out;
293-
}
294-
length = count;
295-
296-
if (new_value) {
297-
pr_err("SELinux: https://github.com/SELinuxProject/selinux-kernel/wiki/DEPRECATE-runtime-disable\n");
298-
pr_err("SELinux: Runtime disable is not supported, use selinux=0 on the kernel cmdline.\n");
299-
}
300-
301-
out:
302-
kfree(page);
303-
return length;
275+
/*
276+
* Setting disable is no longer supported, see
277+
* https://github.com/SELinuxProject/selinux-kernel/wiki/DEPRECATE-runtime-disable
278+
*/
279+
pr_err_once("SELinux: %s (%d) wrote to disable. This is no longer supported.\n",
280+
current->comm, current->pid);
281+
return count;
304282
}
305283

306284
static const struct file_operations sel_disable_ops = {

0 commit comments

Comments
 (0)