public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: GNU C Library <libc-alpha@sourceware.org>,
	Florian Weimer <fweimer@redhat.com>
Subject: PING^2 [PATCH] elf: Guard against __LM_ID_CALLER [BZ #27609]
Date: Wed, 29 Sep 2021 09:57:50 -0700	[thread overview]
Message-ID: <CAMe9rOqE2btHuMLuFrR++_y=oqFknPjjB=8++X8LHgjkarN+TA@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOq_Gq_cSTMWCY_ULktYHSR4JNfhPqsB7XA+vDSGimDpyA@mail.gmail.com>

On Mon, Sep 20, 2021 at 9:53 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Tue, Aug 17, 2021 at 11:45 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > do_dlopen calls _dl_open with nsid == __LM_ID_CALLER (-2).  When _dl_open
> > fails in nptl/tst-setuid1 , we can reach
> >
> > 881       /* Avoid keeping around a dangling reference to the libc.so link
> > 882          map in case it has been cached in libc_map.  */
> > 883       if (!args.libc_already_loaded)
> > 884         GL(dl_ns)[nsid].libc_map = NULL;
> > 885
> >
> > with nsid == -2.  Guard against __LM_ID_CALLER before updating libc_map
> > to avoid buffer underflow.  This fixes BZ #27609.
> > ---
> >  elf/dl-open.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/elf/dl-open.c b/elf/dl-open.c
> > index e90287bc62..5c54df5b7f 100644
> > --- a/elf/dl-open.c
> > +++ b/elf/dl-open.c
> > @@ -885,7 +885,7 @@ no more namespaces available for dlmopen()"));
> >      {
> >        /* Avoid keeping around a dangling reference to the libc.so link
> >          map in case it has been cached in libc_map.  */
> > -      if (!args.libc_already_loaded)
> > +      if (!args.libc_already_loaded && nsid >= 0)
> >         GL(dl_ns)[nsid].libc_map = NULL;
> >
> >        /* Remove the object from memory.  It may be in an inconsistent
> > --
> > 2.31.1
> >
>
> PING.
>

Any comments on this patch?


-- 
H.J.

      reply	other threads:[~2021-09-29 16:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17 18:45 H.J. Lu
2021-09-20 16:53 ` PIN^1 " H.J. Lu
2021-09-29 16:57   ` H.J. Lu [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='CAMe9rOqE2btHuMLuFrR++_y=oqFknPjjB=8++X8LHgjkarN+TA@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=fweimer@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).