public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: Xiaoming Ni <nixiaoming@huawei.com>
Cc: <drepper@redhat.com>, <libc-alpha@sourceware.org>,
	<wangle6@huawei.com>, <wangbing6@huawei.com>
Subject: Re: [PATCH] elf/tlsdeschtab.h: Add the Malloc return value check in _dl_make_tlsdesc_dynamic()
Date: Fri, 4 Nov 2022 11:00:23 +0000	[thread overview]
Message-ID: <Y2Twx4hSELfW0n4i@arm.com> (raw)
In-Reply-To: <20221104093000.25169-1-nixiaoming@huawei.com>

The 11/04/2022 17:30, Xiaoming Ni wrote:
> Check the return value of malloc based on the function header comment of
>  _dl_make_tlsdesc_dynamic(). If the return value fails, NULL is returned.
> 
> Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>

note that allocation failure is not recoverable here:
the caller cannot really deal with NULL so tls access
will crash.

i think the patch is good, but it will only help if
the failure is propagated to _dl_relocate_object and
handled in dlopen by returning an error.

let me know if you don't have commit access, then i
can commit it for you.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>

> ---
>  elf/tlsdeschtab.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/elf/tlsdeschtab.h b/elf/tlsdeschtab.h
> index 8c02e45a49..82733159e3 100644
> --- a/elf/tlsdeschtab.h
> +++ b/elf/tlsdeschtab.h
> @@ -110,6 +110,8 @@ _dl_make_tlsdesc_dynamic (struct link_map *map, size_t ti_offset)
>      }
>  
>    *entry = td = malloc (sizeof (struct tlsdesc_dynamic_arg));
> +  if (! td)
> +    return 0;
>    /* This may be higher than the map's generation, but it doesn't
>       matter much.  Worst case, we'll have one extra DTV update per
>       thread.  */
> -- 
> 2.27.0
> 

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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04  9:30 Xiaoming Ni
2022-11-04 11:00 ` Szabolcs Nagy [this message]
2022-11-05  2:34   ` Xiaoming Ni
2022-11-07 13:34     ` Szabolcs Nagy

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=Y2Twx4hSELfW0n4i@arm.com \
    --to=szabolcs.nagy@arm.com \
    --cc=drepper@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=nixiaoming@huawei.com \
    --cc=wangbing6@huawei.com \
    --cc=wangle6@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).