path: root/arch/s390/include/asm/syscall.h
AgeCommit message (Collapse)AuthorLines
2020-06-17s390: fix syscall_get_error for compat processesDmitry V. Levin-1/+11
If both the tracer and the tracee are compat processes, and gprs[2] is assigned a value by __poke_user_compat, then the higher 32 bits of gprs[2] are cleared, IS_ERR_VALUE() always returns false, and syscall_get_error() always returns 0. Fix the implementation by sign-extending the value for compat processes the same way as x86 implementation does. The bug was exposed to user space by commit 201766a20e30f ("ptrace: add PTRACE_GET_SYSCALL_INFO request") and detected by strace test suite. This change fixes strace syscall tampering on s390. Link: Fixes: 753c4dd6a2fa2 ("[S390] ptrace changes") Cc: Elvira Khabirova <> Cc: # v2.6.28+ Signed-off-by: Dmitry V. Levin <> Signed-off-by: Heiko Carstens <> Signed-off-by: Vasily Gorbik <>
2019-05-07Merge tag 'audit-pr-20190507' of ↵Linus Torvalds-2/+2
git:// Pull audit updates from Paul Moore: "We've got a reasonably broad set of audit patches for the v5.2 merge window, the highlights are below: - The biggest change, and the source of all the arch/* changes, is the patchset from Dmitry to help enable some of the work he is doing around PTRACE_GET_SYSCALL_INFO. To be honest, including this in the audit tree is a bit of a stretch, but it does help move audit a little further along towards proper syscall auditing for all arches, and everyone else seemed to agree that audit was a "good" spot for this to land (or maybe they just didn't want to merge it? dunno.). - We can now audit time/NTP adjustments. - We continue the work to connect associated audit records into a single event" * tag 'audit-pr-20190507' of git:// (21 commits) audit: fix a memory leak bug ntp: Audit NTP parameters adjustment timekeeping: Audit clock adjustments audit: purge unnecessary list_empty calls audit: link integrity evm_write_xattrs record to syscall event syscall_get_arch: add "struct task_struct *" argument unicore32: define syscall_get_arch() Move EM_UNICORE to uapi/linux/elf-em.h nios2: define syscall_get_arch() nds32: define syscall_get_arch() Move EM_NDS32 to uapi/linux/elf-em.h m68k: define syscall_get_arch() hexagon: define syscall_get_arch() Move EM_HEXAGON to uapi/linux/elf-em.h h8300: define syscall_get_arch() c6x: define syscall_get_arch() arc: define syscall_get_arch() Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h audit: Make audit_log_cap and audit_copy_inode static audit: connect LOGIN record to its syscall record ...
2019-05-06Merge tag 's390-5.2-1' of ↵Linus Torvalds-7/+2
git:// Pull s390 updates from Martin Schwidefsky: - Support for kernel address space layout randomization - Add support for kernel image signature verification - Convert s390 to the generic get_user_pages_fast code - Convert s390 to the stack unwind API analog to x86 - Add support for CPU directed interrupts for PCI devices - Provide support for MIO instructions to the PCI base layer, this will allow the use of direct PCI mappings in user space code - Add the basic KVM guest ultravisor interface for protected VMs - Add AT_HWCAP bits for several new hardware capabilities - Update the CPU measurement facility counter definitions to SVN 6 - Arnds cleanup patches for his quest to get LLVM compiles working - A vfio-ccw update with bug fixes and support for halt and clear - Improvements for the hardware TRNG code - Another round of cleanup for the QDIO layer - Numerous cleanups and bug fixes * tag 's390-5.2-1' of git:// (98 commits) s390/vdso: drop unnecessary cc-ldoption s390: fix clang -Wpointer-sign warnigns in boot code s390: drop CONFIG_VIRT_TO_BUS s390: boot, purgatory: pass $(CLANG_FLAGS) where needed s390: only build for new CPUs with clang s390: simplify disabled_wait s390/ftrace: use HAVE_FUNCTION_GRAPH_RET_ADDR_PTR s390/unwind: introduce stack unwind API s390/opcodes: add missing instructions to the disassembler s390/bug: add entry size to the __bug_table section s390: use proper expoline sections for .dma code s390/nospec: rename assembler generated expoline thunks s390: add missing ENDPROC statements to assembler functions locking/lockdep: check for freed initmem in static_obj() s390/kernel: add support for kernel address space layout randomization (KASLR) s390/kernel: introduce .dma sections s390/sclp: do not use static sccbs s390/kprobes: use static buffer for insn_page s390/kernel: convert SYSCALL and PGM_CHECK handlers to .quad s390/kernel: build a relocatable kernel ...
2019-04-29s390/kernel: convert SYSCALL and PGM_CHECK handlers to .quadGerald Schaefer-7/+2
With a relocatable kernel that could reside at any place in memory, the storage size for the SYSCALL and PGM_CHECK handlers needs to be increased from .long to .quad. Signed-off-by: Gerald Schaefer <> Reviewed-by: Philipp Rudo <> Signed-off-by: Martin Schwidefsky <>
2019-04-05syscalls: Remove start and number from syscall_set_arguments() argsSteven Rostedt (VMware)-6/+5
After removing the start and count arguments of syscall_get_arguments() it seems reasonable to remove them from syscall_set_arguments(). Note, as of today, there are no users of syscall_set_arguments(). But we are told that there will be soon. But for now, at least make it consistent with syscall_get_arguments(). Link: Cc: Oleg Nesterov <> Cc: Kees Cook <> Cc: Andy Lutomirski <> Cc: Dominik Brodowski <> Cc: Dave Martin <> Cc: "Dmitry V. Levin" <> Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Acked-by: Max Filippov <> # For xtensa changes Acked-by: Will Deacon <> # For the arm64 bits Reviewed-by: Thomas Gleixner <> # for x86 Reviewed-by: Dmitry V. Levin <> Signed-off-by: Steven Rostedt (VMware) <>
2019-04-05syscalls: Remove start and number from syscall_get_arguments() argsSteven Rostedt (Red Hat)-12/+5
At Linux Plumbers, Andy Lutomirski approached me and pointed out that the function call syscall_get_arguments() implemented in x86 was horribly written and not optimized for the standard case of passing in 0 and 6 for the starting index and the number of system calls to get. When looking at all the users of this function, I discovered that all instances pass in only 0 and 6 for these arguments. Instead of having this function handle different cases that are never used, simply rewrite it to return the first 6 arguments of a system call. This should help out the performance of tracing system calls by ptrace, ftrace and perf. Link: Cc: Oleg Nesterov <> Cc: Kees Cook <> Cc: Andy Lutomirski <> Cc: Dominik Brodowski <> Cc: Dave Martin <> Cc: "Dmitry V. Levin" <> Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Acked-by: Paul Burton <> # MIPS parts Acked-by: Max Filippov <> # For xtensa changes Acked-by: Will Deacon <> # For the arm64 bits Reviewed-by: Thomas Gleixner <> # for x86 Reviewed-by: Dmitry V. Levin <> Reported-by: Andy Lutomirski <> Signed-off-by: Steven Rostedt (VMware) <>
2019-03-20syscall_get_arch: add "struct task_struct *" argumentDmitry V. Levin-2/+2
This argument is required to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request: syscall_get_arch() is going to be called from ptrace_request() along with syscall_get_nr(), syscall_get_arguments(), syscall_get_error(), and syscall_get_return_value() functions with a tracee as their argument. The primary intent is that the triple (audit_arch, syscall_nr, arg1..arg6) should describe what system call is being called and what its arguments are. Reverts: 5e937a9ae913 ("syscall_get_arch: remove useless function arguments") Reverts: 1002d94d3076 ("syscall.h: fix doc text for syscall_get_arch()") Reviewed-by: Andy Lutomirski <> # for x86 Reviewed-by: Palmer Dabbelt <> Acked-by: Paul Moore <> Acked-by: Paul Burton <> # MIPS parts Acked-by: Michael Ellerman <> (powerpc) Acked-by: Kees Cook <> # seccomp parts Acked-by: Mark Salter <> # for the c6x bit Cc: Elvira Khabirova <> Cc: Eugene Syromyatnikov <> Cc: Oleg Nesterov <> Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Signed-off-by: Dmitry V. Levin <> Signed-off-by: Paul Moore <>
2017-11-24s390: include: Remove redundant license textGreg Kroah-Hartman-4/+0
Now that the SPDX tag is in all arch/s390/include/ files, that identifies the license in a specific and legally-defined manner. So the extra GPL text wording can be removed as it is no longer needed at all. This is done on a quest to remove the 700+ different ways that files in the kernel describe the GPL license text. And there's unneeded stuff like the address (sometimes incorrect) for the FSF which is never needed. No copyright headers or other non-license-description text was removed. Cc: Martin Schwidefsky <> Cc: Heiko Carstens <> Cc: Christian Borntraeger <> Cc: Cornelia Huck <> Cc: Halil Pasic <> Cc: "Paul E. McKenney" <> Signed-off-by: Greg Kroah-Hartman <> Signed-off-by: Martin Schwidefsky <>
2017-11-24s390: add SPDX identifiers to the remaining filesGreg Kroah-Hartman-0/+1
It's good to have SPDX identifiers in all files to make it easier to audit the kernel tree for correct licenses. Update the remaining arch/s390/ files with the correct SPDX license identifier based on the license text in the file itself. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. This work is based on a script and data from Thomas Gleixner, Philippe Ombredanne, and Kate Stewart. Cc: Martin Schwidefsky <> Cc: Heiko Carstens <> Cc: Christian Borntraeger <> Cc: Cornelia Huck <> Cc: Thomas Gleixner <> Cc: Kate Stewart <> Cc: Philippe Ombredanne <> Signed-off-by: Greg Kroah-Hartman <> Signed-off-by: Martin Schwidefsky <>
2017-07-05s390/syscalls: Fix out of bounds arguments accessJiri Olsa-0/+6
Zorro reported following crash while having enabled syscall tracing (CONFIG_FTRACE_SYSCALLS): Unable to handle kernel pointer dereference at virtual ... Oops: 0011 [#1] SMP DEBUG_PAGEALLOC SNIP Call Trace: ([<000000000024d79c>] ftrace_syscall_enter+0xec/0x1d8) [<00000000001099c6>] do_syscall_trace_enter+0x236/0x2f8 [<0000000000730f1c>] sysc_tracesys+0x1a/0x32 [<000003fffcf946a2>] 0x3fffcf946a2 INFO: lockdep is turned off. Last Breaking-Event-Address: [<000000000022dd44>] rb_event_data+0x34/0x40 ---[ end trace 8c795f86b1b3f7b9 ]--- The crash happens in syscall_get_arguments function for syscalls with zero arguments, that will try to access first argument (args[0]) in event entry, but it's not allocated. Bail out of there are no arguments. Cc: Reported-by: Zorro Lang <> Signed-off-by: Jiri Olsa <> Signed-off-by: Martin Schwidefsky <>
2015-03-30s390/syscalls: simplify syscall_get_arch()Heiko Carstens-1/+1
Given that sizeof(long) is now always 8, we can simplify syscall_get_arch() a bit. Just another piece I didn't find when removing 31 bit support. Signed-off-by: Heiko Carstens <> Signed-off-by: Martin Schwidefsky <>
2014-07-28s390/seccomp: fix error return for filtered system callsJan Willeke-1/+1
The syscall_set_return_value function of s390 negates the error argument before storing the value to the return register gpr2. This is incorrect, the seccomp code already passes the negative error value. Store the unmodified error value to gpr2. Signed-off-by: Jan Willeke <> Signed-off-by: Martin Schwidefsky <>
2014-05-20s390: split TIF bits into CIF, PIF and TIF bitsMartin Schwidefsky-1/+1
The oi and ni instructions used in entry[64].S to set and clear bits in the thread-flags are not guaranteed to be atomic in regard to other CPUs. Split the TIF bits into CPU, pt_regs and thread-info specific bits. Updates on the TIF bits are done with atomic instructions, updates on CPU and pt_regs bits are done with non-atomic instructions. Signed-off-by: Martin Schwidefsky <>
2014-03-20audit: use uapi/linux/audit.h for AUDIT_ARCH declarationsEric Paris-1/+1
The syscall.h headers were including linux/audit.h but really only needed the uapi/linux/audit.h to get the requisite defines. Switch to the uapi headers. Signed-off-by: Eric Paris <> Cc: Cc: Cc: Cc:
2014-03-20syscall_get_arch: remove useless function argumentsEric Paris-3/+2
Every caller of syscall_get_arch() uses current for the task and no implementors of the function need args. So just get rid of both of those things. Admittedly, since these are inline functions we aren't wasting stack space, but it just makes the prototypes better. Signed-off-by: Eric Paris <> Cc: Cc: Cc: Cc: Cc: Cc: Cc:
2013-04-26s390: system call path micro optimizationMartin Schwidefsky-0/+1
Add a pointer to the system call table to the thread_info structure. The TIF_31BIT bit is set or cleared by SET_PERSONALITY exactly once for the lifetime of a process. With the pointer to the correct system call table in thread_info the system call code in entry64.S path can drop the check for TIF_31BIT which saves a couple of instructions. Signed-off-by: Martin Schwidefsky <>
2012-08-08s390/seccomp: add support for system call filtering using BPFHeiko Carstens-0/+10
Signed-off-by: Heiko Carstens <> Signed-off-by: Martin Schwidefsky <>
2011-12-27[S390] cleanup trap handlingMartin Schwidefsky-1/+1
Move the program interruption code and the translation exception identifier to the pt_regs structure as 'int_code' and 'int_parm_long' and make the first level interrupt handler in entry[64].S store the two values. That makes it possible to drop 'prot_addr' and 'trap_no' from the thread_struct and to reduce the number of arguments to a lot of functions. Finally un-inline do_trap. Overall this saves 5812 bytes in the .text section of the 64 bit kernel. Signed-off-by: Martin Schwidefsky <>
2011-10-30[S390] add TIF_SYSCALL thread flagMartin Schwidefsky-1/+2
Add an explicit TIF_SYSCALL bit that indicates if a task is inside a system call. The svc_code in the pt_regs structure is now only valid if TIF_SYSCALL is set. With this definition TIF_RESTART_SVC can be replaced with TIF_SYSCALL. Overall do_signal is a bit more readable and it saves a few lines of code. Signed-off-by: Martin Schwidefsky <>
2011-10-30[S390] signal race with restarting system callsMartin Schwidefsky-2/+3
For a ERESTARTNOHAND/ERESTARTSYS/ERESTARTNOINTR restarting system call do_signal will prepare the restart of the system call with a rewind of the PSW before calling get_signal_to_deliver (where the debugger might take control). For A ERESTART_RESTARTBLOCK restarting system call do_signal will set -EINTR as return code. There are two issues with this approach: 1) strace never sees ERESTARTNOHAND, ERESTARTSYS, ERESTARTNOINTR or ERESTART_RESTARTBLOCK as the rewinding already took place or the return code has been changed to -EINTR 2) if get_signal_to_deliver does not return with a signal to deliver the restart via the repeat of the svc instruction is left in place. This opens a race if another signal is made pending before the system call instruction can be reexecuted. The original system call will be restarted even if the second signal would have ended the system call with -EINTR. These two issues can be solved by dropping the early rewind of the system call before get_signal_to_deliver has been called and by using the TIF_RESTART_SVC magic to do the restart if no signal has to be delivered. The only situation where the system call restart via the repeat of the svc instruction is appropriate is when a SA_RESTART signal is delivered to user space. Unfortunately this breaks inferior calls by the debugger again. The system call number and the length of the system call instruction is lost over the inferior call and user space will see ERESTARTNOHAND/ ERESTARTSYS/ERESTARTNOINTR/ERESTART_RESTARTBLOCK. To correct this a new ptrace interface is added to save/restore the system call number and system call instruction length. Signed-off-by: Martin Schwidefsky <>
2010-10-25[S390] cleanup system call parameter setupMartin Schwidefsky-4/+0
Do the setup of the stack overflow argument for the sixth system call parameter right before the branch to the system call function. That simplifies the system call parameter access code. Signed-off-by: Martin Schwidefsky <>
2010-02-17tracing: Unify arch_syscall_addr() implementationsMike Frysinger-0/+7
Most implementations of arch_syscall_addr() are the same, so create a default version in common code and move the one piece that differs (the syscall table) to asm/syscall.h. New arch ports don't have to waste time copying & pasting this simple function. The s390/sparc versions need to be different, so document why. Signed-off-by: Mike Frysinger <> Acked-by: David S. Miller <> Acked-by: Paul Mundt <> Acked-by: Heiko Carstens <> Cc: Steven Rostedt <> LKML-Reference: <> Signed-off-by: Frederic Weisbecker <>
2009-06-12[S390] ftrace: add system call tracer supportHeiko Carstens-0/+1
System call tracer support for s390. Signed-off-by: Heiko Carstens <> Signed-off-by: Martin Schwidefsky <>
2008-11-27[S390] fix system call parameter functions.Martin Schwidefsky-12/+16
syscall_get_nr() currently returns a valid result only if the call chain of the traced process includes do_syscall_trace_enter(). But collect_syscall() can be called for any sleeping task, the result of syscall_get_nr() in general is completely bogus. To make syscall_get_nr() work for any sleeping task the traps field in pt_regs is replace with svcnr - the system call number the process is executing. If svcnr == 0 the process is not on a system call path. The syscall_get_arguments and syscall_set_arguments use regs->gprs[2] for the first system call parameter. This is incorrect since gprs[2] may have been overwritten with the system call number if the call chain includes do_syscall_trace_enter. Use regs->orig_gprs2 instead. Signed-off-by: Martin Schwidefsky <>
2008-10-10[S390] ptrace changesMartin Schwidefsky-0/+80
* System call parameter and result access functions * Add tracehook calls * Split syscall_trace into two functions do_syscall_trace_enter and do_syscall_trace_exit Signed-off-by: Martin Schwidefsky <>