public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Stefan Liebler <stli@linux.ibm.com>
To: libc-alpha@sourceware.org
Cc: fweimer@redhat.com
Subject: Re: [PATCH] Fix getting return address in elf/tst-audit28.c.
Date: Wed, 19 Jul 2023 09:06:39 +0200	[thread overview]
Message-ID: <9035b6a2-f4c1-7f91-327e-206ac558a77d@linux.ibm.com> (raw)
In-Reply-To: <20230713131348.985999-1-stli@linux.ibm.com>

Ping
On 13.07.23 15:13, Stefan Liebler wrote:
> Starting with commit 1bcfe0f732066ae5336b252295591ebe7e51c301, the
> test was enhanced and the object for __builtin_return_address (0)
> is searched with _dl_find_object.
> 
> Unfortunately on e.g. s390 (31bit), a postprocessing step is needed
> as the highest bit has to be masked out.  This can be done with
> __builtin_extract_return_addr.
> 
> Without this postprocessing, _dl_find_object returns with -1 and the
> content of dlfo is invalid, which may lead to segfaults in basename.
> Therefore those checks are now only done on success.
> ---
>  elf/tst-auditmod28.c | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/elf/tst-auditmod28.c b/elf/tst-auditmod28.c
> index f6dfbbe202..35180208ba 100644
> --- a/elf/tst-auditmod28.c
> +++ b/elf/tst-auditmod28.c
> @@ -73,12 +73,19 @@ la_version (unsigned int current)
>  
>    /* Check _dl_find_object.  */
>    struct dl_find_object dlfo;
> -  TEST_COMPARE (_dl_find_object (__builtin_return_address (0), &dlfo), 0);
> -  /* "ld.so" is seen with --enable-hardcoded-path-in-tests.  */
> -  if (strcmp (basename (dlfo.dlfo_link_map->l_name), "ld.so") != 0)
> -    TEST_COMPARE_STRING (basename (dlfo.dlfo_link_map->l_name), LD_SO);
> -  TEST_COMPARE (_dl_find_object (dlsym (handle, "environ"), &dlfo), 0);
> -  TEST_COMPARE_STRING (basename (dlfo.dlfo_link_map->l_name), LIBC_SO);
> +  void *ret_addr = __builtin_extract_return_addr (__builtin_return_address (0));
> +  int ret_dl_find_object =_dl_find_object (ret_addr, &dlfo);
> +  TEST_COMPARE (ret_dl_find_object, 0);
> +  if (ret_dl_find_object == 0)
> +    {
> +      /* "ld.so" is seen with --enable-hardcoded-path-in-tests.  */
> +      if (strcmp (basename (dlfo.dlfo_link_map->l_name), "ld.so") != 0)
> +	TEST_COMPARE_STRING (basename (dlfo.dlfo_link_map->l_name), LD_SO);
> +    }
> +  ret_dl_find_object = _dl_find_object (dlsym (handle, "environ"), &dlfo);
> +  TEST_COMPARE (ret_dl_find_object, 0);
> +  if (ret_dl_find_object == 0)
> +    TEST_COMPARE_STRING (basename (dlfo.dlfo_link_map->l_name), LIBC_SO);
>    TEST_COMPARE (_dl_find_object ((void *) 1, &dlfo), -1);
>    TEST_COMPARE (_dl_find_object ((void *) -1, &dlfo), -1);
>  


  reply	other threads:[~2023-07-19  7:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-13 13:13 Stefan Liebler
2023-07-19  7:06 ` Stefan Liebler [this message]
2023-07-19  9:15 ` Florian Weimer
2023-07-19 11:20   ` Stefan Liebler

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=9035b6a2-f4c1-7f91-327e-206ac558a77d@linux.ibm.com \
    --to=stli@linux.ibm.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).