From: Will Deacon <will.deacon@arm.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Alan Cox <alan@linux.intel.com>,
David Laight <David.Laight@aculab.com>,
the arch/x86 maintainers <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jann Horn <jannh@google.com>,
Samuel Neves <samuel.c.p.neves@gmail.com>,
Dan Williams <dan.j.williams@intel.com>,
Kernel Hardening <kernel-hardening@lists.openwall.com>,
Borislav Petkov <bp@alien8.de>
Subject: [kernel-hardening] Re: [PATCH] x86/retpoline/entry: Disable the entire SYSCALL64 fast path with retpolines on
Date: Mon, 29 Jan 2018 13:19:42 +0000 [thread overview]
Message-ID: <20180129131942.GC25549@arm.com> (raw)
In-Reply-To: <CALCETrU9t1TO_Y7tmHnq0Qqrpmm3bBJzaAbPBV0vmtEvo28JCw@mail.gmail.com>
Hi Andy,
On Fri, Jan 26, 2018 at 10:23:23AM -0800, Andy Lutomirski wrote:
> On Fri, Jan 26, 2018 at 10:13 AM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> > On Fri, Jan 26, 2018 at 10:07 AM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> >>
> >> Umm... What about other architectures? Or do you want SYSCALL_DEFINE...
> >> to be per-arch? I wonder how much would that "go through pt_regs" hurt
> >> on something like sparc...
> >
> > No, but I just talked to Will Deacon about register clearing on entry,
> > and so I suspect that arm64 might want something similar too.
> >
> > So I think some opt-in for letting architectures add their own
> > function would be good. Because it wouldn't be all architectures, but
> > it probably _would_ be more than just x86.
> >
> > You need to add architecture-specific "load argX from ptregs" macros anyway.
>
> I mocked that up, and it's straightforward. I ended up with something like:
>
> #define __ARCH_SYSCALL_ARGS(n, ...) (regs->di, ...)
>
> (obviously modified so it actually compiles.)
>
> The issue is that doing it this way gives us, effectively:
>
> long sys_foo(int a, int b)
> {
> body here;
> }
>
> long SyS_foo(const struct pt_regs *regs)
> {
> return sys_foo(regs->di, regs->si);
> }
>
> whereas what we want is *static* long sys_foo(...). So I could split
> the macros into:
>
> DEFINE_SYSCALL2(foo, ....)
>
> and
>
> DEFINE_EXTERN_SYSCALL2(foo, ...)
>
> or I could just fix up all the code that expects calling sys_foo()
> across files to work.
Another issue with this style of macro definition exists on architectures
where the calling convention needs you to carry state around depending on
how you packed the previous parameters. For example, on 32-bit ARM, 64-bit
values are passed in adjacent pairs of registers but the low numbered
register needs to be even. This is what stopped me from trying to use
existing helpers such as syscall_get_arguments to unpack the pt_regs
and it generally means that anything that says "get me argument n" is going
to require constructing arguments 0..n-1 first.
To do this properly I think we'll either need to pass back the size and
current register offset to the arch code, or just allow the thing to be
overridden per syscall (the case above isn't especially frequent).
Will
next prev parent reply other threads:[~2018-01-29 13:19 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-22 18:04 [kernel-hardening] [PATCH] x86/retpoline/entry: Disable the entire SYSCALL64 fast path with retpolines on Andy Lutomirski
2018-01-22 18:55 ` [kernel-hardening] " Linus Torvalds
2018-01-23 8:01 ` Ingo Molnar
2018-01-23 18:36 ` Alan Cox
2018-01-25 18:48 ` Linus Torvalds
2018-01-25 19:16 ` Linus Torvalds
2018-01-25 20:04 ` Brian Gerst
2018-01-25 20:54 ` Linus Torvalds
2018-01-25 21:02 ` Andy Lutomirski
2018-01-25 21:05 ` Thomas Gleixner
2018-01-25 21:06 ` Linus Torvalds
2018-01-25 21:08 ` Andy Lutomirski
2018-01-25 21:20 ` Linus Torvalds
2018-01-25 21:31 ` Andy Lutomirski
2018-01-25 21:39 ` Dan Williams
2018-01-25 21:53 ` Andy Lutomirski
2018-01-25 21:53 ` Linus Torvalds
2018-01-26 11:17 ` [kernel-hardening] " David Laight
2018-01-26 14:24 ` [kernel-hardening] " Alan Cox
2018-01-26 15:57 ` Andy Lutomirski
2018-01-26 17:40 ` Linus Torvalds
2018-01-26 18:07 ` Al Viro
2018-01-26 18:13 ` Linus Torvalds
2018-01-26 18:23 ` Andy Lutomirski
2018-01-26 18:54 ` Linus Torvalds
2018-01-26 19:02 ` Andy Lutomirski
2018-01-29 13:19 ` Will Deacon [this message]
2018-01-29 15:23 ` [kernel-hardening] " David Laight
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=20180129131942.GC25549@arm.com \
--to=will.deacon@arm.com \
--cc=David.Laight@aculab.com \
--cc=alan@linux.intel.com \
--cc=bp@alien8.de \
--cc=dan.j.williams@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jannh@google.com \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=samuel.c.p.neves@gmail.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
--cc=x86@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;
as well as URLs for NNTP newsgroup(s).