public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Fangrui Song <maskray@google.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] elf: Remove __libc_enable_secure_decided
Date: Mon, 18 Apr 2022 12:00:44 +0200	[thread overview]
Message-ID: <8735iau2wj.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20220417225240.1656529-1-maskray@google.com> (Fangrui Song's message of "Sun, 17 Apr 2022 15:52:40 -0700")

* Fangrui Song:

> No functional change. __libc_enable_secure_decided is always 0 since
> 73fc4e28b9464f0e13edc719a5372839970e7ddb.
> ---
>  elf/enbl-secure.c | 7 ++-----
>  include/unistd.h  | 1 -
>  2 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/elf/enbl-secure.c b/elf/enbl-secure.c
> index aa2a0bd877..6a0a6d0f0f 100644
> --- a/elf/enbl-secure.c
> +++ b/elf/enbl-secure.c
> @@ -26,15 +26,12 @@
>  #include <startup.h>
>  #include <libc-internal.h>
>  
> -/* If nonzero __libc_enable_secure is already set.  */
> -int __libc_enable_secure_decided;
>  /* Safest assumption, if somehow the initializer isn't run.  */
>  int __libc_enable_secure = 1;
>  
>  void
>  __libc_init_secure (void)
>  {
> -  if (__libc_enable_secure_decided == 0)
> -    __libc_enable_secure = (startup_geteuid () != startup_getuid ()
> -			    || startup_getegid () != startup_getgid ());
> +  __libc_enable_secure = (startup_geteuid () != startup_getuid ()
> +			  || startup_getegid () != startup_getgid ());
>  }

Thanks for catching this in time before a release, this would have
turned into a minor security vulnerability.

__libc_init_secure should not overwrite __libc_enable_secure on Linux
because _dl_aux_init in dl-support.c already initializes it, and the
real vs effective check does not always yield the right results (it
exits AT_SECURE mode for a pure capabilities-based transition, for
example).

Hurd already overrides __libc_init_secure with an empty function.  I
think we should remove it completely.  Then we can also simply
<startup.h> a bit, I think.  Would you be able to write a patch along
those lines, or should I work on this?

Thanks,
Florian


  reply	other threads:[~2022-04-18 10:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-17 22:52 Fangrui Song
2022-04-18 10:00 ` Florian Weimer [this message]
2022-04-18 23:49   ` Fāng-ruì Sòng

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=8735iau2wj.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=maskray@google.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).