Linux Audio

Check our new training course

Loading...
v6.13.7
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Access to user system call parameters and results
  4 *
  5 * Copyright (C) 2008-2009 Red Hat, Inc.  All rights reserved.
  6 *
 
 
 
 
  7 * This file is a stub providing documentation for what functions
  8 * asm-ARCH/syscall.h files need to define.  Most arch definitions
  9 * will be simple inlines.
 10 *
 11 * All of these functions expect to be called with no locks,
 12 * and only when the caller is sure that the task of interest
 13 * cannot return to user mode while we are looking at it.
 14 */
 15
 16#ifndef _ASM_SYSCALL_H
 17#define _ASM_SYSCALL_H	1
 18
 19struct task_struct;
 20struct pt_regs;
 21
 22/**
 23 * syscall_get_nr - find what system call a task is executing
 24 * @task:	task of interest, must be blocked
 25 * @regs:	task_pt_regs() of @task
 26 *
 27 * If @task is executing a system call or is at system call
 28 * tracing about to attempt one, returns the system call number.
 29 * If @task is not executing a system call, i.e. it's blocked
 30 * inside the kernel for a fault or signal, returns -1.
 31 *
 32 * Note this returns int even on 64-bit machines.  Only 32 bits of
 33 * system call number can be meaningful.  If the actual arch value
 34 * is 64 bits, this truncates to 32 bits so 0xffffffff means -1.
 35 *
 36 * It's only valid to call this when @task is known to be blocked.
 37 */
 38int syscall_get_nr(struct task_struct *task, struct pt_regs *regs);
 39
 40/**
 41 * syscall_rollback - roll back registers after an aborted system call
 42 * @task:	task of interest, must be in system call exit tracing
 43 * @regs:	task_pt_regs() of @task
 44 *
 45 * It's only valid to call this when @task is stopped for system
 46 * call exit tracing (due to %SYSCALL_WORK_SYSCALL_TRACE or
 47 * %SYSCALL_WORK_SYSCALL_AUDIT), after ptrace_report_syscall_entry()
 48 * returned nonzero to prevent the system call from taking place.
 49 *
 50 * This rolls back the register state in @regs so it's as if the
 51 * system call instruction was a no-op.  The registers containing
 52 * the system call number and arguments are as they were before the
 53 * system call instruction.  This may not be the same as what the
 54 * register state looked like at system call entry tracing.
 55 */
 56void syscall_rollback(struct task_struct *task, struct pt_regs *regs);
 57
 58/**
 59 * syscall_get_error - check result of traced system call
 60 * @task:	task of interest, must be blocked
 61 * @regs:	task_pt_regs() of @task
 62 *
 63 * Returns 0 if the system call succeeded, or -ERRORCODE if it failed.
 64 *
 65 * It's only valid to call this when @task is stopped for tracing on exit
 66 * from a system call, due to %SYSCALL_WORK_SYSCALL_TRACE or
 67 * %SYSCALL_WORK_SYSCALL_AUDIT.
 68 */
 69long syscall_get_error(struct task_struct *task, struct pt_regs *regs);
 70
 71/**
 72 * syscall_get_return_value - get the return value of a traced system call
 73 * @task:	task of interest, must be blocked
 74 * @regs:	task_pt_regs() of @task
 75 *
 76 * Returns the return value of the successful system call.
 77 * This value is meaningless if syscall_get_error() returned nonzero.
 78 *
 79 * It's only valid to call this when @task is stopped for tracing on exit
 80 * from a system call, due to %SYSCALL_WORK_SYSCALL_TRACE or
 81 * %SYSCALL_WORK_SYSCALL_AUDIT.
 82 */
 83long syscall_get_return_value(struct task_struct *task, struct pt_regs *regs);
 84
 85/**
 86 * syscall_set_return_value - change the return value of a traced system call
 87 * @task:	task of interest, must be blocked
 88 * @regs:	task_pt_regs() of @task
 89 * @error:	negative error code, or zero to indicate success
 90 * @val:	user return value if @error is zero
 91 *
 92 * This changes the results of the system call that user mode will see.
 93 * If @error is zero, the user sees a successful system call with a
 94 * return value of @val.  If @error is nonzero, it's a negated errno
 95 * code; the user sees a failed system call with this errno code.
 96 *
 97 * It's only valid to call this when @task is stopped for tracing on exit
 98 * from a system call, due to %SYSCALL_WORK_SYSCALL_TRACE or
 99 * %SYSCALL_WORK_SYSCALL_AUDIT.
100 */
101void syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
102			      int error, long val);
103
104/**
105 * syscall_get_arguments - extract system call parameter values
106 * @task:	task of interest, must be blocked
107 * @regs:	task_pt_regs() of @task
 
 
108 * @args:	array filled with argument values
109 *
110 * Fetches 6 arguments to the system call.  First argument is stored in
111*  @args[0], and so on.
 
112 *
113 * It's only valid to call this when @task is stopped for tracing on
114 * entry to a system call, due to %SYSCALL_WORK_SYSCALL_TRACE or
115 * %SYSCALL_WORK_SYSCALL_AUDIT.
 
116 */
117void syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
118			   unsigned long *args);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
120/**
121 * syscall_get_arch - return the AUDIT_ARCH for the current system call
122 * @task:	task of interest, must be blocked
123 *
124 * Returns the AUDIT_ARCH_* based on the system call convention in use.
125 *
126 * It's only valid to call this when @task is stopped on entry to a system
127 * call, due to %SYSCALL_WORK_SYSCALL_TRACE, %SYSCALL_WORK_SYSCALL_AUDIT, or
128 * %SYSCALL_WORK_SECCOMP.
129 *
130 * Architectures which permit CONFIG_HAVE_ARCH_SECCOMP_FILTER must
131 * provide an implementation of this.
132 */
133int syscall_get_arch(struct task_struct *task);
134#endif	/* _ASM_SYSCALL_H */
v3.15
 
  1/*
  2 * Access to user system call parameters and results
  3 *
  4 * Copyright (C) 2008-2009 Red Hat, Inc.  All rights reserved.
  5 *
  6 * This copyrighted material is made available to anyone wishing to use,
  7 * modify, copy, or redistribute it subject to the terms and conditions
  8 * of the GNU General Public License v.2.
  9 *
 10 * This file is a stub providing documentation for what functions
 11 * asm-ARCH/syscall.h files need to define.  Most arch definitions
 12 * will be simple inlines.
 13 *
 14 * All of these functions expect to be called with no locks,
 15 * and only when the caller is sure that the task of interest
 16 * cannot return to user mode while we are looking at it.
 17 */
 18
 19#ifndef _ASM_SYSCALL_H
 20#define _ASM_SYSCALL_H	1
 21
 22struct task_struct;
 23struct pt_regs;
 24
 25/**
 26 * syscall_get_nr - find what system call a task is executing
 27 * @task:	task of interest, must be blocked
 28 * @regs:	task_pt_regs() of @task
 29 *
 30 * If @task is executing a system call or is at system call
 31 * tracing about to attempt one, returns the system call number.
 32 * If @task is not executing a system call, i.e. it's blocked
 33 * inside the kernel for a fault or signal, returns -1.
 34 *
 35 * Note this returns int even on 64-bit machines.  Only 32 bits of
 36 * system call number can be meaningful.  If the actual arch value
 37 * is 64 bits, this truncates to 32 bits so 0xffffffff means -1.
 38 *
 39 * It's only valid to call this when @task is known to be blocked.
 40 */
 41int syscall_get_nr(struct task_struct *task, struct pt_regs *regs);
 42
 43/**
 44 * syscall_rollback - roll back registers after an aborted system call
 45 * @task:	task of interest, must be in system call exit tracing
 46 * @regs:	task_pt_regs() of @task
 47 *
 48 * It's only valid to call this when @task is stopped for system
 49 * call exit tracing (due to TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT),
 50 * after tracehook_report_syscall_entry() returned nonzero to prevent
 51 * the system call from taking place.
 52 *
 53 * This rolls back the register state in @regs so it's as if the
 54 * system call instruction was a no-op.  The registers containing
 55 * the system call number and arguments are as they were before the
 56 * system call instruction.  This may not be the same as what the
 57 * register state looked like at system call entry tracing.
 58 */
 59void syscall_rollback(struct task_struct *task, struct pt_regs *regs);
 60
 61/**
 62 * syscall_get_error - check result of traced system call
 63 * @task:	task of interest, must be blocked
 64 * @regs:	task_pt_regs() of @task
 65 *
 66 * Returns 0 if the system call succeeded, or -ERRORCODE if it failed.
 67 *
 68 * It's only valid to call this when @task is stopped for tracing on exit
 69 * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
 
 70 */
 71long syscall_get_error(struct task_struct *task, struct pt_regs *regs);
 72
 73/**
 74 * syscall_get_return_value - get the return value of a traced system call
 75 * @task:	task of interest, must be blocked
 76 * @regs:	task_pt_regs() of @task
 77 *
 78 * Returns the return value of the successful system call.
 79 * This value is meaningless if syscall_get_error() returned nonzero.
 80 *
 81 * It's only valid to call this when @task is stopped for tracing on exit
 82 * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
 
 83 */
 84long syscall_get_return_value(struct task_struct *task, struct pt_regs *regs);
 85
 86/**
 87 * syscall_set_return_value - change the return value of a traced system call
 88 * @task:	task of interest, must be blocked
 89 * @regs:	task_pt_regs() of @task
 90 * @error:	negative error code, or zero to indicate success
 91 * @val:	user return value if @error is zero
 92 *
 93 * This changes the results of the system call that user mode will see.
 94 * If @error is zero, the user sees a successful system call with a
 95 * return value of @val.  If @error is nonzero, it's a negated errno
 96 * code; the user sees a failed system call with this errno code.
 97 *
 98 * It's only valid to call this when @task is stopped for tracing on exit
 99 * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
 
100 */
101void syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
102			      int error, long val);
103
104/**
105 * syscall_get_arguments - extract system call parameter values
106 * @task:	task of interest, must be blocked
107 * @regs:	task_pt_regs() of @task
108 * @i:		argument index [0,5]
109 * @n:		number of arguments; n+i must be [1,6].
110 * @args:	array filled with argument values
111 *
112 * Fetches @n arguments to the system call starting with the @i'th argument
113 * (from 0 through 5).  Argument @i is stored in @args[0], and so on.
114 * An arch inline version is probably optimal when @i and @n are constants.
115 *
116 * It's only valid to call this when @task is stopped for tracing on
117 * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
118 * It's invalid to call this with @i + @n > 6; we only support system calls
119 * taking up to 6 arguments.
120 */
121void syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
122			   unsigned int i, unsigned int n, unsigned long *args);
123
124/**
125 * syscall_set_arguments - change system call parameter value
126 * @task:	task of interest, must be in system call entry tracing
127 * @regs:	task_pt_regs() of @task
128 * @i:		argument index [0,5]
129 * @n:		number of arguments; n+i must be [1,6].
130 * @args:	array of argument values to store
131 *
132 * Changes @n arguments to the system call starting with the @i'th argument.
133 * Argument @i gets value @args[0], and so on.
134 * An arch inline version is probably optimal when @i and @n are constants.
135 *
136 * It's only valid to call this when @task is stopped for tracing on
137 * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
138 * It's invalid to call this with @i + @n > 6; we only support system calls
139 * taking up to 6 arguments.
140 */
141void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
142			   unsigned int i, unsigned int n,
143			   const unsigned long *args);
144
145/**
146 * syscall_get_arch - return the AUDIT_ARCH for the current system call
 
147 *
148 * Returns the AUDIT_ARCH_* based on the system call convention in use.
149 *
150 * It's only valid to call this when @task is stopped on entry to a system
151 * call, due to %TIF_SYSCALL_TRACE, %TIF_SYSCALL_AUDIT, or %TIF_SECCOMP.
 
152 *
153 * Architectures which permit CONFIG_HAVE_ARCH_SECCOMP_FILTER must
154 * provide an implementation of this.
155 */
156int syscall_get_arch(void);
157#endif	/* _ASM_SYSCALL_H */