diff mbox series

[4/4] exec: move the call to getname_flags into do_execveat

Message ID 20210326143831.1550030-5-hch@lst.de
State New
Headers show
Series [1/4] exec: remove do_execve | expand

Commit Message

Christoph Hellwig March 26, 2021, 2:38 p.m. UTC
Remove the duplicated copying of the pathname into the common helper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/exec.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Arnd Bergmann March 26, 2021, 3:12 p.m. UTC | #1
On Fri, Mar 26, 2021 at 3:38 PM Christoph Hellwig <hch@lst.de> wrote:
>
> Remove the duplicated copying of the pathname into the common helper.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks correct, but

> -static int do_execveat(int fd, struct filename *filename,
> +static int do_execveat(int fd, const char __user *pathname,
>                 const char __user *const __user *argv,
>                 const char __user *const __user *envp, int flags)

Maybe rename this to ksys_execveat() for consistency now? I think that
is the current trend for functions that are essentially just the syscall.

With or without that change

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
diff mbox series

Patch

diff --git a/fs/exec.c b/fs/exec.c
index b34c1eb9e7ad8e..5c0dd8f85fe7b5 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1843,13 +1843,16 @@  static int bprm_execve(struct linux_binprm *bprm,
 	return retval;
 }
 
-static int do_execveat(int fd, struct filename *filename,
+static int do_execveat(int fd, const char __user *pathname,
 		const char __user *const __user *argv,
 		const char __user *const __user *envp, int flags)
 {
+	int lookup_flags = (flags & AT_EMPTY_PATH) ? LOOKUP_EMPTY : 0;
+	struct filename *filename;
 	struct linux_binprm *bprm;
 	int retval;
 
+	filename = getname_flags(pathname, lookup_flags, NULL);
 	if (IS_ERR(filename))
 		return PTR_ERR(filename);
 
@@ -1993,7 +1996,7 @@  SYSCALL_DEFINE3(execve,
 		const char __user *const __user *, argv,
 		const char __user *const __user *, envp)
 {
-	return do_execveat(AT_FDCWD, getname(filename), argv, envp, 0);
+	return do_execveat(AT_FDCWD, filename, argv, envp, 0);
 }
 
 SYSCALL_DEFINE5(execveat,
@@ -2002,9 +2005,5 @@  SYSCALL_DEFINE5(execveat,
 		const char __user *const __user *, envp,
 		int, flags)
 {
-	int lookup_flags = (flags & AT_EMPTY_PATH) ? LOOKUP_EMPTY : 0;
-
-	return do_execveat(fd,
-			   getname_flags(filename, lookup_flags, NULL),
-			   argv, envp, flags);
+	return do_execveat(fd, filename, argv, envp, flags);
 }