fs/exec.c
Source file repositories/reference/linux-study-clean/fs/exec.c
File Facts
- System
- Linux kernel
- Corpus path
fs/exec.c- Extension
.c- Size
- 51011 bytes
- Lines
- 2030
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: syscall or user/kernel boundary
- Status
- core implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or participates in a user/kernel boundary; inspect argument validation, copy_from_user/copy_to_user, credentials, and dispatch target.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel_read_file.hlinux/slab.hlinux/file.hlinux/fdtable.hlinux/mm.hlinux/stat.hlinux/fcntl.hlinux/swap.hlinux/string.hlinux/init.hlinux/sched/mm.hlinux/sched/coredump.hlinux/sched/exec_state.hlinux/sched/signal.hlinux/sched/numa_balancing.hlinux/sched/task.hlinux/pagemap.hlinux/perf_event.hlinux/highmem.hlinux/spinlock.hlinux/key.hlinux/personality.hlinux/binfmts.hlinux/utsname.hlinux/pid_namespace.hlinux/module.hlinux/namei.hlinux/mount.hlinux/security.hlinux/syscalls.hlinux/tsacct_kern.hlinux/cn_proc.h
Detected Declarations
syscall execvesyscall execveatstruct user_arg_ptrfunction __register_binfmtfunction unregister_binfmtfunction put_binfmtfunction path_noexecfunction oom_badnessfunction put_arg_pagefunction free_arg_pagesfunction valid_arg_lenfunction acct_arg_sizefunction put_arg_pagefunction free_arg_pagesfunction flush_arg_pagefunction setup_arg_pagesfunction countfunction count_strings_kernelfunction bprm_set_stack_limitfunction bprm_hit_stack_limitfunction bprm_stack_limitsfunction copy_stringsfunction copy_string_kernelfunction copy_strings_kernelfunction setup_arg_pagesfunction transfer_args_to_stackfunction do_open_execatfunction read_codefunction exec_mmapfunction exec_mm_put_oldfunction de_threadfunction clonefunction __set_task_commfunction signalfunction would_dumpfunction setup_new_execfunction finalize_execfunction setup_new_execfunction do_close_execatfunction free_bprmfunction bprm_change_interpfunction check_unsafe_execfunction bprm_fill_uidfunction bprm_creds_from_filefunction chainsfunction remove_arg_zerofunction search_binary_handlerfunction exec_binprm
Annotated Snippet
SYSCALL_DEFINE3(execve,
const char __user *, filename,
const char __user *const __user *, argv,
const char __user *const __user *, envp)
{
CLASS(filename, name)(filename);
return do_execveat_common(AT_FDCWD, name,
native_arg(argv), native_arg(envp), 0);
}
SYSCALL_DEFINE5(execveat,
int, fd, const char __user *, filename,
const char __user *const __user *, argv,
const char __user *const __user *, envp,
int, flags)
{
CLASS(filename_uflags, name)(filename, flags);
return do_execveat_common(fd, name,
native_arg(argv), native_arg(envp), flags);
}
#ifdef CONFIG_COMPAT
static inline struct user_arg_ptr compat_arg(const compat_uptr_t __user *p)
{
return (struct user_arg_ptr){.is_compat = true, .ptr.compat = p};
}
COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename,
const compat_uptr_t __user *, argv,
const compat_uptr_t __user *, envp)
{
CLASS(filename, name)(filename);
return do_execveat_common(AT_FDCWD, name,
compat_arg(argv), compat_arg(envp), 0);
}
COMPAT_SYSCALL_DEFINE5(execveat, int, fd,
const char __user *, filename,
const compat_uptr_t __user *, argv,
const compat_uptr_t __user *, envp,
int, flags)
{
CLASS(filename_uflags, name)(filename, flags);
return do_execveat_common(fd, name,
compat_arg(argv), compat_arg(envp), flags);
}
#endif
#ifdef CONFIG_SYSCTL
static int proc_dointvec_minmax_coredump(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
int error, old = READ_ONCE(suid_dumpable);
error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
if (!error && write && (old != READ_ONCE(suid_dumpable)))
validate_coredump_safety();
return error;
}
static const struct ctl_table fs_exec_sysctls[] = {
{
.procname = "suid_dumpable",
.data = &suid_dumpable,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax_coredump,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_TWO,
},
};
static int __init init_fs_exec_sysctls(void)
{
register_sysctl_init("fs", fs_exec_sysctls);
return 0;
}
fs_initcall(init_fs_exec_sysctls);
#endif /* CONFIG_SYSCTL */
#ifdef CONFIG_EXEC_KUNIT_TEST
#include "tests/exec_kunit.c"
#endif
Annotation
- Immediate include surface: `linux/kernel_read_file.h`, `linux/slab.h`, `linux/file.h`, `linux/fdtable.h`, `linux/mm.h`, `linux/stat.h`, `linux/fcntl.h`, `linux/swap.h`.
- Detected declarations: `syscall execve`, `syscall execveat`, `struct user_arg_ptr`, `function __register_binfmt`, `function unregister_binfmt`, `function put_binfmt`, `function path_noexec`, `function oom_badness`, `function put_arg_page`, `function free_arg_pages`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: core implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.