diff options
author | David Drysdale <drysdale@google.com> | 2014-12-12 19:57:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-13 15:42:51 -0500 |
commit | 27d6ec7ad6f7a2a131ff8e9f77bcc6547e178d2c (patch) | |
tree | a9d56ffca09d414656cac5a57c9b55c4b226cbea | |
parent | 51f39a1f0cea1cacf8c787f652f26dfee9611874 (diff) |
x86: hook up execveat system call
Hook up x86-64, i386 and x32 ABIs.
Signed-off-by: David Drysdale <drysdale@google.com>
Cc: Meredydd Luff <meredydd@senatehouse.org>
Cc: Shuah Khan <shuah.kh@samsung.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Rich Felker <dalias@aerifal.cx>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/x86/ia32/audit.c | 1 | ||||
-rw-r--r-- | arch/x86/ia32/ia32entry.S | 1 | ||||
-rw-r--r-- | arch/x86/kernel/audit_64.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/entry_64.S | 28 | ||||
-rw-r--r-- | arch/x86/syscalls/syscall_32.tbl | 1 | ||||
-rw-r--r-- | arch/x86/syscalls/syscall_64.tbl | 2 | ||||
-rw-r--r-- | arch/x86/um/sys_call_table_64.c | 1 |
7 files changed, 35 insertions, 0 deletions
diff --git a/arch/x86/ia32/audit.c b/arch/x86/ia32/audit.c index 5d7b381da692..2eccc8932ae6 100644 --- a/arch/x86/ia32/audit.c +++ b/arch/x86/ia32/audit.c | |||
@@ -35,6 +35,7 @@ int ia32_classify_syscall(unsigned syscall) | |||
35 | case __NR_socketcall: | 35 | case __NR_socketcall: |
36 | return 4; | 36 | return 4; |
37 | case __NR_execve: | 37 | case __NR_execve: |
38 | case __NR_execveat: | ||
38 | return 5; | 39 | return 5; |
39 | default: | 40 | default: |
40 | return 1; | 41 | return 1; |
diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S index ffe71228fc10..82e8a1d44658 100644 --- a/arch/x86/ia32/ia32entry.S +++ b/arch/x86/ia32/ia32entry.S | |||
@@ -480,6 +480,7 @@ GLOBAL(\label) | |||
480 | PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn | 480 | PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn |
481 | PTREGSCALL stub32_sigreturn, sys32_sigreturn | 481 | PTREGSCALL stub32_sigreturn, sys32_sigreturn |
482 | PTREGSCALL stub32_execve, compat_sys_execve | 482 | PTREGSCALL stub32_execve, compat_sys_execve |
483 | PTREGSCALL stub32_execveat, compat_sys_execveat | ||
483 | PTREGSCALL stub32_fork, sys_fork | 484 | PTREGSCALL stub32_fork, sys_fork |
484 | PTREGSCALL stub32_vfork, sys_vfork | 485 | PTREGSCALL stub32_vfork, sys_vfork |
485 | 486 | ||
diff --git a/arch/x86/kernel/audit_64.c b/arch/x86/kernel/audit_64.c index 06d3e5a14d9d..f3672508b249 100644 --- a/arch/x86/kernel/audit_64.c +++ b/arch/x86/kernel/audit_64.c | |||
@@ -50,6 +50,7 @@ int audit_classify_syscall(int abi, unsigned syscall) | |||
50 | case __NR_openat: | 50 | case __NR_openat: |
51 | return 3; | 51 | return 3; |
52 | case __NR_execve: | 52 | case __NR_execve: |
53 | case __NR_execveat: | ||
53 | return 5; | 54 | return 5; |
54 | default: | 55 | default: |
55 | return 0; | 56 | return 0; |
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index c0226ab54106..90878aa38dbd 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S | |||
@@ -652,6 +652,20 @@ ENTRY(stub_execve) | |||
652 | CFI_ENDPROC | 652 | CFI_ENDPROC |
653 | END(stub_execve) | 653 | END(stub_execve) |
654 | 654 | ||
655 | ENTRY(stub_execveat) | ||
656 | CFI_STARTPROC | ||
657 | addq $8, %rsp | ||
658 | PARTIAL_FRAME 0 | ||
659 | SAVE_REST | ||
660 | FIXUP_TOP_OF_STACK %r11 | ||
661 | call sys_execveat | ||
662 | RESTORE_TOP_OF_STACK %r11 | ||
663 | movq %rax,RAX(%rsp) | ||
664 | RESTORE_REST | ||
665 | jmp int_ret_from_sys_call | ||
666 | CFI_ENDPROC | ||
667 | END(stub_execveat) | ||
668 | |||
655 | /* | 669 | /* |
656 | * sigreturn is special because it needs to restore all registers on return. | 670 | * sigreturn is special because it needs to restore all registers on return. |
657 | * This cannot be done with SYSRET, so use the IRET return path instead. | 671 | * This cannot be done with SYSRET, so use the IRET return path instead. |
@@ -697,6 +711,20 @@ ENTRY(stub_x32_execve) | |||
697 | CFI_ENDPROC | 711 | CFI_ENDPROC |
698 | END(stub_x32_execve) | 712 | END(stub_x32_execve) |
699 | 713 | ||
714 | ENTRY(stub_x32_execveat) | ||
715 | CFI_STARTPROC | ||
716 | addq $8, %rsp | ||
717 | PARTIAL_FRAME 0 | ||
718 | SAVE_REST | ||
719 | FIXUP_TOP_OF_STACK %r11 | ||
720 | call compat_sys_execveat | ||
721 | RESTORE_TOP_OF_STACK %r11 | ||
722 | movq %rax,RAX(%rsp) | ||
723 | RESTORE_REST | ||
724 | jmp int_ret_from_sys_call | ||
725 | CFI_ENDPROC | ||
726 | END(stub_x32_execveat) | ||
727 | |||
700 | #endif | 728 | #endif |
701 | 729 | ||
702 | /* | 730 | /* |
diff --git a/arch/x86/syscalls/syscall_32.tbl b/arch/x86/syscalls/syscall_32.tbl index 9fe1b5d002f0..b3560ece1c9f 100644 --- a/arch/x86/syscalls/syscall_32.tbl +++ b/arch/x86/syscalls/syscall_32.tbl | |||
@@ -364,3 +364,4 @@ | |||
364 | 355 i386 getrandom sys_getrandom | 364 | 355 i386 getrandom sys_getrandom |
365 | 356 i386 memfd_create sys_memfd_create | 365 | 356 i386 memfd_create sys_memfd_create |
366 | 357 i386 bpf sys_bpf | 366 | 357 i386 bpf sys_bpf |
367 | 358 i386 execveat sys_execveat stub32_execveat | ||
diff --git a/arch/x86/syscalls/syscall_64.tbl b/arch/x86/syscalls/syscall_64.tbl index 281150b539a2..8d656fbb57aa 100644 --- a/arch/x86/syscalls/syscall_64.tbl +++ b/arch/x86/syscalls/syscall_64.tbl | |||
@@ -328,6 +328,7 @@ | |||
328 | 319 common memfd_create sys_memfd_create | 328 | 319 common memfd_create sys_memfd_create |
329 | 320 common kexec_file_load sys_kexec_file_load | 329 | 320 common kexec_file_load sys_kexec_file_load |
330 | 321 common bpf sys_bpf | 330 | 321 common bpf sys_bpf |
331 | 322 64 execveat stub_execveat | ||
331 | 332 | ||
332 | # | 333 | # |
333 | # x32-specific system call numbers start at 512 to avoid cache impact | 334 | # x32-specific system call numbers start at 512 to avoid cache impact |
@@ -366,3 +367,4 @@ | |||
366 | 542 x32 getsockopt compat_sys_getsockopt | 367 | 542 x32 getsockopt compat_sys_getsockopt |
367 | 543 x32 io_setup compat_sys_io_setup | 368 | 543 x32 io_setup compat_sys_io_setup |
368 | 544 x32 io_submit compat_sys_io_submit | 369 | 544 x32 io_submit compat_sys_io_submit |
370 | 545 x32 execveat stub_x32_execveat | ||
diff --git a/arch/x86/um/sys_call_table_64.c b/arch/x86/um/sys_call_table_64.c index f2f0723070ca..20c3649d0691 100644 --- a/arch/x86/um/sys_call_table_64.c +++ b/arch/x86/um/sys_call_table_64.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #define stub_fork sys_fork | 31 | #define stub_fork sys_fork |
32 | #define stub_vfork sys_vfork | 32 | #define stub_vfork sys_vfork |
33 | #define stub_execve sys_execve | 33 | #define stub_execve sys_execve |
34 | #define stub_execveat sys_execveat | ||
34 | #define stub_rt_sigreturn sys_rt_sigreturn | 35 | #define stub_rt_sigreturn sys_rt_sigreturn |
35 | 36 | ||
36 | #define __SYSCALL_COMMON(nr, sym, compat) __SYSCALL_64(nr, sym, compat) | 37 | #define __SYSCALL_COMMON(nr, sym, compat) __SYSCALL_64(nr, sym, compat) |