public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "David S. Miller" <davem@redhat.com>
To: arnd@arndb.de
Cc: linux-kernel@vger.kernel.org
Subject: compat syscall args
Date: Sat, 29 May 2004 12:23:19 -0700	[thread overview]
Message-ID: <20040529122319.49eaafe1.davem@redhat.com> (raw)


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.

Each platform is going to behave differently in this area, so
I suppose the right thing to do really is to have the arch
specific code use little zero/sign extender stubs when necessary
so that the compat layer can assume that the args are properly
sign/zero extended already.  I guess this is how I'll fix this
up on sparc64 for now.

Comments?

             reply	other threads:[~2004-05-29 19:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-29 19:23 David S. Miller [this message]
2004-05-29 19:31 ` compat syscall args David S. Miller
2004-06-01 13:03   ` Arnd Bergmann
2004-06-01  5:06 ` Stephen Rothwell
2004-06-01  9:07   ` Arnd Bergmann
2004-06-01  9:24     ` David S. Miller
     [not found] <21hGW-h5-5@gated-at.bofh.it>
     [not found] ` <229Hi-B1-11@gated-at.bofh.it>
     [not found]   ` <22drH-3Bc-47@gated-at.bofh.it>
     [not found]     ` <22dL7-3O8-39@gated-at.bofh.it>
2004-06-01 13:07       ` Andi Kleen
2004-06-01 17:04         ` Anton Blanchard
2004-06-01 21:28           ` David S. Miller

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=20040529122319.49eaafe1.davem@redhat.com \
    --to=davem@redhat.com \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.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