public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Joe Simmons-Talbott <josimmon@redhat.com>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH v6 3/3] nptl: Use direct syscall numbers in setxid
Date: Thu, 25 May 2023 14:07:22 -0400	[thread overview]
Message-ID: <20230525180722.GM176347@oak> (raw)
In-Reply-To: <20230424150353.1469397-4-josimmon@redhat.com>

ping.

Thanks,
Joe

On Mon, Apr 24, 2023 at 11:03:53AM -0400, Joe Simmons-Talbott wrote:
> Make all internal glibc syscalls use direct compile time numeric values
> rather than variables.  This will make the syscall number easier to
> identify during static analysis.
> ---
>  nptl/nptl_setxid.c | 136 +++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 132 insertions(+), 4 deletions(-)
> 
> diff --git a/nptl/nptl_setxid.c b/nptl/nptl_setxid.c
> index 4bfcfe4188..797015def1 100644
> --- a/nptl/nptl_setxid.c
> +++ b/nptl/nptl_setxid.c
> @@ -66,8 +66,72 @@ __nptl_setxid_sighandler (int sig, siginfo_t *si, void *ctx)
>        || si->si_code != SI_TKILL)
>      return;
>  
> -  result = INTERNAL_SYSCALL_NCS (xidcmd->syscall_no, 3, xidcmd->id[0],
> -				 xidcmd->id[1], xidcmd->id[2]);
> +  switch(xidcmd->syscall_no)
> +  {
> +#ifdef __NR_setuid32
> +    case __NR_setuid32:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setuid32, 3, xidcmd->id[0],
> +				     xidcmd->id[1], xidcmd->id[2]);
> +      break;
> +#endif /* __NR_setuid32 */
> +    case __NR_setuid:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setuid, 3, xidcmd->id[0],
> +				     xidcmd->id[1], xidcmd->id[2]);
> +      break;
> +#ifdef __NR_setreuid32
> +    case __NR_setreuid32:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setreuid32, 3, xidcmd->id[0],
> +				     xidcmd->id[1], xidcmd->id[2]);
> +      break;
> +#endif /* __NR_setreuid32 */
> +    case __NR_setreuid:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setreuid, 3, xidcmd->id[0],
> +				     xidcmd->id[1], xidcmd->id[2]);
> +      break;
> +#ifdef __NR_setresgid32
> +    case __NR_setresgid32:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setresgid32, 3, xidcmd->id[0],
> +				     xidcmd->id[1], xidcmd->id[2]);
> +      break;
> +#endif /* __NR_setresgid32 */
> +    case __NR_setresgid:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setresgid, 3, xidcmd->id[0],
> +				     xidcmd->id[1], xidcmd->id[2]);
> +      break;
> +#ifdef __NR_setregid32
> +    case __NR_setregid32:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setregid32, 3, xidcmd->id[0],
> +				     xidcmd->id[1], xidcmd->id[2]);
> +      break;
> +#endif /* __NR_setregid32 */
> +    case __NR_setregid:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setregid, 3, xidcmd->id[0],
> +				     xidcmd->id[1], xidcmd->id[2]);
> +      break;
> +#ifdef __NR_setgid32
> +    case __NR_setgid32:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setgid32, 3, xidcmd->id[0],
> +				     xidcmd->id[1], xidcmd->id[2]);
> +      break;
> +#endif /* __NR_setgid32 */
> +    case __NR_setgid:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setgid, 3, xidcmd->id[0],
> +				     xidcmd->id[1], xidcmd->id[2]);
> +      break;
> +#ifdef __NR_setgroups32
> +    case __NR_setgroups32:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setgroups32, 3, xidcmd->id[0],
> +				     xidcmd->id[1], xidcmd->id[2]);
> +      break;
> +#endif /* __NR_setgroups32 */
> +    case __NR_setgroups:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setgroups, 3, xidcmd->id[0],
> +				     xidcmd->id[1], xidcmd->id[2]);
> +      break;
> +   default:
> +      result = INTERNAL_SYSCALL_NCS (xidcmd->syscall_no, 3, xidcmd->id[0],
> +				     xidcmd->id[1], xidcmd->id[2]);
> +  }
>    int error = 0;
>    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
>      error = INTERNAL_SYSCALL_ERRNO (result);
> @@ -262,8 +326,72 @@ __nptl_setxid (struct xid_command *cmdp)
>  
>    /* This must be last, otherwise the current thread might not have
>       permissions to send SIGSETXID syscall to the other threads.  */
> -  result = INTERNAL_SYSCALL_NCS (cmdp->syscall_no, 3,
> -                                 cmdp->id[0], cmdp->id[1], cmdp->id[2]);
> +  switch(cmdp->syscall_no)
> +  {
> +#ifdef __NR_setuid32
> +    case __NR_setuid32:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setuid32, 3, cmdp->id[0],
> +				     cmdp->id[1], cmdp->id[2]);
> +      break;
> +#endif /* __NR_setuid32 */
> +    case __NR_setuid:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setuid, 3, cmdp->id[0],
> +				     cmdp->id[1], cmdp->id[2]);
> +      break;
> +#ifdef __NR_setreuid32
> +    case __NR_setreuid32:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setreuid32, 3, cmdp->id[0],
> +				     cmdp->id[1], cmdp->id[2]);
> +      break;
> +#endif /* __NR_setreuid32 */
> +    case __NR_setreuid:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setreuid, 3, cmdp->id[0],
> +				     cmdp->id[1], cmdp->id[2]);
> +      break;
> +#ifdef __NR_setresgid32
> +    case __NR_setresgid32:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setresgid32, 3, cmdp->id[0],
> +				     cmdp->id[1], cmdp->id[2]);
> +      break;
> +#endif /* __NR_setresgid32 */
> +    case __NR_setresgid:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setresgid, 3, cmdp->id[0],
> +				     cmdp->id[1], cmdp->id[2]);
> +      break;
> +#ifdef __NR_setregid32
> +    case __NR_setregid32:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setregid32, 3, cmdp->id[0],
> +				     cmdp->id[1], cmdp->id[2]);
> +      break;
> +#endif /* __NR_setregid32 */
> +    case __NR_setregid:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setregid, 3, cmdp->id[0],
> +				     cmdp->id[1], cmdp->id[2]);
> +      break;
> +#ifdef __NR_setgid32
> +    case __NR_setgid32:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setgid32, 3, cmdp->id[0],
> +				     cmdp->id[1], cmdp->id[2]);
> +      break;
> +#endif /* __NR_setgid32 */
> +    case __NR_setgid:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setgid, 3, cmdp->id[0],
> +				     cmdp->id[1], cmdp->id[2]);
> +      break;
> +#ifdef __NR_setgroups32
> +    case __NR_setgroups32:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setgroups32, 3, cmdp->id[0],
> +				     cmdp->id[1], cmdp->id[2]);
> +      break;
> +#endif /* __NR_setgroups32 */
> +    case __NR_setgroups:
> +      result = INTERNAL_SYSCALL_NCS (__NR_setgroups, 3, cmdp->id[0],
> +				     cmdp->id[1], cmdp->id[2]);
> +      break;
> +   default:
> +      result = INTERNAL_SYSCALL_NCS (cmdp->syscall_no, 3, cmdp->id[0],
> +				     cmdp->id[1], cmdp->id[2]);
> +  }
>    int error = 0;
>    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
>      {
> -- 
> 2.39.2
> 


  parent reply	other threads:[~2023-05-25 18:07 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24 15:03 [PATCH v6 0/3] x86_64: aarch64: Set call number just before syscall Joe Simmons-Talbott
2023-04-24 15:03 ` [PATCH v6 1/3] x86_64: Set the syscall register right before doing the syscall Joe Simmons-Talbott
2023-05-15 14:15   ` Joe Simmons-Talbott
2023-05-15 16:20     ` H.J. Lu
2023-05-25 18:07   ` Joe Simmons-Talbott
2023-05-25 18:40     ` Noah Goldstein
2023-05-26  7:04       ` Florian Weimer
2023-05-26 12:59         ` Joe Simmons-Talbott
2023-05-26 21:18           ` Noah Goldstein
2023-05-30 10:13             ` Florian Weimer
2023-05-31 18:23               ` Noah Goldstein
2023-06-28 19:17                 ` Joe Simmons-Talbott
2023-04-24 15:03 ` [PATCH v6 2/3] aarch64: " Joe Simmons-Talbott
2023-05-09  7:47   ` Szabolcs Nagy
2023-04-24 15:03 ` [PATCH v6 3/3] nptl: Use direct syscall numbers in setxid Joe Simmons-Talbott
2023-04-24 15:17   ` Xi Ruoyao
2023-04-26  9:46     ` Szabolcs Nagy
2023-04-28 10:52       ` Florian Weimer
2023-04-26 12:39     ` Cristian Rodríguez
2023-04-26 13:24       ` Szabolcs Nagy
2023-05-25 18:07   ` Joe Simmons-Talbott [this message]
2023-05-08 14:13 ` [PATCH v6 0/3] x86_64: aarch64: Set call number just before syscall Joe Simmons-Talbott

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=20230525180722.GM176347@oak \
    --to=josimmon@redhat.com \
    --cc=libc-alpha@sourceware.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 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).