vfs: define struct filename and have getname() return it
getname() is intended to copy pathname strings from userspace into a kernel buffer. The result is just a string in kernel space. It would however be quite helpful to be able to attach some ancillary info to the string. For instance, we could attach some audit-related info to reduce the amount of audit-related processing needed. When auditing is enabled, we could also call getname() on the string more than once and not need to recopy it from userspace. This patchset converts the getname()/putname() interfaces to return a struct instead of a string. For now, the struct just tracks the string in kernel space and the original userland pointer for it. Later, we'll add other information to the struct as it becomes convenient. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -298,14 +298,14 @@ asmlinkage int sys_execve(const char __user *ufilename,
|
||||
{
|
||||
struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
|
||||
int error;
|
||||
char *filename;
|
||||
struct filename *filename;
|
||||
|
||||
filename = getname(ufilename);
|
||||
error = PTR_ERR(filename);
|
||||
if (IS_ERR(filename))
|
||||
goto out;
|
||||
|
||||
error = do_execve(filename, uargv, uenvp, regs);
|
||||
error = do_execve(filename->name, uargv, uenvp, regs);
|
||||
putname(filename);
|
||||
out:
|
||||
return error;
|
||||
|
@@ -491,14 +491,14 @@ asmlinkage int sys_execve(const char *ufilename, char **uargv,
|
||||
struct pt_regs *pregs)
|
||||
{
|
||||
int error;
|
||||
char *filename;
|
||||
struct filename *filename;
|
||||
|
||||
filename = getname((char __user *)ufilename);
|
||||
error = PTR_ERR(filename);
|
||||
if (IS_ERR(filename))
|
||||
goto out;
|
||||
|
||||
error = do_execve(filename,
|
||||
error = do_execve(filename->name,
|
||||
(const char __user *const __user *)uargv,
|
||||
(const char __user *const __user *)uenvp,
|
||||
pregs);
|
||||
|
Reference in New Issue
Block a user