public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org,  John Mellor-Crummey <johnmc@rice.edu>,
	 Ben Woodard <woodard@redhat.com>,
	 Alexander Monakov <amonakov@ispras.ru>
Subject: Re: [PATCH v7 09/16] elf: Avoid unnecessary slowdown from profiling with audit (BZ#15533)
Date: Fri, 24 Dec 2021 17:05:17 +0100	[thread overview]
Message-ID: <875yre9ef6.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20211222132712.523295-10-adhemerval.zanella@linaro.org> (Adhemerval Zanella's message of "Wed, 22 Dec 2021 10:27:05 -0300")

* Adhemerval Zanella:

> The rtld-audit interfaces introduces a slowdown due to enabling
> profiling instrumentation (as if LD_AUDIT implied LD_PROFILE).
> However, instrumenting is only necessary if one of audit libraries
> provides PLT callbacks (la_pltenter or la_pltexit symbols).  Otherwise,
> the slowdown can be avoided.
>
> The following patch adjusts the logic that enables profiling to iterate
> over all audit modules and check if any of those provides a PLT hook.
> To keep la_symbind to work even without PLT callbacks, _dl_fixup now
> calls the audit callback if the modules implements it.
>
> Co-authored-by: Alexander Monakov <amonakov@ispras.ru>
>
> Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
> ---
>  NEWS                  |  3 ++
>  elf/Makefile          | 14 ++++++-
>  elf/dl-reloc.c        | 20 ++++++++-
>  elf/dl-runtime.c      | 31 ++++++++++++++
>  elf/rtld.c            |  8 +---
>  elf/tst-audit19a.c    | 38 +++++++++++++++++
>  elf/tst-audit19b.c    | 94 +++++++++++++++++++++++++++++++++++++++++++
>  elf/tst-audit19bmod.c | 23 +++++++++++
>  elf/tst-auditmod19a.c | 25 ++++++++++++
>  elf/tst-auditmod19b.c | 46 +++++++++++++++++++++
>  include/link.h        |  2 +
>  11 files changed, 294 insertions(+), 10 deletions(-)
>  create mode 100644 elf/tst-audit19a.c
>  create mode 100644 elf/tst-audit19b.c
>  create mode 100644 elf/tst-audit19bmod.c
>  create mode 100644 elf/tst-auditmod19a.c
>  create mode 100644 elf/tst-auditmod19b.c

I like the version with the l_reloc_result check much better.

> diff --git a/elf/tst-audit19b.c b/elf/tst-audit19b.c
> new file mode 100644
> index 0000000000..da015734f2
> --- /dev/null
> +++ b/elf/tst-audit19b.c
> @@ -0,0 +1,94 @@

> +  setenv ("LD_AUDIT", "tst-auditmod18b.so", 0);
> +  struct support_capture_subprocess result
> +    = support_capture_subprogram (spargv[0], spargv);
> +  support_capture_subprocess_check (&result, "tst-audit18b", 0, sc_allow_stderr);
> +
> +  bool find_symbind = false;
> +
> +  FILE *out = fmemopen (result.err.buffer, result.err.length, "r");
> +  TEST_VERIFY (out != NULL);
> +  char *buffer = NULL;
> +  size_t buffer_length = 0;
> +  while (xgetline (&buffer, &buffer_length, out))
> +    if (startswith (buffer, "la_symbind: tst_audit18bmod1_func") == 0)
> +      find_symbind = true;
> +
> +  TEST_COMPARE (find_symbind, true);
> +
> +  free (buffer);
> +  xfclose (out);

You could use strstr to find the "\nla_symbind: tst_audit18bmod1_func"
string (possibly after altering the output so that the \n is always
there).  But the version above works for me as well.

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Thanks,
Florian


  reply	other threads:[~2021-12-24 16:05 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22 13:26 [PATCH v7 00/16] Multiple rtld-audit fixes Adhemerval Zanella
2021-12-22 13:26 ` [PATCH v7 01/16] elf: Add _dl_audit_objopen Adhemerval Zanella
2021-12-24 11:50   ` Florian Weimer
2021-12-22 13:26 ` [PATCH v7 02/16] elf: Add _dl_audit_activity_map and _dl_audit_activity_nsid Adhemerval Zanella
2021-12-24 11:58   ` Florian Weimer
2021-12-27 12:10     ` Adhemerval Zanella
2021-12-22 13:26 ` [PATCH v7 03/16] elf: Add _dl_audit_objsearch Adhemerval Zanella
2021-12-24 12:05   ` Florian Weimer
2021-12-27 12:20     ` Adhemerval Zanella
2021-12-22 13:27 ` [PATCH v7 04/16] elf: Add _dl_audit_objclose Adhemerval Zanella
2021-12-24 12:10   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 05/16] elf: Add _dl_audit_symbind_alt and _dl_audit_symbind Adhemerval Zanella
2021-12-24 12:42   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 06/16] elf: Add _dl_audit_preinit Adhemerval Zanella
2021-12-24 12:47   ` Florian Weimer
2021-12-24 12:53   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 07/16] elf: Add _dl_audit_pltenter Adhemerval Zanella
2021-12-24 13:57   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 08/16] elf: Add _dl_audit_pltexit Adhemerval Zanella
2021-12-24 14:17   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 09/16] elf: Avoid unnecessary slowdown from profiling with audit (BZ#15533) Adhemerval Zanella
2021-12-24 16:05   ` Florian Weimer [this message]
2021-12-22 13:27 ` [PATCH v7 10/16] elf: Add audit tests for modules with TLSDESC Adhemerval Zanella
2021-12-24 16:55   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 11/16] elf: Do not fail for failed dlmopen on audit modules (BZ #28061) Adhemerval Zanella
2021-12-22 13:27 ` [PATCH v7 12/16] elf: Fix initial-exec TLS access on audit modules (BZ #28096) Adhemerval Zanella
2021-12-24 17:17   ` Florian Weimer
2021-12-27 20:13     ` Adhemerval Zanella
2021-12-22 13:27 ` [PATCH v7 13/16] elf: Issue audit la_objopen for vDSO Adhemerval Zanella
2021-12-24 17:44   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 14/16] elf: Add la_activity during application exit Adhemerval Zanella
2021-12-24 17:50   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 15/16] elf: Issue la_symbind for bind-now (BZ #23734) Adhemerval Zanella
2021-12-24 18:50   ` Florian Weimer
2021-12-27 20:17     ` Adhemerval Zanella
2021-12-22 13:27 ` [PATCH v7 16/16] elf: Fix runtime linker auditing on aarch64 (BZ #26643) Adhemerval Zanella
2021-12-24 18:53   ` Florian Weimer
2021-12-27 20:31     ` Adhemerval Zanella
2021-12-24 11:49 ` [PATCH v7 00/16] Multiple rtld-audit fixes 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=875yre9ef6.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=amonakov@ispras.ru \
    --cc=johnmc@rice.edu \
    --cc=libc-alpha@sourceware.org \
    --cc=woodard@redhat.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).