public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Szabolcs Nagy via Libc-alpha <libc-alpha@sourceware.org>
Cc: Szabolcs Nagy <szabolcs.nagy@arm.com>
Subject: Re: [PATCH v3 1/2] aarch64: Use generic argv adjustment in ld.so [BZ #23293]
Date: Tue, 03 May 2022 13:53:19 +0200	[thread overview]
Message-ID: <875ymmx26o.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <4a157fa95462503bd1b6c3218644a0334ae52325.1649854695.git.szabolcs.nagy@arm.com> (Szabolcs Nagy via Libc-alpha's message of "Wed, 13 Apr 2022 14:00:22 +0100")

* Szabolcs Nagy via Libc-alpha:

> When an executable is invoked as
>
>   ./ld.so [ld.so-args] ./exe [exe-args]
>
> then the argv is adujusted in ld.so before calling the entry point of
> the executable so ld.so args are not visible to it.  On most targets
> this requires moving argv, env and auxv on the stack to ensure correct
> stack alignment at the entry point.  This had several issues:
>
> - The code for this adjustment on the stack is written in asm as part
>   of the target specific ld.so _start code which is hard to maintain.
>
> - The adjustment is done after _dl_start returns, where it's too late
>   to update GLRO(dl_auxv), as it is already readonly, so it points to
>   memory that was clobbered by the adjustment. This is bug 23293.
>
> - _environ is also wrong in ld.so after the adjustment, but it is
>   likely not used after _dl_start returns so this is not user visible.
>
> - _dl_argv was updated, but for this it was moved out of relro, which
>   changes security properties across targets unnecessarily.
>
> This patch introduces a generic _dl_start_args_adjust function that
> handles the argument adjustments after ld.so processed its own args
> and before relro protection is applied.  It sets _dl_skip_args to 0 so
> the existing adjustment in asm is not invoked.  Each target has to
> opt-in to use this new adjustment since some targets don't need it.
> Once all targets are updated, _dl_argv declaration can be simplified.
>
> A new _dl_start_argptr was introduced because the original sp is not
> passed to dl_main which now has to do the adjustments.
>
> --
> v2:
> - use p != NULL, and a_type != AT_NULL
> - remove the confusing paragraph from the commit message.

Looks good to me.

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

Thanks,
Florian


  reply	other threads:[~2022-05-03 15:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-13 13:00 [PATCH v3 0/2] Args adjustment with ./ld.so exe " Szabolcs Nagy
2022-04-13 13:00 ` [PATCH v3 1/2] aarch64: Use generic argv adjustment in ld.so " Szabolcs Nagy
2022-05-03 11:53   ` Florian Weimer [this message]
2022-05-03 16:53     ` Szabolcs Nagy
2022-05-03 17:00       ` Florian Weimer
2022-04-13 13:00 ` [PATCH v3 2/2] aarch64: Move ld.so _start to separate file and drop _dl_skip_args Szabolcs Nagy
2022-05-03 11:53   ` 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=875ymmx26o.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=szabolcs.nagy@arm.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).