tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH] fexecve

Emmanuel Dreyfus <> wrote:

> > The spec only requires that the file only needs to be open for reading.
> That is not completely clear to me. open(2) and openat(2) get a O_EXEC
> flag, but I did not found other reference of it: fexecve(2)
> specification does explicitely require a fd open with O_EXEC. 

Wait, it actually says something:

--- cut here---
Since execute permission is checked by fexecve(), the file description
fd need not have been opened with the O_EXEC flag. However, if the file
to be executed denies read and write permission for the process
preparing to do the exec, the only way to provide the fd to fexecve()
will be to use the O_EXEC flag when opening fd. In this case, the
application will not be able to perform a checksum test since it will
not be able to read the contents of the file.

Note that when a file descriptor is opened with O_RDONLY, O_RDWR, or
O_WRONLY mode, the file descriptor can be used to read, read and write,
or write the file, respectively, even if the mode of the file changes
after the file was opened. Using the O_EXEC open mode is different;
fexecve() will ignore the mode that was used when the file descriptor
was opened and the exec will fail if the mode of the file associated
with fd does not grant execute permission to the calling process at the
time fexecve() is called.
--- cut here---

Emmanuel Dreyfus

Home | Main Index | Thread Index | Old Index