Commit dbc5be57 authored by David S. Miller's avatar David S. Miller

[PATCH] sys_swapoff bug

filp_open expects a kernel pointer not a user one.
parent cebce9d8
...@@ -961,13 +961,20 @@ asmlinkage long sys_swapoff(const char * specialfile) ...@@ -961,13 +961,20 @@ asmlinkage long sys_swapoff(const char * specialfile)
unsigned short *swap_map; unsigned short *swap_map;
struct file *swap_file, *victim; struct file *swap_file, *victim;
struct address_space *mapping; struct address_space *mapping;
char * pathname;
int i, type, prev; int i, type, prev;
int err; int err;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
victim = filp_open(specialfile, O_RDWR, 0); pathname = getname(specialfile);
err = PTR_ERR(pathname);
if (IS_ERR(pathname))
goto out;
victim = filp_open(pathname, O_RDWR, 0);
putname(pathname);
err = PTR_ERR(victim); err = PTR_ERR(victim);
if (IS_ERR(victim)) if (IS_ERR(victim))
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment