2019-05-28 19:57:20 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2008-07-26 06:45:57 +04:00
|
|
|
/*
|
|
|
|
* Access to user system call parameters and results
|
|
|
|
*
|
2009-09-23 06:56:50 +04:00
|
|
|
* Copyright (C) 2008-2009 Red Hat, Inc. All rights reserved.
|
2008-07-26 06:45:57 +04:00
|
|
|
*
|
|
|
|
* This file is a stub providing documentation for what functions
|
|
|
|
* asm-ARCH/syscall.h files need to define. Most arch definitions
|
|
|
|
* will be simple inlines.
|
|
|
|
*
|
|
|
|
* All of these functions expect to be called with no locks,
|
|
|
|
* and only when the caller is sure that the task of interest
|
|
|
|
* cannot return to user mode while we are looking at it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ASM_SYSCALL_H
|
|
|
|
#define _ASM_SYSCALL_H 1
|
|
|
|
|
|
|
|
struct task_struct;
|
|
|
|
struct pt_regs;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* syscall_get_nr - find what system call a task is executing
|
|
|
|
* @task: task of interest, must be blocked
|
|
|
|
* @regs: task_pt_regs() of @task
|
|
|
|
*
|
|
|
|
* If @task is executing a system call or is at system call
|
|
|
|
* tracing about to attempt one, returns the system call number.
|
|
|
|
* If @task is not executing a system call, i.e. it's blocked
|
|
|
|
* inside the kernel for a fault or signal, returns -1.
|
|
|
|
*
|
2009-09-23 06:56:50 +04:00
|
|
|
* Note this returns int even on 64-bit machines. Only 32 bits of
|
|
|
|
* system call number can be meaningful. If the actual arch value
|
|
|
|
* is 64 bits, this truncates to 32 bits so 0xffffffff means -1.
|
|
|
|
*
|
2008-07-26 06:45:57 +04:00
|
|
|
* It's only valid to call this when @task is known to be blocked.
|
|
|
|
*/
|
2009-09-23 06:56:50 +04:00
|
|
|
int syscall_get_nr(struct task_struct *task, struct pt_regs *regs);
|
2008-07-26 06:45:57 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* syscall_rollback - roll back registers after an aborted system call
|
|
|
|
* @task: task of interest, must be in system call exit tracing
|
|
|
|
* @regs: task_pt_regs() of @task
|
|
|
|
*
|
|
|
|
* It's only valid to call this when @task is stopped for system
|
2020-11-16 20:42:04 +03:00
|
|
|
* call exit tracing (due to %SYSCALL_WORK_SYSCALL_TRACE or
|
2022-01-27 20:46:37 +03:00
|
|
|
* %SYSCALL_WORK_SYSCALL_AUDIT), after ptrace_report_syscall_entry()
|
2020-11-16 20:42:04 +03:00
|
|
|
* returned nonzero to prevent the system call from taking place.
|
2008-07-26 06:45:57 +04:00
|
|
|
*
|
|
|
|
* This rolls back the register state in @regs so it's as if the
|
|
|
|
* system call instruction was a no-op. The registers containing
|
|
|
|
* the system call number and arguments are as they were before the
|
|
|
|
* system call instruction. This may not be the same as what the
|
|
|
|
* register state looked like at system call entry tracing.
|
|
|
|
*/
|
|
|
|
void syscall_rollback(struct task_struct *task, struct pt_regs *regs);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* syscall_get_error - check result of traced system call
|
|
|
|
* @task: task of interest, must be blocked
|
|
|
|
* @regs: task_pt_regs() of @task
|
|
|
|
*
|
|
|
|
* Returns 0 if the system call succeeded, or -ERRORCODE if it failed.
|
|
|
|
*
|
|
|
|
* It's only valid to call this when @task is stopped for tracing on exit
|
2020-11-16 20:42:04 +03:00
|
|
|
* from a system call, due to %SYSCALL_WORK_SYSCALL_TRACE or
|
|
|
|
* %SYSCALL_WORK_SYSCALL_AUDIT.
|
2008-07-26 06:45:57 +04:00
|
|
|
*/
|
|
|
|
long syscall_get_error(struct task_struct *task, struct pt_regs *regs);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* syscall_get_return_value - get the return value of a traced system call
|
|
|
|
* @task: task of interest, must be blocked
|
|
|
|
* @regs: task_pt_regs() of @task
|
|
|
|
*
|
|
|
|
* Returns the return value of the successful system call.
|
|
|
|
* This value is meaningless if syscall_get_error() returned nonzero.
|
|
|
|
*
|
|
|
|
* It's only valid to call this when @task is stopped for tracing on exit
|
2020-11-16 20:42:04 +03:00
|
|
|
* from a system call, due to %SYSCALL_WORK_SYSCALL_TRACE or
|
|
|
|
* %SYSCALL_WORK_SYSCALL_AUDIT.
|
2008-07-26 06:45:57 +04:00
|
|
|
*/
|
|
|
|
long syscall_get_return_value(struct task_struct *task, struct pt_regs *regs);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* syscall_set_return_value - change the return value of a traced system call
|
|
|
|
* @task: task of interest, must be blocked
|
|
|
|
* @regs: task_pt_regs() of @task
|
|
|
|
* @error: negative error code, or zero to indicate success
|
|
|
|
* @val: user return value if @error is zero
|
|
|
|
*
|
|
|
|
* This changes the results of the system call that user mode will see.
|
|
|
|
* If @error is zero, the user sees a successful system call with a
|
|
|
|
* return value of @val. If @error is nonzero, it's a negated errno
|
|
|
|
* code; the user sees a failed system call with this errno code.
|
|
|
|
*
|
|
|
|
* It's only valid to call this when @task is stopped for tracing on exit
|
2020-11-16 20:42:04 +03:00
|
|
|
* from a system call, due to %SYSCALL_WORK_SYSCALL_TRACE or
|
|
|
|
* %SYSCALL_WORK_SYSCALL_AUDIT.
|
2008-07-26 06:45:57 +04:00
|
|
|
*/
|
|
|
|
void syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
|
|
|
|
int error, long val);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* syscall_get_arguments - extract system call parameter values
|
|
|
|
* @task: task of interest, must be blocked
|
|
|
|
* @regs: task_pt_regs() of @task
|
|
|
|
* @args: array filled with argument values
|
|
|
|
*
|
2016-11-08 00:26:37 +03:00
|
|
|
* Fetches 6 arguments to the system call. First argument is stored in
|
|
|
|
* @args[0], and so on.
|
2008-07-26 06:45:57 +04:00
|
|
|
*
|
|
|
|
* It's only valid to call this when @task is stopped for tracing on
|
2020-11-16 20:42:04 +03:00
|
|
|
* entry to a system call, due to %SYSCALL_WORK_SYSCALL_TRACE or
|
|
|
|
* %SYSCALL_WORK_SYSCALL_AUDIT.
|
2008-07-26 06:45:57 +04:00
|
|
|
*/
|
|
|
|
void syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
|
2016-11-08 00:26:37 +03:00
|
|
|
unsigned long *args);
|
2008-07-26 06:45:57 +04:00
|
|
|
|
2012-04-13 01:47:55 +04:00
|
|
|
/**
|
|
|
|
* syscall_get_arch - return the AUDIT_ARCH for the current system call
|
2019-03-18 02:30:18 +03:00
|
|
|
* @task: task of interest, must be blocked
|
2012-04-13 01:47:55 +04:00
|
|
|
*
|
|
|
|
* Returns the AUDIT_ARCH_* based on the system call convention in use.
|
|
|
|
*
|
2019-03-18 02:30:18 +03:00
|
|
|
* It's only valid to call this when @task is stopped on entry to a system
|
2020-11-16 20:42:04 +03:00
|
|
|
* call, due to %SYSCALL_WORK_SYSCALL_TRACE, %SYSCALL_WORK_SYSCALL_AUDIT, or
|
2020-11-16 20:42:02 +03:00
|
|
|
* %SYSCALL_WORK_SECCOMP.
|
2012-04-13 01:47:55 +04:00
|
|
|
*
|
|
|
|
* Architectures which permit CONFIG_HAVE_ARCH_SECCOMP_FILTER must
|
|
|
|
* provide an implementation of this.
|
|
|
|
*/
|
2019-03-18 02:30:18 +03:00
|
|
|
int syscall_get_arch(struct task_struct *task);
|
2008-07-26 06:45:57 +04:00
|
|
|
#endif /* _ASM_SYSCALL_H */
|