unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer via Libc-alpha <libc-alpha@sourceware.org>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: Xiaozhu Meng <xm13@rice.edu>,
	John Mellor-Crummey <johnmc@rice.edu>,
	libc-alpha@sourceware.org, "Mark W. Krentel" <krentel@rice.edu>
Subject: Re: Fwd: [PATCH v5 00/22] Some rtld-audit fixes
Date: Fri, 19 Nov 2021 21:31:22 +0100	[thread overview]
Message-ID: <87wnl399b9.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <d9b3a9a5-4808-ddc3-df37-7a214736794b@linaro.org> (Adhemerval Zanella's message of "Fri, 19 Nov 2021 16:56:25 -0300")

* Adhemerval Zanella:

>> "" for the main executable is widely known.  Usually code uses it to
>> implement a fallback on argv[0] or /proc/self/exe, though.
>
> There are still the issue where audit interface does not have direct
> access to argv[0] from the audited process and '/proc' might also not
> be accessible.  I am still not convinced that provided argv[0] for
> l_name for main executable is worse than "", specially because the
> fallback might not work.

I think it's better to give the auditor a chance to figure out whether
they want to use program_invocation_name (if that's not available in the
inner libc, that's for sure a bug we must fix), AT_EXECFN, or
/proc/self/exe.  If we pick one of these for the auditor, we make it
more difficult to make the appropriate choice.

>> Changing l_addr will break the libgcc unwinder.  It uses l_addr to
>> relocate the program header (see the code I quoted previously).  Not
>> everyone uses the platform unwinder, and the libgcc unwinder is
>> sometimes linked statically.  This is different from the l_name change:
>> The l_addr would definitely cause widespread breakage.
>> 
>>>  - Every use case I can think of for obtaining a link_map from the dl*
>>> functions (dlinfo and dladdr1) will either already have the special 
>>> handling, or won't operate on the main executable, or likely won't opt
>>> to use l_addr (vs. dlsym or dli_fbase) or l_name (vs. dli_fname).
>> 
>> Some special-case the main executable based on l_name, I expect, which
>> is why I'm so reluctant to change l_name.  The GDB comment is actually
>> hinting strongly towards a "" convention (that Solaris broke).
>
> So I take that Solaris does provide the application name to l_name? And
> what kind of breakage it has done on gdb?

Solaris seems to use the pathname argument to execve as l_name,
via AT_SUN_EXECNAME.  I do not know if it is an absolute name.
The documentation for getexecname suggests it may not be:

| Normally this is an absolute pathname, as the majority of commands are
| executed by the shells that append the command name to the user's PATH
| components. If this is not an absolute path, the output of getcwd(3C)
| can be prepended to it to create an absolute path, unless the process
| or one of its ancestors has changed its root directory or current
| working directory since the last successful call to one of the exec
| family of functions.

<https://docs.oracle.com/cd/E36784_01/html/E36874/getexecname-3c.html>

If that's accurate, it would be just like our AT_EXECFN.  I suspect this
won't work for fexecve, so they are just going to fall back to argv[0]
in that case.

Still I think we have 20+ years of doing things our way (the BSD way),
and I do worry about the backwards compatibility impact of such a
change.

Thanks,
Florian


  reply	other threads:[~2021-11-19 20:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <EA69A62D-7C01-4536-B551-2609226053F2@rice.edu>
2021-11-17 18:08 ` Fwd: [PATCH v5 00/22] Some rtld-audit fixes John Mellor-Crummey via Libc-alpha
2021-11-17 20:42   ` Florian Weimer via Libc-alpha
2021-11-18 21:55     ` Jonathon Anderson via Libc-alpha
2021-11-19 19:18       ` Florian Weimer via Libc-alpha
2021-11-19 19:56         ` Adhemerval Zanella via Libc-alpha
2021-11-19 20:31           ` Florian Weimer via Libc-alpha [this message]
2021-11-23 16:36             ` Adhemerval Zanella via Libc-alpha
2021-11-22 17:46 jma14 via Libc-alpha
2021-11-23 13:58 ` Adhemerval Zanella via Libc-alpha
2021-11-23 14:02   ` Florian Weimer via Libc-alpha
2021-11-23 16:25     ` Adhemerval Zanella via Libc-alpha
2021-11-23 16:50       ` Florian Weimer via Libc-alpha
2021-11-23 21:13         ` Jonathon Anderson via Libc-alpha
2021-11-25 17:56           ` Adhemerval Zanella via Libc-alpha
  -- strict thread matches above, loose matches on Subject: below --
2021-11-22 17:46 jma14 via Libc-alpha

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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to=87wnl399b9.fsf@oldenburg.str.redhat.com \
    --to=libc-alpha@sourceware.org \
    --cc=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=johnmc@rice.edu \
    --cc=krentel@rice.edu \
    --cc=xm13@rice.edu \
    /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).