fexecve(2): Return ENOENT if exec a script opened with O_CLOEXEC
authorAaron LI <aly@aaronly.me>
Wed, 17 Feb 2021 13:47:03 +0000 (21:47 +0800)
committerAaron LI <aly@aaronly.me>
Sat, 20 Feb 2021 14:49:01 +0000 (22:49 +0800)
commit941642e84ed84b735224d17d3114379f1ed0920c
tree60ff8c19a0b781d1a013554244a7f9e77adaad2b
parent337acc4483de8c3f37e3efcda91cad4249ba6d61
fexecve(2): Return ENOENT if exec a script opened with O_CLOEXEC

If a script (i.e., interpreter file) is opened with the O_CLOEXEC flag,
it would be closed by the time the interpreter is executed, and then the
executation would fail.  So just return ENOENT from fexecve(2).  This
behavior aligns with Linux's.

See Linux's fexecve(2) man page.

See also: https://bugzilla.kernel.org/show_bug.cgi?id=74481

Thank dillon for implementing the holdvnode2() function to obtain the
fileflags together with the fp from fd.
lib/libc/sys/execve.2
sys/kern/kern_descrip.c
sys/kern/kern_exec.c
sys/sys/filedesc.h
sys/sys/kern_syscall.h