public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Subject: Re: [PATCH v2] elf: _dl_find_object may return 1 during early startup (bug 30515)
Date: Thu, 6 Jul 2023 15:44:14 -0400	[thread overview]
Message-ID: <bd558b24-60f9-76a2-b026-33ccf0f771c8@redhat.com> (raw)
In-Reply-To: <87ilbzlhes.fsf@oldenburg3.str.redhat.com>

On 6/7/23 06:02, Florian Weimer via Libc-alpha wrote:
> Success is reported with a 0 return value, and failure is -1.
> Enhance the kitchen sink test elf/tst-audit28 to cover
> _dl_find_object as well.
> 
> Fixes commit 5d28a8962dcb ("elf: Add _dl_find_object function")
> and bug 30515.

Tested on x86_64 and it looks correct to me.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>

> 
> ---
> v2: Handle "ld.so" for --enable-hardcoded-path-in-tests.
>  elf/dl-find_object.c |  2 +-
>  elf/tst-auditmod28.c | 11 +++++++++++
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/elf/dl-find_object.c b/elf/dl-find_object.c
> index 928eb499cc..c1390ee10f 100644
> --- a/elf/dl-find_object.c
> +++ b/elf/dl-find_object.c
> @@ -46,7 +46,7 @@ _dl_find_object_slow (void *pc, struct dl_find_object *result)
>            struct dl_find_object_internal internal;
>            _dl_find_object_from_map (l, &internal);
>            _dl_find_object_to_external (&internal, result);
> -          return 1;
> +          return 0;

OK. Normal _dl_find_object returns -1 for failure and 0 for success.

>          }
>  
>    /* Object not found.  */
> diff --git a/elf/tst-auditmod28.c b/elf/tst-auditmod28.c
> index f6ab991398..f6dfbbe202 100644
> --- a/elf/tst-auditmod28.c
> +++ b/elf/tst-auditmod28.c
> @@ -71,6 +71,17 @@ la_version (unsigned int current)
>    TEST_VERIFY (dladdr1 (&_exit, &info, &extra_info, RTLD_DL_LINKMAP) != 0);
>    TEST_VERIFY (extra_info == handle);
>  
> +  /* 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);

OK.

> +  TEST_COMPARE (_dl_find_object (dlsym (handle, "environ"), &dlfo), 0);

OK.

> +  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);

OK.

> +
>    /* Verify that dlmopen creates a new namespace.  */
>    void *dlmopen_handle = xdlmopen (LM_ID_NEWLM, LIBC_SO, RTLD_NOW);
>    TEST_VERIFY (dlmopen_handle != handle);
> 
> base-commit: 85e6d8b4175fcb195011a0a1bad37d6f3b2355db
> 

-- 
Cheers,
Carlos.


  parent reply	other threads:[~2023-07-06 19:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-07 10:02 Florian Weimer
2023-06-07 17:31 ` Adhemerval Zanella Netto
2023-07-06 19:44 ` Carlos O'Donell [this message]
2023-07-04 12:46 Florian Weimer

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=bd558b24-60f9-76a2-b026-33ccf0f771c8@redhat.com \
    --to=carlos@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --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).