Re: compat syscall args
From: Stephen Rothwell
Date: Tue Jun 01 2004 - 00:07:56 EST
Hi Dave,
On Sat, 29 May 2004 12:23:19 -0700 "David S. Miller" <davem@xxxxxxxxxx> wrote:
>
>
> Arnd asked:
>
> > If sparc64 has this problem only for the fifth syscall argument,
> > does that mean that e.g. compat_sys_futex and
> > compat_sys_mq_timed{send,receive} have the same bug? If this is
> > a more general, i.e. not limited to the last argument, there is a
> > potential problem in lots of syscalls.
>
> Here is the issue. In the sparc64 C calling conventions, it is
> assumed that 32-bit signed values are sign extended by the
> caller.
>
> This means that, at syscall invocation time, we have to choose
> between either:
>
> 1) sign extending all syscall args for the C code, then explicitly
> zero-extending all non-signed syscall args. This would require
> the most amount of compat layer code help.
>
> 2) zero extending all syscall args for the C code, then expliticly
> sign-extending all signed syscall args.
>
> 3) some mixture of 1 and 2
>
> #3 is what sparc64 does, it hits the highest number of system
> call arguments correctly. Specifically we:
>
> arg0: zero-extend
> arg1: zero-extend
> arg2: zero-extend
> arg3: zero-extend
> arg4: leave as-is
> arg5: leave as-is
>
> I remember discussing this with Andi Kleen before.
Yeah, you and Andi and I (and others, I think) had this discussion, but it ended like this:
--------------------
Date: Thu, 13 Jun 2002 22:56:52 -0700 (PDT)
Message-Id: <20020613.225652.109741623.davem@xxxxxxxxxx>
To: ak@xxxxxxx
Cc: sfr@xxxxxxxxxxxxxxxx, ralf@xxxxxxx, engebret@xxxxxxxxxx,
schwidefsky@xxxxxxxxxx, linux390@xxxxxxxxxx, anton@xxxxxxxxx
Subject: Re: [PATCH] Consolidate sys32_utime
From: "David S. Miller" <davem@xxxxxxxxxx>
From: Andi Kleen <ak@xxxxxxx>
Date: Fri, 14 Jun 2002 07:53:10 +0200
On Thu, Jun 13, 2002 at 10:37:23PM -0700, David S. Miller wrote:
> We could easily change that to "all args zero-extended" if that makes
> everything easier. It probably does.
I've had good experiences with zero extension at least so far.
Would be probably good just for consistency.
So be it, the convention is that all arguments are zero extended from
32-bits to 64-bits when the syscall is invoked.
----------------------------------------------------------------------
Did something change along the way?
--
Cheers,
Stephen Rothwell sfr@xxxxxxxxxxxxxxxx
http://www.canb.auug.org.au/~sfr/
Attachment:
pgp00000.pgp
Description: PGP signature