-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: syscall: add ExecFD options for Linux fexecve to SysProcAttr #72102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Related Issues
Related Code Changes
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
CC @neild It seems that it would make sense to consider this in conjunction with the new At bool // use execveat with DirFD and AtFlags
DirFD int // if At is true, dirfd argument to execveat
AtFlags int // if At is true, flags argument to execveat In order to use this we would have to add |
The |
@criyle I can't tell if you are pointing out a problem or not. The pathname is under program control, along with the fields in |
You are right, the user can pass empty string to syscall.ForkExec("", argv, &syscall.SysProcAttr{
At: true,
DirFD: fileFD,
AtFlags: syscall.AT_EMPTY_PATH
}) It indeed made the implementation more generic to other use cases. Sorry that I remembered the |
I don't understand the point about "fexecve requires mount of /proc system". The example in #66654 seems to be using If we're adding new API here, it seems like we should do it for all OSs that support the necessary syscalls. FreeBSD at least has fexecve.
I'm not sure how Cmd.Root and Cmd.Dir should interact, though. |
From the fexecve(3) man page, the POSIX's |
Rather than a // CommandRoot is like CommandContext, but the executable is relative to root.
func CommandRoot(ctx context.Context, root *os.Root, name string, arg ...string) *Cmd I think that may be a more natural way to describe what we want to execute. It would set the |
If we do add something, I think it should use fexecve on systems which have it but not execveat. That is: This shouldn't be a Linux-specific feature. (Even if we just add something to syscall, we should think about non-Linux systems.) My one concern about |
I think that if we take the Of course, we should think about some approach for setting |
Proposal Details
Linux 3.19 added a new system call,
execveat
, which provides the proper implementation for POSIX'sfexecve
.fexecve
requires mount of/proc
system and previous example shows the implementation offexecve
over the/proc
filesystem is not reliable given the reorganization of file descriptors before theexecve
call in the child process. #66654 #61751It would be great for some software written in Go to benefit from this new functionality, especially for containerized software which makes copies of their binary to avoid escaping attacks.
Proposed implementation as follows:
The text was updated successfully, but these errors were encountered: