mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Will Drewry <wad@chromium.org>
Cc: wade_farnsworth@mentor.com, stevenrwalter@gmail.com,
	will.deacon@arm.com, Alexander Viro <viro@zeniv.linux.org.uk>,
	Olof Johansson <olof@lixom.net>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: New ARM asm/syscall.h incompatible? (commit bf2c9f9866928df60157bc4f1ab39f93a32c754e)
Date: Wed, 23 May 2012 19:56:10 +0100	[thread overview]
Message-ID: <20120523185610.GB6908@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <CABqD9hao8sYHimbs1SjT3uRiht2ACnS8TMPyUnPt7AMrM3kVGA@mail.gmail.com>

On Wed, May 23, 2012 at 11:01:50AM -0500, Will Drewry wrote:
> Hi Wade and Steven,
> 
> I don't believe the syscall_get_arguments/syscall_set_arguments
> implementation that landed in 3.4 is correct or safe.  I didn't see it
> get pulled in - sorry for not mailing sooner! :(
> 
> The current implementation allows for _7_ arguments and allows the 0th
> index to be the ARM_ORIG_r0 instead of starting with ARM_r0 == 0.  In
> the global description of syscall_*_arguments it says:
> 
>  * It's only valid to call this when @task is stopped for tracing on
>  * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
>  * It's invalid to call this with @i + @n > 6; we only support system calls
>  * taking up to 6 arguments.
> 
> This means that the current implementation is broken when matching
> system call arguments for ftrace (unless there is an arch specific
> hack in there) and it breaks internal kernel API for any other
> consumers without arch knowledge (like seccomp mode=2).  Is there a
> reason to expose ARM_ORIG_r0 this way?  Am I misreading?
> 
> My understanding of the arch register usage at syscall time is something like:
> - ORIG_r0 gets the syscall number
> - r0 becomes the first system call argument
> - system call proceeds
> - on return, r0 is the return value

Wrong.  You're far too used to the x86 way of doing things.

For ARM, on entry to a system call, r0 _and_ orig_r0 are the first
syscall argument.  For other exceptions, orig_r0 will be -1 (but you
can't rely upon that meaning anything, because a syscall can take -1
as the first argument.)

On exit from a system call, r0 will be the return value, and orig_r0
will _still_ be the first system call argument.

  parent reply	other threads:[~2012-05-23 18:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-23 16:01 Will Drewry
2012-05-23 16:45 ` Will Deacon
2012-05-23 18:02   ` Will Drewry
2012-05-24 18:58     ` Roland McGrath
2012-05-23 18:56 ` Russell King - ARM Linux [this message]
2012-05-23 19:04   ` Will Drewry
2012-05-23 19:14     ` Russell King - ARM Linux
2012-05-24 15:39       ` Will Drewry
2012-05-24 16:11         ` Russell King - ARM Linux
2012-05-29  0:47           ` Al Viro

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=20120523185610.GB6908@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=stevenrwalter@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wad@chromium.org \
    --cc=wade_farnsworth@mentor.com \
    --cc=will.deacon@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

all inboxes | Powered by JetHome®