All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: Laurent Vivier <laurent@vivier.eu>, qemu-devel@nongnu.org
Subject: Re: [PATCH v2 0/2] linux-user: handle /proc/self/exe with execve() syscall
Date: Thu, 27 Oct 2022 15:09:18 +0300	[thread overview]
Message-ID: <f62172f4-e8d1-fc02-cab3-939fb05fae6c@msgid.tls.msk.ru> (raw)
In-Reply-To: <ff22a2ac-d058-2448-0e76-03223f7f46dc@tls.msk.ru>

27.10.2022 13:42, Michael Tokarev wrote:
> 27.10.2022 09:40, Laurent Vivier wrote:
> ..
>> I tried O_CLOEXEC, but it seems the fd is closed before it is needed by execveat() to re-spawn the process, so it exits with an error (something 
>> like EBADF)
> 
> It works here for me with a simple test program:
> 
> #include <sys/types.h>
> #include <fcntl.h>
> #include <unistd.h>
> #include <sys/syscall.h>
> #define AT_EMPTY_PATH        0x1000
> 
> static char *argv[] = { "ls", NULL };
> static char *envp[] = { NULL };
> 
> int main(void) {
>    int fd = open("/usr/bin/ls", O_RDONLY);
>    fcntl(fd, F_SETFD, O_CLOEXEC);
>    //execveat(fd, "", argv, envp, AT_EMPTY_PATH);
>    syscall(__NR_execveat, fd, "", argv, envp, AT_EMPTY_PATH);
>    return 0;
> }

But for some reason it does not close this fd# on exec.

  static char *argv[] = { "ls", "-l", "/proc/self/fd", NULL };

shows this.

Hmm. Ok. Let's keep it the way you did :)

/mjt


      parent reply	other threads:[~2022-10-27 12:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27 12:43 [PATCH v2 0/2] linux-user: handle /proc/self/exe with execve() syscall Laurent Vivier
2022-09-27 12:43 ` [PATCH v2 1/2] " Laurent Vivier
2022-10-21 15:10   ` Laurent Vivier
2022-09-27 12:43 ` [PATCH v2 2/2] linux-user: don't use AT_EXECFD in do_openat() Laurent Vivier
2022-10-21 15:10   ` Laurent Vivier
2022-10-26 15:25 ` [PATCH v2 0/2] linux-user: handle /proc/self/exe with execve() syscall Michael Tokarev
2022-10-27  6:40   ` Laurent Vivier
2022-10-27 10:42     ` Michael Tokarev
     [not found]     ` <ff22a2ac-d058-2448-0e76-03223f7f46dc@tls.msk.ru>
2022-10-27 12:09       ` Michael Tokarev [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f62172f4-e8d1-fc02-cab3-939fb05fae6c@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.