From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>,
the arch/x86 maintainers <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Kernel Hardening <kernel-hardening@lists.openwall.com>,
Borislav Petkov <bp@alien8.de>
Subject: [kernel-hardening] Re: [PATCH 3/3] syscalls: Add a bit of documentation to __SYSCALL_DEFINE
Date: Sun, 28 Jan 2018 20:21:28 +0000 [thread overview]
Message-ID: <20180128202128.GI13338@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CA+55aFxbE6p+3kMumsTfh_E=fR=bteKi4d6WLGaFeBP8JBv_eg@mail.gmail.com>
On Sun, Jan 28, 2018 at 11:15:15AM -0800, Linus Torvalds wrote:
> Is that "long long" part of the example on purpose? Because that's
> likely the only really nasty part about any ptregs wrapper: some
> arguments aren't _one_ register, they are two. And "long long" is the
> simplest example, even though in practice the type is most often
> "loff_t".
>
> You won't see this on 64-bit architectures, but it's visible on 32-bit ones.
>
> We may have to do wrappers for those, and error out for 'long long'.
> We already do that for some cases, for compat system calls. See for
> example
>
> COMPAT_SYSCALL_DEFINE5(preadv, compat_ulong_t, fd,
> const struct compat_iovec __user *,vec,
> compat_ulong_t, vlen, u32, pos_low, u32, pos_high)
> {
> loff_t pos = ((loff_t)pos_high << 32) | pos_low;
>
> return do_compat_preadv64(fd, vec, vlen, pos, 0);
> }
>
> where we have the issue of a 64-bit value being split over two
> registers even on 64-bit, due to it being a compat interface for 32
> bit.
>
> But if we pick up the values by hand from ptregs in a wrapper, we'll
> have this issue even for native calls on 32-bit.
... and have more of that logics arch-dependent than one might expect;
it's *not* just "split each 64bit argument into a pair of 32bit ones,
combine in the body". I tried to do something to reduce the amount of
remaining wrappers several years ago. Trying to automate that gets
very ugly very fast - there are architectures like mips where you get
alignment requirements ($6/$7 can hold that, $5/$6 can't), creating
padding arguments, etc.
FWIW, that affects
lookup_dcookie() (64,32,32)
truncate64(), ftruncate64() (32,64)
fadvise64_64(), sync_file_range() (32,64,64,32)
readahead() (32,64,32)
fadvise64() (32,64,32,32)
fallocate(), sync_file_range2() (32,32,64,64)
fanotify_mark() (32,32,64,32,32)
pread64(), pwrite64() (32,32,32,64)
Giving each of those a compat wrapper of its own is already annoying
(looking at that again, we should at least unify pread64() and pwrite64()
compat wrappers - grep for sys_pread64 and you'll see), but giving
each an explicit wrapper for native ones? Ouch.
next prev parent reply other threads:[~2018-01-28 20:21 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-28 18:38 [kernel-hardening] [PATCH 0/3] x86/pti-ish syscall cleanups Andy Lutomirski
2018-01-28 18:38 ` [kernel-hardening] [PATCH 1/3] x86/entry/64: Remove the SYSCALL64 fast path Andy Lutomirski
2018-01-28 19:00 ` [kernel-hardening] " Ingo Molnar
2018-01-30 14:49 ` [tip:x86/pti] " tip-bot for Andy Lutomirski
2018-01-30 14:50 ` [tip:x86/pti] x86/entry/64: Push extra regs right away tip-bot for Andy Lutomirski
2018-01-28 18:38 ` [kernel-hardening] [PATCH 2/3] x86/asm: Move 'status' from thread_struct to thread_info Andy Lutomirski
2018-01-28 19:02 ` [kernel-hardening] " Ingo Molnar
2018-01-28 19:19 ` Linus Torvalds
2018-01-30 14:50 ` [tip:x86/pti] " tip-bot for Andy Lutomirski
2018-01-28 18:38 ` [kernel-hardening] [PATCH 3/3] syscalls: Add a bit of documentation to __SYSCALL_DEFINE Andy Lutomirski
2018-01-28 19:15 ` [kernel-hardening] " Linus Torvalds
2018-01-28 20:21 ` Al Viro [this message]
2018-01-28 20:42 ` Linus Torvalds
2018-01-28 22:50 ` Al Viro
2018-01-29 6:22 ` Al Viro
2018-01-28 19:21 ` Ingo Molnar
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=20180128202128.GI13338@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=bp@alien8.de \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=torvalds@linux-foundation.org \
--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).