public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Simon Chopin <simon.chopin@canonical.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] Linux: Switch back to assembly syscall wrapper for prctl (bug 29770)
Date: Tue, 13 Feb 2024 12:54:45 +0100	[thread overview]
Message-ID: <87jzn8inp6.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <CAOOWow3CiCUcrX5om8+F7xQW+vD8LGYLjtys5u-6mML=+XiNZA@mail.gmail.com> (Simon Chopin's message of "Tue, 13 Feb 2024 03:35:03 -0800")

* Simon Chopin:

> Hi Florian,
>
> On ven. 02 févr. 2024 22:30:25, Florian Weimer wrote:
>> Commit ff026950e280bc3e9487b41b460fb31bc5b57721 ("Add a C wrapper for
>> prctl [BZ #25896]") replaced the assembler wrapper with a C function.
>> However, the C variadic function implementation has a different ABI
>> on powerpc64le-linux-gnu.  Switch back to the assembler implementation
>> on most targets and only keep the C implementation for x86-64 x32.
>>
>> Also add the __prctl_time64 alias from commit
>> b39ffab860cd743a82c91946619f1b8158b0b65e ("Linux: Add time64 alias for
>> prctl") to sysdeps/unix/sysv/linux/syscalls.list; it was not yet
>> present in commit ff026950e280bc3e9487b41b460fb31bc5b57721.
>>
>> This restores the old ABI on powerpc64le-linux-gnu, thus fixing
>> bug 29770.
>
> Codewise it all looks good to me, but I have a perhaps dumb question:
> at this point, aren't we breaking ABI again? Presumably, binaries have
> been compiled against the varargs ABI, which AFAICT has been shipped in
> RHEL 9 and Ubuntu 22.04 among others, which have been out for a while
> now.

It's possible to call functions with the parameter save area present
that do not actually need it.  The issue is in the other direction only.

I believe the ABI was designed this way that it's possible to compile
lots of legacy software that uses implicit function declarations, where
the compiler has no information whether the function is defined variadic
or not.  Therefore, it creates the parameter save area for all such
calls.  I could probably word the commit message better, maybe like
this:

“
Commit ff026950e280bc3e9487b41b460fb31bc5b57721 ("Add a C wrapper for
prctl [BZ #25896]") replaced the assembler wrapper with a C function.
However, on powerpc64le-linux-gnu, the C variadic function
implementation requires extra work in the caller to set up the parameter
save area.  Calling a function that needs a parameter save area without
one (because the prototype used indicates the function is not variadic)
corrupts the caller's stack.  Switch back to the assembler
implementation on most targets and only keep the C implementation for
x86-64 x32.
”

Thanks,
Florian


  reply	other threads:[~2024-02-13 11:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02 21:30 Florian Weimer
2024-02-13 11:35 ` Simon Chopin
2024-02-13 11:54   ` Florian Weimer [this message]
2024-02-13 12:12     ` Andreas Schwab
2024-02-13 12:24       ` Florian Weimer
2024-02-13 12:40         ` Andreas Schwab

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=87jzn8inp6.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=simon.chopin@canonical.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).