git: fexecve(2): Return ENOENT if exec a script opened with O_CLOEXEC

Aaron LI aly at crater.dragonflybsd.org
Sat Feb 20 06:49:38 PST 2021


commit 941642e84ed84b735224d17d3114379f1ed0920c
Author: Aaron LI <aly at aaronly.me>
Date:   Wed Feb 17 21:47:03 2021 +0800

    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.

Summary of changes:
 lib/libc/sys/execve.2   | 12 ++++++++++
 sys/kern/kern_descrip.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++
 sys/kern/kern_exec.c    | 18 ++++++++++----
 sys/sys/filedesc.h      |  2 ++
 sys/sys/kern_syscall.h  |  2 +-
 5 files changed, 91 insertions(+), 5 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/941642e84ed84b735224d17d3114379f1ed0920c


-- 
DragonFly BSD source repository


More information about the Commits mailing list