Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

execve: fold {compat_,}do_execve{,at}() into their sole callers

All of them are wrappers for do_execveat_common() and each has
exactly one caller. The only difference is in the way they are
constructing argv/envp arguments for do_execveat_common() and
that's easy to do with less boilerplate.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 88b33614 bb850584

+19 -61
+19 -61
fs/exec.c
··· 1907 1907 return retval; 1908 1908 } 1909 1909 1910 - static int do_execve(struct filename *filename, 1911 - const char __user *const __user *__argv, 1912 - const char __user *const __user *__envp) 1913 - { 1914 - struct user_arg_ptr argv = { .ptr.native = __argv }; 1915 - struct user_arg_ptr envp = { .ptr.native = __envp }; 1916 - return do_execveat_common(AT_FDCWD, filename, argv, envp, 0); 1917 - } 1918 - 1919 - static int do_execveat(int fd, struct filename *filename, 1920 - const char __user *const __user *__argv, 1921 - const char __user *const __user *__envp, 1922 - int flags) 1923 - { 1924 - struct user_arg_ptr argv = { .ptr.native = __argv }; 1925 - struct user_arg_ptr envp = { .ptr.native = __envp }; 1926 - 1927 - return do_execveat_common(fd, filename, argv, envp, flags); 1928 - } 1929 - 1930 - #ifdef CONFIG_COMPAT 1931 - static int compat_do_execve(struct filename *filename, 1932 - const compat_uptr_t __user *__argv, 1933 - const compat_uptr_t __user *__envp) 1934 - { 1935 - struct user_arg_ptr argv = { 1936 - .is_compat = true, 1937 - .ptr.compat = __argv, 1938 - }; 1939 - struct user_arg_ptr envp = { 1940 - .is_compat = true, 1941 - .ptr.compat = __envp, 1942 - }; 1943 - return do_execveat_common(AT_FDCWD, filename, argv, envp, 0); 1944 - } 1945 - 1946 - static int compat_do_execveat(int fd, struct filename *filename, 1947 - const compat_uptr_t __user *__argv, 1948 - const compat_uptr_t __user *__envp, 1949 - int flags) 1950 - { 1951 - struct user_arg_ptr argv = { 1952 - .is_compat = true, 1953 - .ptr.compat = __argv, 1954 - }; 1955 - struct user_arg_ptr envp = { 1956 - .is_compat = true, 1957 - .ptr.compat = __envp, 1958 - }; 1959 - return do_execveat_common(fd, filename, argv, envp, flags); 1960 - } 1961 - #endif 1962 - 1963 1910 void set_binfmt(struct linux_binfmt *new) 1964 1911 { 1965 1912 struct mm_struct *mm = current->mm; ··· 1931 1984 __mm_flags_set_mask_dumpable(mm, value); 1932 1985 } 1933 1986 1987 + static inline struct user_arg_ptr native_arg(const char __user *const __user *p) 1988 + { 1989 + return (struct user_arg_ptr){.ptr.native = p}; 1990 + } 1991 + 1934 1992 SYSCALL_DEFINE3(execve, 1935 1993 const char __user *, filename, 1936 1994 const char __user *const __user *, argv, 1937 1995 const char __user *const __user *, envp) 1938 1996 { 1939 - return do_execve(getname(filename), argv, envp); 1997 + return do_execveat_common(AT_FDCWD, getname(filename), 1998 + native_arg(argv), native_arg(envp), 0); 1940 1999 } 1941 2000 1942 2001 SYSCALL_DEFINE5(execveat, ··· 1951 1998 const char __user *const __user *, envp, 1952 1999 int, flags) 1953 2000 { 1954 - return do_execveat(fd, 1955 - getname_uflags(filename, flags), 1956 - argv, envp, flags); 2001 + return do_execveat_common(fd, getname_uflags(filename, flags), 2002 + native_arg(argv), native_arg(envp), flags); 1957 2003 } 1958 2004 1959 2005 #ifdef CONFIG_COMPAT 2006 + 2007 + static inline struct user_arg_ptr compat_arg(const compat_uptr_t __user *p) 2008 + { 2009 + return (struct user_arg_ptr){.is_compat = true, .ptr.compat = p}; 2010 + } 2011 + 1960 2012 COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename, 1961 2013 const compat_uptr_t __user *, argv, 1962 2014 const compat_uptr_t __user *, envp) 1963 2015 { 1964 - return compat_do_execve(getname(filename), argv, envp); 2016 + return do_execveat_common(AT_FDCWD, getname(filename), 2017 + compat_arg(argv), compat_arg(envp), 0); 1965 2018 } 1966 2019 1967 2020 COMPAT_SYSCALL_DEFINE5(execveat, int, fd, ··· 1976 2017 const compat_uptr_t __user *, envp, 1977 2018 int, flags) 1978 2019 { 1979 - return compat_do_execveat(fd, 1980 - getname_uflags(filename, flags), 1981 - argv, envp, flags); 2020 + return do_execveat_common(fd, getname_uflags(filename, flags), 2021 + compat_arg(argv), compat_arg(envp), flags); 1982 2022 } 1983 2023 #endif 1984 2024