unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] elf: Check objname before calling fatal_error
Date: Mon, 8 Apr 2024 10:39:35 -0700	[thread overview]
Message-ID: <CAMe9rOrVzwZWtYN=MyrWETz0bui+o1sBX3MeZ+d+o0tfZeK=RQ@mail.gmail.com> (raw)
In-Reply-To: <a766e0e2-0d92-4ddb-8fe1-9a81e5a9ef5c@linaro.org>

On Mon, Apr 8, 2024 at 10:18 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 08/04/24 13:58, H.J. Lu wrote:
> > On Mon, Apr 8, 2024 at 9:47 AM Adhemerval Zanella Netto
> > <adhemerval.zanella@linaro.org> wrote:
> >>
> >>
> >>
> >> On 08/04/24 13:06, H.J. Lu wrote:
> >>> _dl_signal_error may be called with objname == NULL.  _dl_exception_create
> >>> checks objname == NULL.  But fatal_error doesn't.  Check objname before
> >>> calling fatal_error.  This fixes BZ #31596.
> >>
> >> Do we have a reproducer for this? The one from BZ#31596 does seems to trigger
> >> it.
> >
> > We don't.  But it may happen in theory.
>
> Why not add the test on fatal_error instead? Because if we are adding
> possible check for argument where we are not sure that it might trigger,
> it is clear to me to add where the issue might happen (besides that our
> policy is to avoid adding fixes without proper reproducers).

void
_dl_signal_exception (int errcode, struct dl_exception *exception,
                      const char *occasion)
{
  struct rtld_catch *lcatch = get_catch ();
  if (lcatch != NULL)
    {
      *lcatch->exception = *exception;
      *lcatch->errcode = errcode;

      /* We do not restore the signal mask because none was saved.  */
      __longjmp (lcatch->env[0].__jmpbuf, 1);
    }
  else
    fatal_error (errcode, exception->objname, occasion, exception->errstring);
}

Will exception->objname ever be NULL?

> Also, I think we should close the BZ#31596 as a notabug because the
> reproducer does not actually trigger an issue and it is misleading
> that this is a glibc issue.
>
> >
> >>> ---
> >>>  elf/dl-catch.c | 6 +++++-
> >>>  1 file changed, 5 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/elf/dl-catch.c b/elf/dl-catch.c
> >>> index 2109516dba..8ef7a4c706 100644
> >>> --- a/elf/dl-catch.c
> >>> +++ b/elf/dl-catch.c
> >>> @@ -126,7 +126,11 @@ _dl_signal_error (int errcode, const char *objname, const char *occasion,
> >>>        __longjmp (lcatch->env[0].__jmpbuf, 1);
> >>>      }
> >>>    else
> >>> -    fatal_error (errcode, objname, occasion, errstring);
> >>> +    {
> >>> +      if (objname == NULL)
> >>> +     objname = "";
> >>> +      fatal_error (errcode, objname, occasion, errstring);
> >>> +    }
> >>>  }
> >>>  rtld_hidden_def (_dl_signal_error)
> >>>
>
>


-- 
H.J.

  reply	other threads:[~2024-04-08 17:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08 16:06 [PATCH] elf: Check objname before calling fatal_error H.J. Lu
2024-04-08 16:39 ` Sunil Pandey
2024-04-08 16:47 ` Adhemerval Zanella Netto
2024-04-08 16:58   ` H.J. Lu
2024-04-08 17:18     ` Adhemerval Zanella Netto
2024-04-08 17:39       ` H.J. Lu [this message]
2024-04-08 17:55         ` Adhemerval Zanella Netto

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='CAMe9rOrVzwZWtYN=MyrWETz0bui+o1sBX3MeZ+d+o0tfZeK=RQ@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=adhemerval.zanella@linaro.org \
    --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).