kernel/bpf/sys_call.c:127:34: error: no member named 'mode' in 'struct seccomp'
kernel test robot
build bottree: https://github.com/kkdwivedi/linux sys-ext head: 79d84dbb504831f04e5d82b21db272463339a59d commit: b261415512b693cb1b56af55aa2c4790d2b98c6a [53/54] bpf: Let a syscall program make system calls for its process's threads config: um-randconfig-2001-20261129 (https://download.01.org/0day-ci/archive/20261129/[email protected]/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261129/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> kernel/bpf/sys_call.c:127:34: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
49 | compiletime_assert_rwonce_type(x); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 | "Unsupported access size for {READ,WRITE}_ONCE().")
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:663:10: note: expanded from macro '__native_word'
663 | (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
| ^
include/linux/compiler_types.h:702:22: note: expanded from macro 'compiletime_assert'
702 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:690:23: note: expanded from macro '_compiletime_assert'
690 | __compiletime_assert(condition, msg, prefix, suffix)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:682:9: note: expanded from macro '__compiletime_assert'
682 | if (!(condition)) \
| ^~~~~~~~~
>> kernel/bpf/sys_call.c:127:34: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
49 | compiletime_assert_rwonce_type(x); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 | "Unsupported access size for {READ,WRITE}_ONCE().")
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:663:39: note: expanded from macro '__native_word'
663 | (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
| ^
include/linux/compiler_types.h:702:22: note: expanded from macro 'compiletime_assert'
702 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:690:23: note: expanded from macro '_compiletime_assert'
690 | __compiletime_assert(condition, msg, prefix, suffix)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:682:9: note: expanded from macro '__compiletime_assert'
682 | if (!(condition)) \
| ^~~~~~~~~
>> kernel/bpf/sys_call.c:127:34: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
49 | compiletime_assert_rwonce_type(x); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 | "Unsupported access size for {READ,WRITE}_ONCE().")
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:664:10: note: expanded from macro '__native_word'
664 | sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
| ^
include/linux/compiler_types.h:702:22: note: expanded from macro 'compiletime_assert'
702 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:690:23: note: expanded from macro '_compiletime_assert'
690 | __compiletime_assert(condition, msg, prefix, suffix)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:682:9: note: expanded from macro '__compiletime_assert'
682 | if (!(condition)) \
| ^~~~~~~~~
>> kernel/bpf/sys_call.c:127:34: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
49 | compiletime_assert_rwonce_type(x); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 | "Unsupported access size for {READ,WRITE}_ONCE().")
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:664:38: note: expanded from macro '__native_word'
664 | sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
| ^
include/linux/compiler_types.h:702:22: note: expanded from macro 'compiletime_assert'
702 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:690:23: note: expanded from macro '_compiletime_assert'
690 | __compiletime_assert(condition, msg, prefix, suffix)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:682:9: note: expanded from macro '__compiletime_assert'
682 | if (!(condition)) \
| ^~~~~~~~~
>> kernel/bpf/sys_call.c:127:34: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
49 | compiletime_assert_rwonce_type(x); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
include/asm-generic/rwonce.h:36:48: note: expanded from macro 'compiletime_assert_rwonce_type'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
37 | "Unsupported access size for {READ,WRITE}_ONCE().")
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:702:22: note: expanded from macro 'compiletime_assert'
702 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:690:23: note: expanded from macro '_compiletime_assert'
690 | __compiletime_assert(condition, msg, prefix, suffix)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:682:9: note: expanded from macro '__compiletime_assert'
682 | if (!(condition)) \
| ^~~~~~~~~
>> kernel/bpf/sys_call.c:127:34: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE'
50 | __READ_ONCE(x); \
| ~~~~~~~~~~~~^~
include/asm-generic/rwonce.h:44:65: note: expanded from macro '__READ_ONCE'
44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
| ~~~~~~~~~~~~~~~~~~~~~~~^~
include/linux/compiler_types.h:635:53: note: expanded from macro '__unqual_scalar_typeof'
635 | #define __unqual_scalar_typeof(x) __typeof_unqual__(x)
| ^
>> kernel/bpf/sys_call.c:127:34: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE'
50 | __READ_ONCE(x); \
| ~~~~~~~~~~~~^~
include/asm-generic/rwonce.h:44:72: note: expanded from macro '__READ_ONCE'
44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
| ^
kernel/bpf/sys_call.c:127:67: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~ ^
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
49 | compiletime_assert_rwonce_type(x); \
| ^
include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^
include/linux/compiler_types.h:663:10: note: expanded from macro '__native_word'
663 | (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
| ^
include/linux/compiler_types.h:702:22: note: expanded from macro 'compiletime_assert'
702 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~
include/linux/compiler_types.h:690:23: note: expanded from macro '_compiletime_assert'
690 | __compiletime_assert(condition, msg, prefix, suffix)
| ^~~~~~~~~
include/linux/compiler_types.h:682:9: note: expanded from macro '__compiletime_assert'
682 | if (!(condition)) \
| ^~~~~~~~~
kernel/bpf/sys_call.c:127:67: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~ ^
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
49 | compiletime_assert_rwonce_type(x); \
| ^
include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^
include/linux/compiler_types.h:663:39: note: expanded from macro '__native_word'
663 | (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
| ^
include/linux/compiler_types.h:702:22: note: expanded from macro 'compiletime_assert'
702 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~
include/linux/compiler_types.h:690:23: note: expanded from macro '_compiletime_assert'
690 | __compiletime_assert(condition, msg, prefix, suffix)
| ^~~~~~~~~
include/linux/compiler_types.h:682:9: note: expanded from macro '__compiletime_assert'
682 | if (!(condition)) \
| ^~~~~~~~~
kernel/bpf/sys_call.c:127:67: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~ ^
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
49 | compiletime_assert_rwonce_type(x); \
| ^
include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^
include/linux/compiler_types.h:664:10: note: expanded from macro '__native_word'
664 | sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
| ^
include/linux/compiler_types.h:702:22: note: expanded from macro 'compiletime_assert'
702 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~
include/linux/compiler_types.h:690:23: note: expanded from macro '_compiletime_assert'
690 | __compiletime_assert(condition, msg, prefix, suffix)
| ^~~~~~~~~
include/linux/compiler_types.h:682:9: note: expanded from macro '__compiletime_assert'
682 | if (!(condition)) \
| ^~~~~~~~~
kernel/bpf/sys_call.c:127:67: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~ ^
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
49 | compiletime_assert_rwonce_type(x); \
| ^
include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^
include/linux/compiler_types.h:664:38: note: expanded from macro '__native_word'
664 | sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
| ^
include/linux/compiler_types.h:702:22: note: expanded from macro 'compiletime_assert'
702 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~
include/linux/compiler_types.h:690:23: note: expanded from macro '_compiletime_assert'
690 | __compiletime_assert(condition, msg, prefix, suffix)
| ^~~~~~~~~
include/linux/compiler_types.h:682:9: note: expanded from macro '__compiletime_assert'
682 | if (!(condition)) \
| ^~~~~~~~~
kernel/bpf/sys_call.c:127:67: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~ ^
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
49 | compiletime_assert_rwonce_type(x); \
| ^
include/asm-generic/rwonce.h:36:48: note: expanded from macro 'compiletime_assert_rwonce_type'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^
include/linux/compiler_types.h:702:22: note: expanded from macro 'compiletime_assert'
702 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~
include/linux/compiler_types.h:690:23: note: expanded from macro '_compiletime_assert'
690 | __compiletime_assert(condition, msg, prefix, suffix)
| ^~~~~~~~~
include/linux/compiler_types.h:682:9: note: expanded from macro '__compiletime_assert'
682 | if (!(condition)) \
| ^~~~~~~~~
kernel/bpf/sys_call.c:127:67: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~ ^
include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE'
50 | __READ_ONCE(x); \
| ^
include/asm-generic/rwonce.h:44:65: note: expanded from macro '__READ_ONCE'
44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
| ^
include/linux/compiler_types.h:635:53: note: expanded from macro '__unqual_scalar_typeof'
635 | #define __unqual_scalar_typeof(x) __typeof_unqual__(x)
| ^
kernel/bpf/sys_call.c:127:67: error: no member named 'mode' in 'struct seccomp'
127 | (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
| ~~~~~~~~~~~~~ ^
include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE'
50 | __READ_ONCE(x); \
| ^
include/asm-generic/rwonce.h:44:72: note: expanded from macro '__READ_ONCE'
44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
| ^
>> kernel/bpf/sys_call.c:209:7: error: no member named 'orig_ax' in 'struct pt_regs'
209 | regs.orig_ax = nr;
| ~~~~ ^
>> kernel/bpf/sys_call.c:210:7: error: no member named 'di' in 'struct pt_regs'
210 | regs.di = args[0];
| ~~~~ ^
>> kernel/bpf/sys_call.c:211:7: error: no member named 'si' in 'struct pt_regs'
211 | regs.si = args[1];
| ~~~~ ^
>> kernel/bpf/sys_call.c:212:7: error: no member named 'dx' in 'struct pt_regs'
212 | regs.dx = args[2];
| ~~~~ ^
>> kernel/bpf/sys_call.c:213:7: error: no member named 'r10' in 'struct pt_regs'
213 | regs.r10 = args[3];
| ~~~~ ^fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated.
vim +127 kernel/bpf/sys_call.c
106
107 /*
108 * Whether @task has what a call made by the current thread would use in its
109 * place: the file table, the fs and the namespaces, and no filter or audit
110 * that the call would pass by. The pointers are compared, not followed: each
111 * changes only by its own thread, and a call that raced with such a change
112 * was made before it.
113 */
114 static int bpf_sys_call_check(struct task_struct *task)
115 {
116 if (task != current) {
117 if (!same_thread_group(task, current))
118 return -EPERM;
119 if (READ_ONCE(task->flags) & PF_EXITING)
120 return -ESRCH;
121 if (READ_ONCE(task->files) != current->files ||
122 READ_ONCE(task->fs) != current->fs ||
123 READ_ONCE(task->nsproxy) != current->nsproxy)
124 return -EPERM;
125 }
126 if (IS_ENABLED(CONFIG_SECCOMP) &&
> 127 (READ_ONCE(current->seccomp.mode) || READ_ONCE(task->seccomp.mode)))
128 return -EPERM;
129 if (!audit_dummy_context())
130 return -EPERM;
131 return 0;
132 }
133
134 /*
135 * The work that the return to user mode would run for the calling thread:
136 * the release of a file whose last reference a call dropped, above all,
137 * which would otherwise wait until the thread leaves the program. io threads run theirs
138 * the same way, see io_run_task_work().
139 */
140 static void bpf_sys_call_task_work(void)
141 {
142 if (test_thread_flag(TIF_NOTIFY_SIGNAL))
143 clear_notify_signal();
144 if (task_work_pending(current)) {
145 __set_current_state(TASK_RUNNING);
146 task_work_run();
147 }
148 }
149
150 __bpf_kfunc_start_defs();
151
152 /**
153 * bpf_sys_call - Make a system call for a thread of the caller's process
154 * @task: the thread the call is made for, the calling thread or another one
155 * of its process
156 * @nr: the system call's number
157 * @args: its six arguments
158 * @args__sz: the size of @args, 48
159 * @aux: the calling program, set by the verifier
160 *
161 * Makes system call @nr in the calling thread, a thread of a user process
162 * running a syscall program, as @task would make it: see the comment at the
163 * top for what is the task's and what is refused. Pointers in @args are user
164 * addresses of the process.
165 *
166 * For the verifier the call is a park, see bpf_task_park(): the program
167 * leaves its Tasks Trace RCU read section and may migrate for the time of the
168 * call, which may sleep for as long as the system call does, and the time
169 * slice of its loops starts over when it returns.
170 *
171 * Signals are delivered on the return to user mode, which the call does not
172 * make. A call that a signal interrupted returns -ERESTARTSYS,
173 * -ERESTARTNOINTR, -ERESTARTNOHAND or -ERESTART_RESTARTBLOCK, as the system
174 * call gave it: it did nothing, and the program makes it again once the
175 * thread has been to user mode, or completes it with -EINTR. The program does
176 * not hand those codes to user space. A call is not begun while a signal is
177 * pending: that returns -ERESTARTNOINTR. Work queued for the thread's return
178 * to user mode, the release of a file whose last reference a call dropped
179 * among it, is run before and after the call.
180 *
181 * Return: what the system call returned, or -EINVAL if @args__sz is not 48,
182 * -ENOSYS if @nr is not a call that may be made for @task, -EPERM if the
183 * calling thread is not a thread of a user process, @task is not of its
184 * process or does not have its files, fs or namespaces, or a seccomp filter
185 * or syscall auditing applies, -ESRCH if @task is exiting, and
186 * -ERESTARTNOINTR if a signal is pending.
187 */
188 __bpf_kfunc long bpf_sys_call(struct task_struct *task, u32 nr, const u64 *args, u32 args__sz,
189 struct bpf_prog_aux *aux)
190 {
191 const struct cred *cred = NULL, *old;
192 struct pt_regs regs = {};
193 long ret;
194
195 if (args__sz != 6 * sizeof(u64))
196 return -EINVAL;
197 if (!current->mm || (current->flags & (PF_KTHREAD | PF_USER_WORKER)))
198 return -EPERM;
199 if (nr >= NR_syscalls)
200 return -ENOSYS;
201 nr = array_index_nospec(nr, NR_syscalls);
202 if (!test_bit(nr, bpf_sys_call_for_process) &&
203 !(task == current && test_bit(nr, bpf_sys_call_for_self)))
204 return -ENOSYS;
205 ret = bpf_sys_call_check(task);
206 if (ret)
207 return ret;
208
> 209 regs.orig_ax = nr;
> 210 regs.di = args[0];
> 211 regs.si = args[1];
> 212 regs.dx = args[2];
> 213 regs.r10 = args[3]; 214 regs.r8 = args[4];
215 regs.r9 = args[5];
216
217 /* What bpf_task_park() does for its sleep, and for the same reasons. */
218 migrate_enable();
219 rcu_read_unlock_trace();
220
221 bpf_sys_call_task_work();
222 if (signal_pending(current)) {
223 ret = -ERESTARTNOINTR;
224 goto out;
225 }
226 /*
227 * The task's objective credentials: its subjective ones may be an
228 * override that a call of its own made for itself for a while.
229 */
230 if (task != current && rcu_access_pointer(task->real_cred) != current_cred())
231 cred = get_task_cred(task);
232 if (cred)
233 old = override_creds(cred);
234 ret = sys_call_table[nr](®s);
235 if (cred) {
236 revert_creds(old);
237 put_cred(cred);
238 }
239 bpf_sys_call_task_work();
240 out:
241 rcu_read_lock_trace();
242 migrate_disable();
243 bpf_timed_may_goto_rearm(aux);
244 return ret;
245 }
246
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki