lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Sat, 23 Apr 2022 02:31:04 +0000 From: Junwen Wu <wudaemon@....com> To: akpm@...ux-foundation.org, keescook@...omium.org, adobriyan@...il.com, fweimer@...hat.com, ddiss@...e.de Cc: linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org, Junwen Wu <wudaemon@....com> Subject: [PATCH v1] proc: limit schedstate node write operation Whatever value is written to /proc/$pid/sched, a task's schedstate data will reset.In some cases, schedstate will drop by accident. We restrict writing a certain value to this node before the data is reset. Signed-off-by: Junwen Wu <wudaemon@....com> --- fs/proc/base.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index d654ce7150fd..6bb2677659ce 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1459,13 +1459,21 @@ sched_write(struct file *file, const char __user *buf, { struct inode *inode = file_inode(file); struct task_struct *p; + char ubuf[5]; - p = get_proc_task(inode); - if (!p) - return -ESRCH; - proc_sched_set_task(p); + memset(ubuf, 0, sizeof(ubuf)); + if (count > 5) + count = 0; + if (copy_from_user(ubuf, buf, count)) + return -EFAULT; + if (strcmp(ubuf, "reset") == 0) { + p = get_proc_task(inode); + if (!p) + return -ESRCH; + proc_sched_set_task(p); - put_task_struct(p); + put_task_struct(p); + } return count; } -- 2.25.1
Powered by blists - more mailing lists