* [PATCH RFC 0/1] UAPI,x86: export syscall numbers for all x86 archs
@ 2015-07-28 8:05 David Drysdale
2015-07-28 8:05 ` [PATCH RFC 1/1] " David Drysdale
[not found] ` <1438070731-17764-1-git-send-email-drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
0 siblings, 2 replies; 5+ messages in thread
From: David Drysdale @ 2015-07-28 8:05 UTC (permalink / raw)
To: x86, Thomas Gleixner, Ingo Molnar, Andy Lutomirski,
H. Peter Anvin
Cc: Michael Kerrisk, Kees Cook, Paul Moore, Eric Paris, linux-api,
linux-kernel, David Drysdale
A while ago I was trying to build a seccomp-bpf filter program that would
survive a change of x86 architecture. This was complicated for all sorts of
reasons, but one of the problems was that the different syscall numbers aren't
all available at the same time -- hence this patch.
Naming-wise, Andy Lutomirski has indicated he'd prefer the prefixes to be
__NR_x86_64_, __NR_x86_64_x32_ and __NR_i386_; however, for the latter two
sets of numbers there are existing headers that use different prefixes
(__NR_x32_ and __NR_ia32_), so altering those would involve a change and/or an
additional set of definitions. For the new constants I've left in my
original suggestion (__NR_amd64_) for the time being.
What are folks' thoughts about the preferred naming for these?
David Drysdale (1):
UAPI,x86: export syscall numbers for all x86 archs
arch/x86/entry/syscalls/Makefile | 11 ++++++++---
arch/x86/include/uapi/asm/Kbuild | 3 +++
2 files changed, 11 insertions(+), 3 deletions(-)
--
2.4.3.573.g4eafbef
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH RFC 1/1] UAPI,x86: export syscall numbers for all x86 archs
2015-07-28 8:05 [PATCH RFC 0/1] UAPI,x86: export syscall numbers for all x86 archs David Drysdale
@ 2015-07-28 8:05 ` David Drysdale
[not found] ` <1438070731-17764-1-git-send-email-drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
1 sibling, 0 replies; 5+ messages in thread
From: David Drysdale @ 2015-07-28 8:05 UTC (permalink / raw)
To: x86, Thomas Gleixner, Ingo Molnar, Andy Lutomirski,
H. Peter Anvin
Cc: Michael Kerrisk, Kees Cook, Paul Moore, Eric Paris, linux-api,
linux-kernel, David Drysdale
Some userspace code occasionally has a need to reference the syscall
numbers for different-but-compatible architectures, so explicitly
export the generated files that contain the __NR_ia32_<name> and
__NR_x32_<name> constants.
Also, add a new generated unistd_64_amd64.h file, holding amd64
system call numbers in form __NR_amd64_<name>.
For example, this allows a seccomp-bpf filter to include filtering
for multiple architectures, and (in particular) to include x32
syscalls in an x86_64 filter. (Programmatic control of the audit
framework is another possible use case.)
Signed-off-by: David Drysdale <drysdale@google.com>
---
arch/x86/entry/syscalls/Makefile | 11 ++++++++---
arch/x86/include/uapi/asm/Kbuild | 3 +++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/arch/x86/entry/syscalls/Makefile b/arch/x86/entry/syscalls/Makefile
index 57aa59fd140c..ec6811d0db0b 100644
--- a/arch/x86/entry/syscalls/Makefile
+++ b/arch/x86/entry/syscalls/Makefile
@@ -28,7 +28,7 @@ $(uapi)/unistd_32.h: $(syscall32) $(syshdr)
syshdr_abi_unistd_32_ia32 := i386
syshdr_pfx_unistd_32_ia32 := ia32_
-$(out)/unistd_32_ia32.h: $(syscall32) $(syshdr)
+$(uapi)/unistd_32_ia32.h: $(syscall32) $(syshdr)
$(call if_changed,syshdr)
syshdr_abi_unistd_x32 := common,x32
@@ -42,7 +42,12 @@ $(uapi)/unistd_64.h: $(syscall64) $(syshdr)
syshdr_abi_unistd_64_x32 := x32
syshdr_pfx_unistd_64_x32 := x32_
-$(out)/unistd_64_x32.h: $(syscall64) $(syshdr)
+$(uapi)/unistd_64_x32.h: $(syscall64) $(syshdr)
+ $(call if_changed,syshdr)
+
+syshdr_abi_unistd_64_amd64 := common,64
+syshdr_pfx_unistd_64_amd64 := amd64_
+$(uapi)/unistd_64_amd64.h: $(syscall64) $(syshdr)
$(call if_changed,syshdr)
$(out)/syscalls_32.h: $(syscall32) $(systbl)
@@ -56,8 +61,8 @@ $(out)/xen-hypercalls.h: $(srctree)/scripts/xen-hypercalls.sh
$(out)/xen-hypercalls.h: $(srctree)/include/xen/interface/xen*.h
uapisyshdr-y += unistd_32.h unistd_64.h unistd_x32.h
+uapisyshdr-$(CONFIG_X86_64) += unistd_32_ia32.h unistd_64_amd64.h unistd_64_x32.h
syshdr-y += syscalls_32.h
-syshdr-$(CONFIG_X86_64) += unistd_32_ia32.h unistd_64_x32.h
syshdr-$(CONFIG_X86_64) += syscalls_64.h
syshdr-$(CONFIG_XEN) += xen-hypercalls.h
diff --git a/arch/x86/include/uapi/asm/Kbuild b/arch/x86/include/uapi/asm/Kbuild
index 3dec769cadf7..68805cba2fad 100644
--- a/arch/x86/include/uapi/asm/Kbuild
+++ b/arch/x86/include/uapi/asm/Kbuild
@@ -4,6 +4,9 @@ include include/uapi/asm-generic/Kbuild.asm
genhdr-y += unistd_32.h
genhdr-y += unistd_64.h
genhdr-y += unistd_x32.h
+genhdr-y += unistd_64_amd64.h
+genhdr-y += unistd_64_x32.h
+genhdr-y += unistd_32_ia32.h
header-y += a.out.h
header-y += auxvec.h
header-y += bitsperlong.h
--
2.4.3.573.g4eafbef
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH RFC 0/1] UAPI,x86: export syscall numbers for all x86 archs
[not found] ` <1438070731-17764-1-git-send-email-drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
@ 2015-07-28 12:20 ` Paul Moore
2015-07-28 15:32 ` David Drysdale
0 siblings, 1 reply; 5+ messages in thread
From: Paul Moore @ 2015-07-28 12:20 UTC (permalink / raw)
To: David Drysdale
Cc: x86-DgEjT+Ai2ygdnm+yROfE0A, Thomas Gleixner, Ingo Molnar,
Andy Lutomirski, H. Peter Anvin, Michael Kerrisk, Kees Cook,
Eric Paris, linux-api-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
On Tue, Jul 28, 2015 at 4:05 AM, David Drysdale <drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> wrote:
> A while ago I was trying to build a seccomp-bpf filter program that would
> survive a change of x86 architecture. This was complicated for all sorts of
> reasons, but one of the problems was that the different syscall numbers aren't
> all available at the same time -- hence this patch.
Or just use libseccomp and let it take care of all the different ABI
specific warts for you. The library handles the undefined syscalls
you describe, but also multiplexed syscalls (e.g. socket related
syscalls on x86) and proper invalid arch/ABI filtering (you are
filtering x32 correctly on x86-64 right?).
* https://github.com/seccomp/libseccomp
--
paul moore
www.paul-moore.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC 0/1] UAPI,x86: export syscall numbers for all x86 archs
2015-07-28 12:20 ` [PATCH RFC 0/1] " Paul Moore
@ 2015-07-28 15:32 ` David Drysdale
[not found] ` <CAHse=S8dN+e6nhSrf=hVLsfGyrR191mrxj_wc_OauqNtUXxSCg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: David Drysdale @ 2015-07-28 15:32 UTC (permalink / raw)
To: Paul Moore
Cc: X86 ML, Thomas Gleixner, Ingo Molnar, Andy Lutomirski,
H. Peter Anvin, Michael Kerrisk, Kees Cook, Eric Paris, Linux API,
linux-kernel@vger.kernel.org
On Tue, Jul 28, 2015 at 1:20 PM, Paul Moore <paul@paul-moore.com> wrote:
> On Tue, Jul 28, 2015 at 4:05 AM, David Drysdale <drysdale@google.com> wrote:
>> A while ago I was trying to build a seccomp-bpf filter program that would
>> survive a change of x86 architecture. This was complicated for all sorts of
>> reasons, but one of the problems was that the different syscall numbers aren't
>> all available at the same time -- hence this patch.
>
> Or just use libseccomp and let it take care of all the different ABI
> specific warts for you. The library handles the undefined syscalls
> you describe, but also multiplexed syscalls (e.g. socket related
> syscalls on x86) and proper invalid arch/ABI filtering
Ah, I hadn't realized that libseccomp handled cross-architecture
stuff and the socketcall multiplexing -- very neat. I'll look into whether
I can convert my stuff to use it.
I still think exporting all the sub-arch syscall numbers is a good idea
though (even if my need for it is potentially reduced by libseccomp)...
> (you are
> filtering x32 correctly on x86-64 right?).
Yep, I think so, but it's fiddly. If I can leave the fiddliness
to libseccomp, so much the better...
Thanks for the pointer,
David
> * https://github.com/seccomp/libseccomp
>
> --
> paul moore
> www.paul-moore.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC 0/1] UAPI,x86: export syscall numbers for all x86 archs
[not found] ` <CAHse=S8dN+e6nhSrf=hVLsfGyrR191mrxj_wc_OauqNtUXxSCg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-07-28 15:52 ` Paul Moore
0 siblings, 0 replies; 5+ messages in thread
From: Paul Moore @ 2015-07-28 15:52 UTC (permalink / raw)
To: David Drysdale
Cc: X86 ML, Thomas Gleixner, Ingo Molnar, Andy Lutomirski,
H. Peter Anvin, Michael Kerrisk, Kees Cook, Eric Paris, Linux API,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
On Tue, Jul 28, 2015 at 11:32 AM, David Drysdale <drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> wrote:
> On Tue, Jul 28, 2015 at 1:20 PM, Paul Moore <paul-r2n+y4ga6xFZroRs9YW3xA@public.gmane.org> wrote:
>> On Tue, Jul 28, 2015 at 4:05 AM, David Drysdale <drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> wrote:
>>> A while ago I was trying to build a seccomp-bpf filter program that would
>>> survive a change of x86 architecture. This was complicated for all sorts of
>>> reasons, but one of the problems was that the different syscall numbers aren't
>>> all available at the same time -- hence this patch.
>>
>> Or just use libseccomp and let it take care of all the different ABI
>> specific warts for you. The library handles the undefined syscalls
>> you describe, but also multiplexed syscalls (e.g. socket related
>> syscalls on x86) and proper invalid arch/ABI filtering
>
> Ah, I hadn't realized that libseccomp handled cross-architecture
> stuff and the socketcall multiplexing -- very neat. I'll look into whether
> I can convert my stuff to use it.
[Ooops, forgot to hit reply-all]
It should be pretty easy; if you've been writing BPF assembly, simply
making a few function calls should be a no-brainer.
We've got man pages for each of the libseccomp APIs that should cover
most of your questions, but there is also a collection of tests (see
the "tests/" directory) which serve as reasonable examples too. If
all else fails, you can always ask for help on our mailing list:
* https://groups.google.com/d/forum/libseccomp
> I still think exporting all the sub-arch syscall numbers is a good idea
> though (even if my need for it is potentially reduced by libseccomp)...
No real argument against it from me. I just worry that some
developers accidently get the seccomp-bpf filters wrong when they do
it by hand, e.g. ABI specific filters and not properly handling x32 on
x86-64.
>> (you are filtering x32 correctly on x86-64 right?).
>
> Yep, I think so, but it's fiddly. If I can leave the fiddliness
> to libseccomp, so much the better...
Annoyingly fiddly. If we could do it over I would much prefer to see
x32 get its own 32-bit ABI token value; sharing a value with x86-64
makes things harder than they need to be, but sadly it is too late to
change it now.
> Thanks for the pointer,
> David
>
>> * https://github.com/seccomp/libseccomp
No problem, let me know if you run into any problems.
Good luck!
--
paul moore
www.paul-moore.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-07-28 15:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-28 8:05 [PATCH RFC 0/1] UAPI,x86: export syscall numbers for all x86 archs David Drysdale
2015-07-28 8:05 ` [PATCH RFC 1/1] " David Drysdale
[not found] ` <1438070731-17764-1-git-send-email-drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2015-07-28 12:20 ` [PATCH RFC 0/1] " Paul Moore
2015-07-28 15:32 ` David Drysdale
[not found] ` <CAHse=S8dN+e6nhSrf=hVLsfGyrR191mrxj_wc_OauqNtUXxSCg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-28 15:52 ` Paul Moore
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).