diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-12-24 00:16:30 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-01-04 10:28:00 -0500 |
commit | bb646cdb12e75d82258c2f2e7746d5952d3e321a (patch) | |
tree | 3ea70ea98962ca3f9344757cf1cde87b210a699e /fs/proc | |
parent | 70f6cbb6f9c95535acd327d1ac1ce5fd078cff1e (diff) |
proc_pid_attr_write(): switch to memdup_user()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/proc')
-rw-r--r-- | fs/proc/base.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 4bd5d3118acd..1b0f470a3e35 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -2359,7 +2359,7 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf, | |||
2359 | size_t count, loff_t *ppos) | 2359 | size_t count, loff_t *ppos) |
2360 | { | 2360 | { |
2361 | struct inode * inode = file_inode(file); | 2361 | struct inode * inode = file_inode(file); |
2362 | char *page; | 2362 | void *page; |
2363 | ssize_t length; | 2363 | ssize_t length; |
2364 | struct task_struct *task = get_proc_task(inode); | 2364 | struct task_struct *task = get_proc_task(inode); |
2365 | 2365 | ||
@@ -2374,14 +2374,11 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf, | |||
2374 | if (*ppos != 0) | 2374 | if (*ppos != 0) |
2375 | goto out; | 2375 | goto out; |
2376 | 2376 | ||
2377 | length = -ENOMEM; | 2377 | page = memdup_user(buf, count); |
2378 | page = (char*)__get_free_page(GFP_TEMPORARY); | 2378 | if (IS_ERR(page)) { |
2379 | if (!page) | 2379 | length = PTR_ERR(page); |
2380 | goto out; | 2380 | goto out; |
2381 | 2381 | } | |
2382 | length = -EFAULT; | ||
2383 | if (copy_from_user(page, buf, count)) | ||
2384 | goto out_free; | ||
2385 | 2382 | ||
2386 | /* Guard against adverse ptrace interaction */ | 2383 | /* Guard against adverse ptrace interaction */ |
2387 | length = mutex_lock_interruptible(&task->signal->cred_guard_mutex); | 2384 | length = mutex_lock_interruptible(&task->signal->cred_guard_mutex); |
@@ -2390,10 +2387,10 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf, | |||
2390 | 2387 | ||
2391 | length = security_setprocattr(task, | 2388 | length = security_setprocattr(task, |
2392 | (char*)file->f_path.dentry->d_name.name, | 2389 | (char*)file->f_path.dentry->d_name.name, |
2393 | (void*)page, count); | 2390 | page, count); |
2394 | mutex_unlock(&task->signal->cred_guard_mutex); | 2391 | mutex_unlock(&task->signal->cred_guard_mutex); |
2395 | out_free: | 2392 | out_free: |
2396 | free_page((unsigned long) page); | 2393 | kfree(page); |
2397 | out: | 2394 | out: |
2398 | put_task_struct(task); | 2395 | put_task_struct(task); |
2399 | out_no_task: | 2396 | out_no_task: |