structlinux_binprm { #ifdef CONFIG_MMU structvm_area_struct *vma; unsignedlong vma_pages; unsignedlong argmin; /* rlimit marker for copy_strings() */ #else # define MAX_ARG_PAGES 32 structpage *page[MAX_ARG_PAGES]; #endif structmm_struct *mm; unsignedlong p; /* current top of mem */ unsignedint /* Should an execfd be passed to userspace? */ have_execfd:1,
/* Use the creds of a script (see binfmt_misc) */ execfd_creds:1, /* * Set by bprm_creds_for_exec hook to indicate a * privilege-gaining exec has happened. Used to set * AT_SECURE auxv for glibc. */ secureexec:1, /* * Set when errors can no longer be returned to the * original userspace. */ point_of_no_return:1; structfile *executable; /* Executable to pass to the interpreter */ structfile *interpreter; structfile *file; structcred *cred; /* new credentials */ int unsafe; /* how unsafe this exec is (mask of LSM_UNSAFE_*) */ unsignedint per_clear; /* bits to clear in current->personality */ int argc, envc; constchar *filename; /* Name of binary as seen by procps */ constchar *interp; /* Name of the binary really executed. Most of the time same as filename, but could be different for binfmt_{misc,script} */ constchar *fdpath; /* generated filename for execveat */ unsigned interp_flags; int execfd; /* File descriptor of the executable */ unsignedlong loader, exec;
structrlimit rlim_stack; /* Saved RLIMIT_STACK used during exec. */
staticintdo_execveat_common(int fd, struct filename *filename, struct user_arg_ptr argv, struct user_arg_ptr envp, int flags) { structlinux_binprm *bprm; int retval;
if (IS_ERR(filename)) return PTR_ERR(filename);
/* * We move the actual failure in case of RLIMIT_NPROC excess from * set*uid() to execve() because too many poorly written programs * don't check setuid() return code. Here we additionally recheck * whether NPROC limit is still exceeded. */ if ((current->flags & PF_NPROC_EXCEEDED) && is_rlimit_overlimit(current_ucounts(), UCOUNT_RLIMIT_NPROC, rlimit(RLIMIT_NPROC))) { retval = -EAGAIN; goto out_ret; }
/* We're below the limit (still or again), so we don't want to make * further execve() calls fail. */ current->flags &= ~PF_NPROC_EXCEEDED;
/* * When argv is empty, add an empty string ("") as argv[0] to * ensure confused userspace programs that start processing * from argv[1] won't end up walking envp. See also * bprm_stack_limits(). */ if (bprm->argc == 0) { retval = copy_string_kernel("", bprm); if (retval < 0) goto out_free; bprm->argc = 1; }
Reprint policy:
All articles in this blog are used except for special statements
CC BY 4.0
reprint policy. If reproduced, please indicate source
deepwzh
!