diff options
author | Jeff Layton <jlayton@redhat.com> | 2012-10-10 15:25:28 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-12 20:14:55 -0400 |
commit | 91a27b2a756784714e924e5e854b919273082d26 (patch) | |
tree | 3913246b7d6e62703ec915f481e3a7159393f0f0 /fs/exec.c | |
parent | 8e377d15078a501c4da98471f56396343c407d92 (diff) |
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>
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -105,7 +105,7 @@ static inline void put_binfmt(struct linux_binfmt * fmt) | |||
105 | SYSCALL_DEFINE1(uselib, const char __user *, library) | 105 | SYSCALL_DEFINE1(uselib, const char __user *, library) |
106 | { | 106 | { |
107 | struct file *file; | 107 | struct file *file; |
108 | char *tmp = getname(library); | 108 | struct filename *tmp = getname(library); |
109 | int error = PTR_ERR(tmp); | 109 | int error = PTR_ERR(tmp); |
110 | static const struct open_flags uselib_flags = { | 110 | static const struct open_flags uselib_flags = { |
111 | .open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC, | 111 | .open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC, |
@@ -116,7 +116,7 @@ SYSCALL_DEFINE1(uselib, const char __user *, library) | |||
116 | if (IS_ERR(tmp)) | 116 | if (IS_ERR(tmp)) |
117 | goto out; | 117 | goto out; |
118 | 118 | ||
119 | file = do_filp_open(AT_FDCWD, tmp, &uselib_flags, LOOKUP_FOLLOW); | 119 | file = do_filp_open(AT_FDCWD, tmp->name, &uselib_flags, LOOKUP_FOLLOW); |
120 | putname(tmp); | 120 | putname(tmp); |
121 | error = PTR_ERR(file); | 121 | error = PTR_ERR(file); |
122 | if (IS_ERR(file)) | 122 | if (IS_ERR(file)) |
@@ -1664,10 +1664,10 @@ SYSCALL_DEFINE3(execve, | |||
1664 | const char __user *const __user *, argv, | 1664 | const char __user *const __user *, argv, |
1665 | const char __user *const __user *, envp) | 1665 | const char __user *const __user *, envp) |
1666 | { | 1666 | { |
1667 | const char *path = getname(filename); | 1667 | struct filename *path = getname(filename); |
1668 | int error = PTR_ERR(path); | 1668 | int error = PTR_ERR(path); |
1669 | if (!IS_ERR(path)) { | 1669 | if (!IS_ERR(path)) { |
1670 | error = do_execve(path, argv, envp, current_pt_regs()); | 1670 | error = do_execve(path->name, argv, envp, current_pt_regs()); |
1671 | putname(path); | 1671 | putname(path); |
1672 | } | 1672 | } |
1673 | return error; | 1673 | return error; |
@@ -1677,10 +1677,11 @@ asmlinkage long compat_sys_execve(const char __user * filename, | |||
1677 | const compat_uptr_t __user * argv, | 1677 | const compat_uptr_t __user * argv, |
1678 | const compat_uptr_t __user * envp) | 1678 | const compat_uptr_t __user * envp) |
1679 | { | 1679 | { |
1680 | const char *path = getname(filename); | 1680 | struct filename *path = getname(filename); |
1681 | int error = PTR_ERR(path); | 1681 | int error = PTR_ERR(path); |
1682 | if (!IS_ERR(path)) { | 1682 | if (!IS_ERR(path)) { |
1683 | error = compat_do_execve(path, argv, envp, current_pt_regs()); | 1683 | error = compat_do_execve(path->name, argv, envp, |
1684 | current_pt_regs()); | ||
1684 | putname(path); | 1685 | putname(path); |
1685 | } | 1686 | } |
1686 | return error; | 1687 | return error; |