Implement the fexecve(2) system call

Operating Systems / DragonFlyBSD - Aaron LI [aaronly.me] - 20 February 2021 14:49 UTC

The fexecve(2) function is equivalent to execve(2), except that the file to be executed is determined by the file descriptor fd instead of a pathname.

The purpose of fexecve(2) is to enable executing a file which has been
verified to be the intended file. It is possible to actively check the file by reading from the file descriptor and be sure that the file is not exchanged for another between the reading and the execution.

See https://pubs.opengroup.org/onlinepubs/9699919799/functions/fexecve.html

This work is partially based on swildner's patch and FreeBSD's implementation (revisions 177787, 182191, 238220).

XXX: We're missing O_EXEC support in open(2).

337acc4483 Implement the fexecve(2) system call
include/unistd.h | 2 -
lib/libc/sys/Makefile.inc | 1 +
lib/libc/sys/Symbol.map | 3 ++
lib/libc/sys/execve.2 | 71 ++++++++++++++++++++++++++---
lib/libc/sys/open.2 | 4 +-
sys/kern/init_sysent.c | 1 +
sys/kern/kern_exec.c | 114 ++++++++++++++++++++++++++++++++++++++--------
sys/kern/syscalls.c | 1 +
sys/kern/syscalls.master | 1 +
sys/sys/kern_syscall.h | 3 +-
sys/sys/param.h | 3 +-
sys/sys/syscall.h | 3 +-
sys/sys/syscall.mk | 3 +-
sys/sys/sysproto.h | 6 +++
sys/sys/sysunion.h | 1 +
15 files changed, 182 insertions(+), 35 deletions(-)

Upstream: gitweb.dragonflybsd.org


  • Share