sysctl: Call sysctl_head_finish on error
Subsystems (2)
PATCH 1/1 sysctl: Call sysctl_head_finish on error
From: "Matthew Wilcox (Oracle)" <[email protected]>
This error path returned directly instead of calling sysctl_head_finish().
Fixes ef9d965bc8b6 ("sysctl: reject gigantic reads/write to sysctl files")
Signed-off-by Matthew Wilcox (Oracle) <[email protected]>
--- fs/proc/proc_sysctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/proc/proc_sysctl.c +2 -2
@@ -566,8 +566,9 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf, goto out;/* don't even try if the size is too large */ + error = -ENOMEM ;if (count >KMALLOC_MAX_SIZE ) -return -ENOMEM ; + goto out;if (write) { kbuf =memdup_user_nul (ubuf, count);
@@ -576,7 +577,6 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf, goto out; } }else { - error = -ENOMEM ; kbuf =kzalloc (count,GFP_KERNEL );if (!kbuf) goto out;
Signature · 1 line
2.27.0
Quoted 3 lines · Matthew Wilcox
From: "Matthew Wilcox (Oracle)" <[email protected]>
This error path returned directly instead of calling
sysctl_head_finish().
Looks good. But if you touch this anyway we also need to add the extra byte to count for the write case (see the memdup_user_nul implementation).