Skip to content

Commit ef9d965

Browse files
Christoph HellwigAl Viro
authored andcommitted
sysctl: reject gigantic reads/write to sysctl files
Instead of triggering a WARN_ON deep down in the page allocator just give up early on allocations that are way larger than the usual sysctl values. Fixes: 3292739 ("sysctl: pass kernel pointers to ->proc_handler") Reported-by: Vegard Nossum <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 8c46fa9 commit ef9d965

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/proc/proc_sysctl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,10 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf,
564564
if (!table->proc_handler)
565565
goto out;
566566

567+
/* don't even try if the size is too large */
568+
if (count > KMALLOC_MAX_SIZE)
569+
return -ENOMEM;
570+
567571
if (write) {
568572
kbuf = memdup_user_nul(ubuf, count);
569573
if (IS_ERR(kbuf)) {

0 commit comments

Comments
 (0)