![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only */ 0002 /* 0003 * Access to user system call parameters and results 0004 * 0005 * Copyright (C) 2008-2009 Red Hat, Inc. All rights reserved. 0006 * 0007 * This file is a stub providing documentation for what functions 0008 * asm-ARCH/syscall.h files need to define. Most arch definitions 0009 * will be simple inlines. 0010 * 0011 * All of these functions expect to be called with no locks, 0012 * and only when the caller is sure that the task of interest 0013 * cannot return to user mode while we are looking at it. 0014 */ 0015 0016 #ifndef _ASM_SYSCALL_H 0017 #define _ASM_SYSCALL_H 1 0018 0019 struct task_struct; 0020 struct pt_regs; 0021 0022 /** 0023 * syscall_get_nr - find what system call a task is executing 0024 * @task: task of interest, must be blocked 0025 * @regs: task_pt_regs() of @task 0026 * 0027 * If @task is executing a system call or is at system call 0028 * tracing about to attempt one, returns the system call number. 0029 * If @task is not executing a system call, i.e. it's blocked 0030 * inside the kernel for a fault or signal, returns -1. 0031 * 0032 * Note this returns int even on 64-bit machines. Only 32 bits of 0033 * system call number can be meaningful. If the actual arch value 0034 * is 64 bits, this truncates to 32 bits so 0xffffffff means -1. 0035 * 0036 * It's only valid to call this when @task is known to be blocked. 0037 */ 0038 int syscall_get_nr(struct task_struct *task, struct pt_regs *regs); 0039 0040 /** 0041 * syscall_rollback - roll back registers after an aborted system call 0042 * @task: task of interest, must be in system call exit tracing 0043 * @regs: task_pt_regs() of @task 0044 * 0045 * It's only valid to call this when @task is stopped for system 0046 * call exit tracing (due to %SYSCALL_WORK_SYSCALL_TRACE or 0047 * %SYSCALL_WORK_SYSCALL_AUDIT), after ptrace_report_syscall_entry() 0048 * returned nonzero to prevent the system call from taking place. 0049 * 0050 * This rolls back the register state in @regs so it's as if the 0051 * system call instruction was a no-op. The registers containing 0052 * the system call number and arguments are as they were before the 0053 * system call instruction. This may not be the same as what the 0054 * register state looked like at system call entry tracing. 0055 */ 0056 void syscall_rollback(struct task_struct *task, struct pt_regs *regs); 0057 0058 /** 0059 * syscall_get_error - check result of traced system call 0060 * @task: task of interest, must be blocked 0061 * @regs: task_pt_regs() of @task 0062 * 0063 * Returns 0 if the system call succeeded, or -ERRORCODE if it failed. 0064 * 0065 * It's only valid to call this when @task is stopped for tracing on exit 0066 * from a system call, due to %SYSCALL_WORK_SYSCALL_TRACE or 0067 * %SYSCALL_WORK_SYSCALL_AUDIT. 0068 */ 0069 long syscall_get_error(struct task_struct *task, struct pt_regs *regs); 0070 0071 /** 0072 * syscall_get_return_value - get the return value of a traced system call 0073 * @task: task of interest, must be blocked 0074 * @regs: task_pt_regs() of @task 0075 * 0076 * Returns the return value of the successful system call. 0077 * This value is meaningless if syscall_get_error() returned nonzero. 0078 * 0079 * It's only valid to call this when @task is stopped for tracing on exit 0080 * from a system call, due to %SYSCALL_WORK_SYSCALL_TRACE or 0081 * %SYSCALL_WORK_SYSCALL_AUDIT. 0082 */ 0083 long syscall_get_return_value(struct task_struct *task, struct pt_regs *regs); 0084 0085 /** 0086 * syscall_set_return_value - change the return value of a traced system call 0087 * @task: task of interest, must be blocked 0088 * @regs: task_pt_regs() of @task 0089 * @error: negative error code, or zero to indicate success 0090 * @val: user return value if @error is zero 0091 * 0092 * This changes the results of the system call that user mode will see. 0093 * If @error is zero, the user sees a successful system call with a 0094 * return value of @val. If @error is nonzero, it's a negated errno 0095 * code; the user sees a failed system call with this errno code. 0096 * 0097 * It's only valid to call this when @task is stopped for tracing on exit 0098 * from a system call, due to %SYSCALL_WORK_SYSCALL_TRACE or 0099 * %SYSCALL_WORK_SYSCALL_AUDIT. 0100 */ 0101 void syscall_set_return_value(struct task_struct *task, struct pt_regs *regs, 0102 int error, long val); 0103 0104 /** 0105 * syscall_get_arguments - extract system call parameter values 0106 * @task: task of interest, must be blocked 0107 * @regs: task_pt_regs() of @task 0108 * @args: array filled with argument values 0109 * 0110 * Fetches 6 arguments to the system call. First argument is stored in 0111 * @args[0], and so on. 0112 * 0113 * It's only valid to call this when @task is stopped for tracing on 0114 * entry to a system call, due to %SYSCALL_WORK_SYSCALL_TRACE or 0115 * %SYSCALL_WORK_SYSCALL_AUDIT. 0116 */ 0117 void syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, 0118 unsigned long *args); 0119 0120 /** 0121 * syscall_get_arch - return the AUDIT_ARCH for the current system call 0122 * @task: task of interest, must be blocked 0123 * 0124 * Returns the AUDIT_ARCH_* based on the system call convention in use. 0125 * 0126 * It's only valid to call this when @task is stopped on entry to a system 0127 * call, due to %SYSCALL_WORK_SYSCALL_TRACE, %SYSCALL_WORK_SYSCALL_AUDIT, or 0128 * %SYSCALL_WORK_SECCOMP. 0129 * 0130 * Architectures which permit CONFIG_HAVE_ARCH_SECCOMP_FILTER must 0131 * provide an implementation of this. 0132 */ 0133 int syscall_get_arch(struct task_struct *task); 0134 #endif /* _ASM_SYSCALL_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |