[Bug 294780] fexecve(2) only works for scripts if /dev/fd is mounted with the non-default nodup option.

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 28 Apr 2026 19:22:09 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=294780

--- Comment #3 from Kyle Evans <kevans@freebsd.org> ---
(In reply to Jan Bramkamp from comment #2)

> to launch the script with fexecve() the descriptor needs to be executable.

The comment I quoted disagrees with you there, and my reading of the following
path agrees:

```
                error = fgetvp_exec(td, args->fd, &cap_fexecve_rights,          
                    &newtextvp);                                                
```

```
int                                                                             
fgetvp_exec(struct thread *td, int fd, const cap_rights_t *rightsp,             
    struct vnode **vpp)                                                         
{                                                                               

        return (_fgetvp(td, fd, FEXEC, rightsp, vpp));                          
}      
```

Follow that through to _fget:

```
...
        case FEXEC:                                                             
                if (fp->f_ops != &path_fileops &&                               
                    ((fp->f_flag & (FREAD | FEXEC)) == 0 ||                     
                    (fp->f_flag & FWRITE) != 0))                                
                        error = EBADF;                                          
...
```

O_RDONLY is sufficient for fexecve(2), the vnode will be re-checked for
executability after the above call.

-- 
You are receiving this mail because:
You are the assignee for the bug.