unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
To: libc-alpha@sourceware.org, "Alexandra Hájková" <ahajkova@redhat.com>
Subject: Re: [PATCH] Linux: Add execveat system call wrapper
Date: Mon, 3 May 2021 16:20:54 -0300	[thread overview]
Message-ID: <8fedbeac-5ff8-67bf-201f-3d59b106fbab@linaro.org> (raw)
In-Reply-To: <20210421181159.3579223-1-ahajkova@redhat.com>



On 21/04/2021 15:11, Alexandra Hájková via Libc-alpha wrote:
> From: Alexandra Hájková <ahajkova@redhat.com>
> 
>  Also add the test for the new wrapper.

Patch looks ok in general, but there are minor issues. Since it is being
back and forth for some time, I took the liberty to fix them and I will
push it upstream.

> 
> diff --git a/NEWS b/NEWS
> index aa0f10a891..0765db4543 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -18,6 +18,11 @@ Major new features:
>    a dump of information related to IFUNC resolver operation and
>    glibc-hwcaps subdirectory selection.
>  
> +* The function execveat has been added and it operates similar to execve.
> +  The syscall is already used to implement fexecve without requiring /proc to
> +  be mounted.  Similar to fexecve, if the syscall is not supported ENOSYS is
> +  returned.
> +

With the fallback removal, execveat does not act similar to fexecve.  I changed
the NEWS entry to:

  * On Linux, the function execveat has been added.  It operates similar to
    execve and it is is already used to implement fexecve without requiring
    /proc to be mounted.  However, different than fexecve, if the syscall is not
    supported by the kernel an error is returned instead of trying a fallback.


> +int
> +call_execveat (int fd, const char *pathname, int flags, int expected_fail,
> +               int num)
> +{
> +  char *envp[] = { (char *) "FOO=3", NULL };
> +  char *argv[] = { (char *) "sh", (char *) "-c", (char *) "exit $FOO", NULL };
> +  pid_t pid;
> +  int status;
> +
> +  if (test_verbose > 0)
> +    printf ("call line number: %d\n", num);
> +
> +  pid = xfork ();
> +  if (pid == 0)
> +    {
> +      TEST_COMPARE (execveat (fd, pathname, argv, envp, flags), -1);
> +      if (errno == ENOSYS)
> +        FAIL_UNSUPPORTED ("execveat is unimplemented");

This will print 'execveat is unimplemented', since the WEXITSTATUS below
will already handle it.  Instead I replace it with:

  exit (EXIT_UNSUPPORTED); 


> +int
> +execveat (int dirfd, const char *path, char *const argv[], char *const envp[],
> +          int flags)
> +{
> +  /* Avoid implicit array coercion in syscall macros.  */
> +  INLINE_SYSCALL_CALL (execveat, dirfd, path, &argv[0], &envp[0], flags);
> +#ifndef __ASSUME_EXECVEAT
> +  if ((flags & ~(AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW)) != 0)
> +    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> +
> +  if (errno != ENOSYS)
> +    return -1;
> +  else
> +    return ENOSYS;
> +#endif
> +
> +  return -1;
> +}

Since there is no fallback anymore, there is no need to check for flag
support neither handle the errno value.  It can be simple as:

  int
  execveat (int dirfd, const char *path, char *const argv[], char *const envp[],
            int flags)
  {
    /* Avoid implicit array coercion in syscall macros.  */
    return INLINE_SYSCALL_CALL (execveat, dirfd, path, &argv[0], &envp[0],
                                flags);
  }

      reply	other threads:[~2021-05-03 19:21 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 12:20 [PATCH] Linux: Add execveat system call wrapper Alexandra Hájková via Libc-alpha
2020-04-28 14:17 ` Florian Weimer
2020-04-28 15:03   ` Joseph Myers
2020-04-28 15:03 ` Joseph Myers
2020-04-28 15:08   ` Florian Weimer
2020-04-28 15:29     ` Joseph Myers
2020-04-28 17:15       ` Florian Weimer
2020-04-28 17:19         ` Joseph Myers
2020-04-28 17:44 ` Adhemerval Zanella via Libc-alpha
2020-04-28 17:50   ` Florian Weimer
2020-04-28 18:31     ` Adhemerval Zanella via Libc-alpha
2020-04-30 11:15 ` Florian Weimer via Libc-alpha
2020-04-30 12:28   ` Adhemerval Zanella via Libc-alpha
2020-04-30 12:55     ` Florian Weimer via Libc-alpha
2020-04-30 19:03       ` Adhemerval Zanella via Libc-alpha
2020-04-30 12:32 ` Adhemerval Zanella via Libc-alpha
2020-11-06 21:03 ` Alexandra Hájková via Libc-alpha
2020-11-06 22:15   ` Joseph Myers
2020-11-09 18:43     ` Florian Weimer via Libc-alpha
2020-11-09 21:34   ` Yann Droneaud
2020-11-26 11:31     ` Alexandra Petlanova Hajkova via Libc-alpha
2020-11-09 20:39 ` Adhemerval Zanella via Libc-alpha
2020-12-03 13:55   ` Florian Weimer via Libc-alpha
2020-11-26 21:28 ` Alexandra Hájková via Libc-alpha
2020-11-27 14:58   ` Adhemerval Zanella via Libc-alpha
2020-11-27 17:32     ` Florian Weimer via Libc-alpha
2020-11-27 17:38       ` Adhemerval Zanella via Libc-alpha
2020-12-03 14:20 ` Alexandra Hájková via Libc-alpha
2020-12-03 14:37   ` Andreas Schwab
2020-12-08 14:44   ` Adhemerval Zanella via Libc-alpha
2020-12-08 15:18     ` Florian Weimer via Libc-alpha
2020-12-08 16:41       ` Adhemerval Zanella via Libc-alpha
2021-03-15 21:42 ` Alexandra Hájková via Libc-alpha
2021-03-15 22:12   ` Joseph Myers
2021-03-15 22:17   ` Dmitry V. Levin
2021-03-24 13:54 ` Alexandra Hájková via Libc-alpha
2021-03-26 20:36   ` Adhemerval Zanella via Libc-alpha
2021-04-02 12:13     ` Alexandra Hájková via Libc-alpha
2021-04-02 13:29       ` Adhemerval Zanella via Libc-alpha
2021-04-05 16:32 ` Alexandra Hájková via Libc-alpha
2021-04-12 10:26   ` Alexandra Hájková via Libc-alpha
2021-04-12 11:14   ` Andreas Schwab
2021-04-12 19:26 ` Alexandra Hájková via Libc-alpha
2021-04-13 19:27   ` Adhemerval Zanella via Libc-alpha
2021-04-21 18:11 ` Alexandra Hájková via Libc-alpha
2021-05-03 19:20   ` Adhemerval Zanella via Libc-alpha [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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to=8fedbeac-5ff8-67bf-201f-3d59b106fbab@linaro.org \
    --to=libc-alpha@sourceware.org \
    --cc=adhemerval.zanella@linaro.org \
    --cc=ahajkova@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).