public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Jiangfeng Xiao <xiaojiangfeng@huawei.com>
Cc: libc-alpha@sourceware.org, schwab@linux-m68k.org,
	nixiaoming@huawei.com, douzhaolei@huawei.com,
	wangbing6@huawei.com, wangfangpeng1@huawei.com
Subject: Re: [PATCH] elf: sanitize objname in _dl_signal_error
Date: Mon, 1 Apr 2024 10:50:56 -0300	[thread overview]
Message-ID: <3f6a6290-9136-4a72-a24b-7c6bb7965569@linaro.org> (raw)
In-Reply-To: <1711939509-1411-1-git-send-email-xiaojiangfeng@huawei.com>


On 31/03/24 23:45, Jiangfeng Xiao wrote:
> "dlopen_doit" may execute
> "_dl_signal_error (0, NULL, NULL, ...)",
> which cause a segmentation fault.
> 
> The call stack is as follows:
> 
> Program received signal SIGSEGV, Segmentation fault.
> fatal_error (errcode=errcode@entry=0, objname=0x0, occasion=0x0,
>     errstring=errstring@entry=0xf7c90518 "invalid mode parameter")
> (gdb) bt
> @0  fatal_error (errcode=errcode@entry=0, objname=0x0, occasion=0x0,
>     errstring=errstring@entry=0xf7c90518 "invalid mode parameter")
> @1  0xf7de5260 in __GI__dl_signal_error (errcode=0, objname=0x0, occation=0x0,
>     errstring=0xf7c90518 "invalid mode parameter")
> @2  0xf7d0e204 in dlopen_doit (a=a@entry=0xfffefa94)
> 
> When objname is NULL, referencing *objname will accesses
> a null pointer. As a result, a segmentation fault occurs.
> 
> _dl_signal_error used to set objname to "" if it is null,
> it should continue to do so (this has been removed in commit 2449ae7b2d)
> 
> Fixes: 2449ae7b2da24 ("ld.so: Introduce struct dl_exception")

How did you trigger this issue, either from user provided ABI (dlfcn.h)
or some some internal usage (if any)? If this is a user-visible issue
it will require a bug report and a reproducer.

> 
> Suggested-by: Andreas Schwab <schwab@linux-m68k.org>
> Link: https://public-inbox.org/libc-alpha/1711806052-117857-1-git-send-email-xiaojiangfeng@huawei.com/
> Signed-off-by: Jiangfeng Xiao <xiaojiangfeng@huawei.com>
> ---
>  elf/dl-catch.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/elf/dl-catch.c b/elf/dl-catch.c
> index 2109516..92f0654 100644
> --- a/elf/dl-catch.c
> +++ b/elf/dl-catch.c
> @@ -117,6 +117,9 @@ _dl_signal_error (int errcode, const char *objname, const char *occasion,
>    if (! errstring)
>      errstring = N_("DYNAMIC LINKER BUG!!!");
>  
> +  if (! objname)
> +    objname = "";
> +
>    if (lcatch != NULL)
>      {
>        _dl_exception_create (lcatch->exception, objname, errstring);

  reply	other threads:[~2024-04-01 13:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-30 13:40 [PATCH] elf: handle NULL input to fatal_error Jiangfeng Xiao
2024-03-30 15:47 ` Andreas Schwab
2024-04-01  1:40   ` Jiangfeng Xiao
2024-04-01  2:45 ` [PATCH] elf: sanitize objname in _dl_signal_error Jiangfeng Xiao
2024-04-01 13:50   ` Adhemerval Zanella Netto [this message]
2024-04-02 14:37     ` Jiangfeng Xiao
2024-04-02 14:42       ` H.J. Lu
2024-04-02 14:54         ` Jiangfeng Xiao
2024-04-02 15:00           ` H.J. Lu
2024-04-02 15:06             ` Jiangfeng Xiao
2024-04-02 15:08               ` H.J. Lu
2024-04-02 15:21                 ` Jiangfeng Xiao
2024-04-02 15:50         ` 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

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

  git send-email \
    --in-reply-to=3f6a6290-9136-4a72-a24b-7c6bb7965569@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=douzhaolei@huawei.com \
    --cc=libc-alpha@sourceware.org \
    --cc=nixiaoming@huawei.com \
    --cc=schwab@linux-m68k.org \
    --cc=wangbing6@huawei.com \
    --cc=wangfangpeng1@huawei.com \
    --cc=xiaojiangfeng@huawei.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).