git: 15581af7c2d3 - main - exec: Remove parameter 'segflg' from exec_copyin_args()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 21 Apr 2025 23:07:08 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=15581af7c2d30360313dcad74dc5dc83c02f9df0 commit 15581af7c2d30360313dcad74dc5dc83c02f9df0 Author: Wuyang Chung <wy-chung@outlook.com> AuthorDate: 2025-02-05 06:54:54 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2025-04-21 23:06:35 +0000 exec: Remove parameter 'segflg' from exec_copyin_args() In kern "copyin" means copy data from user address space to kernel address space. But in the function exec_copyin_args() there is a parameter 'segflg' that is used to specify the address space of the parameter 'fname'. In the source code there are two places where 'segflg' are not UIO_USERSPACE. In both cases the 'fname' argument are NULL so the argument 'segflg' are not important there. So it is safe to remove the parameter 'segflg' from the function exec_copyin_args(). Reviewed by: markj, jhb MFC after: 2 weeks Pull Request: https://github.com/freebsd/freebsd-src/pull/1590 --- sys/compat/freebsd32/freebsd32_misc.c | 11 +++++------ sys/compat/freebsd32/freebsd32_util.h | 2 +- sys/compat/linux/linux_misc.c | 8 ++++---- sys/kern/kern_exec.c | 13 +++++-------- sys/sys/imgact.h | 3 +-- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index 3efc93969419..cc777f2bf830 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -401,7 +401,7 @@ freebsd32_sigaltstack(struct thread *td, */ int freebsd32_exec_copyin_args(struct image_args *args, const char *fname, - enum uio_seg segflg, uint32_t *argv, uint32_t *envv) + uint32_t *argv, uint32_t *envv) { char *argp, *envp; uint32_t *p32, arg; @@ -422,7 +422,7 @@ freebsd32_exec_copyin_args(struct image_args *args, const char *fname, /* * Copy the file name. */ - error = exec_args_add_fname(args, fname, segflg); + error = exec_args_add_fname(args, fname, UIO_USERSPACE); if (error != 0) goto err_exit; @@ -477,8 +477,8 @@ freebsd32_execve(struct thread *td, struct freebsd32_execve_args *uap) error = pre_execve(td, &oldvmspace); if (error != 0) return (error); - error = freebsd32_exec_copyin_args(&eargs, uap->fname, UIO_USERSPACE, - uap->argv, uap->envv); + error = freebsd32_exec_copyin_args(&eargs, uap->fname, uap->argv, + uap->envv); if (error == 0) error = kern_execve(td, &eargs, NULL, oldvmspace); post_execve(td, error, oldvmspace); @@ -496,8 +496,7 @@ freebsd32_fexecve(struct thread *td, struct freebsd32_fexecve_args *uap) error = pre_execve(td, &oldvmspace); if (error != 0) return (error); - error = freebsd32_exec_copyin_args(&eargs, NULL, UIO_SYSSPACE, - uap->argv, uap->envv); + error = freebsd32_exec_copyin_args(&eargs, NULL, uap->argv, uap->envv); if (error == 0) { eargs.fd = uap->fd; error = kern_execve(td, &eargs, NULL, oldvmspace); diff --git a/sys/compat/freebsd32/freebsd32_util.h b/sys/compat/freebsd32/freebsd32_util.h index 4ac314f4391e..1ae016814329 100644 --- a/sys/compat/freebsd32/freebsd32_util.h +++ b/sys/compat/freebsd32/freebsd32_util.h @@ -120,7 +120,7 @@ void freebsd32_rusage_out(const struct rusage *s, struct rusage32 *s32); struct image_args; int freebsd32_exec_copyin_args(struct image_args *args, const char *fname, - enum uio_seg segflg, uint32_t *argv, uint32_t *envv); + uint32_t *argv, uint32_t *envv); struct kinfo_knote; struct kinfo_knote32; diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index e789586160b6..b88f1451f1a2 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -2612,7 +2612,7 @@ linux_seccomp(struct thread *td, struct linux_seccomp_args *args) */ static int linux_exec_copyin_args(struct image_args *args, const char *fname, - enum uio_seg segflg, l_uintptr_t *argv, l_uintptr_t *envv) + l_uintptr_t *argv, l_uintptr_t *envv) { char *argp, *envp; l_uintptr_t *ptr, arg; @@ -2633,7 +2633,7 @@ linux_exec_copyin_args(struct image_args *args, const char *fname, /* * Copy the file name. */ - error = exec_args_add_fname(args, fname, segflg); + error = exec_args_add_fname(args, fname, UIO_USERSPACE); if (error != 0) goto err_exit; @@ -2696,8 +2696,8 @@ linux_execve(struct thread *td, struct linux_execve_args *args) LINUX_CTR(execve); - error = linux_exec_copyin_args(&eargs, args->path, UIO_USERSPACE, - args->argp, args->envp); + error = linux_exec_copyin_args(&eargs, args->path, args->argp, + args->envp); if (error == 0) error = linux_common_execve(td, &eargs); AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index f6d0201f9b37..a943ec339e75 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -225,8 +225,7 @@ sys_execve(struct thread *td, struct execve_args *uap) error = pre_execve(td, &oldvmspace); if (error != 0) return (error); - error = exec_copyin_args(&args, uap->fname, UIO_USERSPACE, - uap->argv, uap->envv); + error = exec_copyin_args(&args, uap->fname, uap->argv, uap->envv); if (error == 0) error = kern_execve(td, &args, NULL, oldvmspace); post_execve(td, error, oldvmspace); @@ -251,8 +250,7 @@ sys_fexecve(struct thread *td, struct fexecve_args *uap) error = pre_execve(td, &oldvmspace); if (error != 0) return (error); - error = exec_copyin_args(&args, NULL, UIO_SYSSPACE, - uap->argv, uap->envv); + error = exec_copyin_args(&args, NULL, uap->argv, uap->envv); if (error == 0) { args.fd = uap->fd; error = kern_execve(td, &args, NULL, oldvmspace); @@ -282,8 +280,7 @@ sys___mac_execve(struct thread *td, struct __mac_execve_args *uap) error = pre_execve(td, &oldvmspace); if (error != 0) return (error); - error = exec_copyin_args(&args, uap->fname, UIO_USERSPACE, - uap->argv, uap->envv); + error = exec_copyin_args(&args, uap->fname, uap->argv, uap->envv); if (error == 0) error = kern_execve(td, &args, uap->mac_p, oldvmspace); post_execve(td, error, oldvmspace); @@ -1328,7 +1325,7 @@ out: */ int exec_copyin_args(struct image_args *args, const char *fname, - enum uio_seg segflg, char **argv, char **envv) + char **argv, char **envv) { u_long arg, env; int error; @@ -1348,7 +1345,7 @@ exec_copyin_args(struct image_args *args, const char *fname, /* * Copy the file name. */ - error = exec_args_add_fname(args, fname, segflg); + error = exec_args_add_fname(args, fname, UIO_USERSPACE); if (error != 0) goto err_exit; diff --git a/sys/sys/imgact.h b/sys/sys/imgact.h index 4f0c8aff9f42..c1c94a2eabfd 100644 --- a/sys/sys/imgact.h +++ b/sys/sys/imgact.h @@ -119,8 +119,7 @@ int exec_map_stack(struct image_params *); int exec_new_vmspace(struct image_params *, struct sysentvec *); void exec_setregs(struct thread *, struct image_params *, uintptr_t); int exec_shell_imgact(struct image_params *); -int exec_copyin_args(struct image_args *, const char *, enum uio_seg, - char **, char **); +int exec_copyin_args(struct image_args *, const char *, char **, char **); int pre_execve(struct thread *td, struct vmspace **oldvmspace); void post_execve(struct thread *td, int error, struct vmspace *oldvmspace); #endif