From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH] mips: Fix argument passing for inlined syscalls on Linux [BZ #25523]
Date: Tue, 25 Feb 2020 17:01:29 -0300 [thread overview]
Message-ID: <3192bb62-53e2-8efc-4003-5fef1503ebb1@linaro.org> (raw)
In-Reply-To: <alpine.LFD.2.21.2002222237250.3158264@eddie.linux-mips.org>
On 22/02/2020 19:40, Maciej W. Rozycki wrote:
> On Mon, 10 Feb 2020, WANG Xuerui wrote:
>
>> According to [gcc documentation][1], temporary variables must be used for
>> the desired content to not be call-clobbered.
>
> Why does it specifically matter here?
>
>> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
>> index beefcf284b..c275d63f67 100644
>> --- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
>> +++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> [...]
>> @@ -202,11 +203,13 @@ union __mips_syscall_return
>> long _sys_result; \
>> \
>> { \
>> + long _arg1 = (long) (arg1); \
>> + long _arg2 = (long) (arg2); \
>> register long __s0 asm ("$16") __attribute__ ((unused)) \
>> = (number); \
>> register long __v0 asm ("$2"); \
>> - register long __a0 asm ("$4") = (long) (arg1); \
>> - register long __a1 asm ("$5") = (long) (arg2); \
>> + register long __a0 asm ("$4") = _arg1; \
>> + register long __a1 asm ("$5") = _arg2; \
>> register long __a3 asm ("$7"); \
>> __asm__ volatile ( \
>> ".set\tnoreorder\n\t" \
>
> Can e.g. `(long) (arg1)' end up as a library call? Do you have a case,
> even potential, where such clobbering actually happens?
On sysdeps/unix/sysv/linux/spawni.c:
188 if ((attr->__flags & POSIX_SPAWN_RESETIDS) != 0
189 && (local_seteuid (__getuid ()) != 0
190 || local_setegid (__getgid ()) != 0))
191 goto fail;
And local_seteuid/local_setegid are defined as:
sysdeps/unix/sysv/linux/local-setxid.h:
5 #ifdef __NR_setresuid32
6 # define local_seteuid(id) INLINE_SYSCALL (setresuid32, 3, -1, id, -1)
7 #else
8 # define local_seteuid(id) INLINE_SYSCALL (setresuid, 3, -1, id, -1)
9 #endif
10
11
12 #ifdef __NR_setresgid32
13 # define local_setegid(id) INLINE_SYSCALL (setresgid32, 3, -1, id, -1)
14 #else
15 # define local_setegid(id) INLINE_SYSCALL (setresgid, 3, -1, id, -1)
16 #endif
In any case, the previous usage of inline syscall is indeed fragile
and subject to such potential breakage.
next prev parent reply other threads:[~2020-02-25 20:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-09 18:57 [PATCH] mips: Fix argument passing for inlined syscalls on Linux [BZ #25523] WANG Xuerui
2020-02-10 16:06 ` Adhemerval Zanella
2020-02-10 22:34 ` Joseph Myers
2020-02-22 22:40 ` Maciej W. Rozycki
2020-02-25 20:01 ` Adhemerval Zanella [this message]
2020-02-27 18:23 ` Matt Turner
2020-03-17 0:18 ` Maciej W. Rozycki
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=3192bb62-53e2-8efc-4003-5fef1503ebb1@linaro.org \
--to=adhemerval.zanella@linaro.org \
--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).