Re: [PATCH v2 3/3] audit: Use syscall_get_return_value to get syscall return code in audit_syscall_exit

From: kernel test robot
Date: Sat Apr 24 2021 - 02:13:42 EST


Hi He,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on pcmoore-audit/next xlnx/master arm/for-next soc/for-next kvmarm/next v5.12-rc8 next-20210423]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/He-Zhe/arm64-ptrace-Add-is_syscall_success-to-handle-compat/20210423-183635
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: alpha-allyesconfig (attached as .config)
compiler: alpha-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/05158a30658079871fe05b4ac0e87fd5681874b4
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review He-Zhe/arm64-ptrace-Add-is_syscall_success-to-handle-compat/20210423-183635
git checkout 05158a30658079871fe05b4ac0e87fd5681874b4
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=alpha

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

In file included from include/net/xfrm.h:15,
from drivers/net/wireless/mac80211_hwsim.c:21:
include/linux/audit.h: In function 'audit_syscall_exit':
>> include/linux/audit.h:337:22: error: implicit declaration of function 'syscall_get_return_value' [-Werror=implicit-function-declaration]
337 | long return_code = syscall_get_return_value(current, pt_regs);
| ^~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
In file included from arch/alpha/kernel/ptrace.c:19:
include/linux/audit.h: In function 'audit_syscall_exit':
>> include/linux/audit.h:337:22: error: implicit declaration of function 'syscall_get_return_value' [-Werror=implicit-function-declaration]
337 | long return_code = syscall_get_return_value(current, pt_regs);
| ^~~~~~~~~~~~~~~~~~~~~~~~
arch/alpha/kernel/ptrace.c: At top level:
arch/alpha/kernel/ptrace.c:321:26: warning: no previous prototype for 'syscall_trace_enter' [-Wmissing-prototypes]
321 | asmlinkage unsigned long syscall_trace_enter(void)
| ^~~~~~~~~~~~~~~~~~~
arch/alpha/kernel/ptrace.c:333:1: warning: no previous prototype for 'syscall_trace_leave' [-Wmissing-prototypes]
333 | syscall_trace_leave(void)
| ^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
In file included from kernel/fork.c:63:
include/linux/audit.h: In function 'audit_syscall_exit':
>> include/linux/audit.h:337:22: error: implicit declaration of function 'syscall_get_return_value' [-Werror=implicit-function-declaration]
337 | long return_code = syscall_get_return_value(current, pt_regs);
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/fork.c: At top level:
kernel/fork.c:161:13: warning: no previous prototype for 'arch_release_task_struct' [-Wmissing-prototypes]
161 | void __weak arch_release_task_struct(struct task_struct *tsk)
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/fork.c:746:20: warning: no previous prototype for 'arch_task_cache_init' [-Wmissing-prototypes]
746 | void __init __weak arch_task_cache_init(void) { }
| ^~~~~~~~~~~~~~~~~~~~
kernel/fork.c:836:12: warning: no previous prototype for 'arch_dup_task_struct' [-Wmissing-prototypes]
836 | int __weak arch_dup_task_struct(struct task_struct *dst,
| ^~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
In file included from kernel/exit.c:49:
include/linux/audit.h: In function 'audit_syscall_exit':
>> include/linux/audit.h:337:22: error: implicit declaration of function 'syscall_get_return_value' [-Werror=implicit-function-declaration]
337 | long return_code = syscall_get_return_value(current, pt_regs);
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/exit.c: At top level:
kernel/exit.c:1763:13: warning: no previous prototype for 'abort' [-Wmissing-prototypes]
1763 | __weak void abort(void)
| ^~~~~
cc1: some warnings being treated as errors
--
In file included from kernel/module.c:58:
include/linux/audit.h: In function 'audit_syscall_exit':
>> include/linux/audit.h:337:22: error: implicit declaration of function 'syscall_get_return_value' [-Werror=implicit-function-declaration]
337 | long return_code = syscall_get_return_value(current, pt_regs);
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/module.c: At top level:
kernel/module.c:4675:6: warning: no previous prototype for 'module_layout' [-Wmissing-prototypes]
4675 | void module_layout(struct module *mod,
| ^~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
In file included from kernel/audit.c:51:
include/linux/audit.h: In function 'audit_syscall_exit':
>> include/linux/audit.h:337:22: error: implicit declaration of function 'syscall_get_return_value' [-Werror=implicit-function-declaration]
337 | long return_code = syscall_get_return_value(current, pt_regs);
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/audit.c: In function 'audit_log_vformat':
kernel/audit.c:1926:2: warning: function 'audit_log_vformat' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
1926 | len = vsnprintf(skb_tail_pointer(skb), avail, fmt, args);
| ^~~
kernel/audit.c:1935:3: warning: function 'audit_log_vformat' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
1935 | len = vsnprintf(skb_tail_pointer(skb), avail, fmt, args2);
| ^~~
cc1: some warnings being treated as errors
--
In file included from include/linux/fsnotify.h:16,
from security/security.c:24:
include/linux/audit.h: In function 'audit_syscall_exit':
>> include/linux/audit.h:337:22: error: implicit declaration of function 'syscall_get_return_value' [-Werror=implicit-function-declaration]
337 | long return_code = syscall_get_return_value(current, pt_regs);
| ^~~~~~~~~~~~~~~~~~~~~~~~
At top level:
include/linux/lsm_hook_defs.h:399:18: warning: 'perf_event_write_default' defined but not used [-Wunused-const-variable=]
399 | LSM_HOOK(int, 0, perf_event_write, struct perf_event *event)
| ^~~~~~~~~~~~~~~~
security/security.c:682:32: note: in definition of macro 'LSM_RET_DEFAULT'
682 | #define LSM_RET_DEFAULT(NAME) (NAME##_default)
| ^~~~
security/security.c:687:2: note: in expansion of macro 'DECLARE_LSM_RET_DEFAULT_int'
687 | DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/lsm_hook_defs.h:399:1: note: in expansion of macro 'LSM_HOOK'
399 | LSM_HOOK(int, 0, perf_event_write, struct perf_event *event)
| ^~~~~~~~
include/linux/lsm_hook_defs.h:398:18: warning: 'perf_event_read_default' defined but not used [-Wunused-const-variable=]
398 | LSM_HOOK(int, 0, perf_event_read, struct perf_event *event)
| ^~~~~~~~~~~~~~~
security/security.c:682:32: note: in definition of macro 'LSM_RET_DEFAULT'
682 | #define LSM_RET_DEFAULT(NAME) (NAME##_default)
| ^~~~
security/security.c:687:2: note: in expansion of macro 'DECLARE_LSM_RET_DEFAULT_int'
687 | DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/lsm_hook_defs.h:398:1: note: in expansion of macro 'LSM_HOOK'
398 | LSM_HOOK(int, 0, perf_event_read, struct perf_event *event)
| ^~~~~~~~
include/linux/lsm_hook_defs.h:396:18: warning: 'perf_event_alloc_default' defined but not used [-Wunused-const-variable=]
396 | LSM_HOOK(int, 0, perf_event_alloc, struct perf_event *event)
| ^~~~~~~~~~~~~~~~
security/security.c:682:32: note: in definition of macro 'LSM_RET_DEFAULT'
682 | #define LSM_RET_DEFAULT(NAME) (NAME##_default)
| ^~~~
security/security.c:687:2: note: in expansion of macro 'DECLARE_LSM_RET_DEFAULT_int'
687 | DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/lsm_hook_defs.h:396:1: note: in expansion of macro 'LSM_HOOK'
396 | LSM_HOOK(int, 0, perf_event_alloc, struct perf_event *event)
| ^~~~~~~~
include/linux/lsm_hook_defs.h:395:18: warning: 'perf_event_open_default' defined but not used [-Wunused-const-variable=]
395 | LSM_HOOK(int, 0, perf_event_open, struct perf_event_attr *attr, int type)
| ^~~~~~~~~~~~~~~
security/security.c:682:32: note: in definition of macro 'LSM_RET_DEFAULT'
682 | #define LSM_RET_DEFAULT(NAME) (NAME##_default)
| ^~~~
security/security.c:687:2: note: in expansion of macro 'DECLARE_LSM_RET_DEFAULT_int'
687 | DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/lsm_hook_defs.h:395:1: note: in expansion of macro 'LSM_HOOK'
395 | LSM_HOOK(int, 0, perf_event_open, struct perf_event_attr *attr, int type)
| ^~~~~~~~
include/linux/lsm_hook_defs.h:392:18: warning: 'locked_down_default' defined but not used [-Wunused-const-variable=]
392 | LSM_HOOK(int, 0, locked_down, enum lockdown_reason what)
| ^~~~~~~~~~~
security/security.c:682:32: note: in definition of macro 'LSM_RET_DEFAULT'
682 | #define LSM_RET_DEFAULT(NAME) (NAME##_default)
| ^~~~
security/security.c:687:2: note: in expansion of macro 'DECLARE_LSM_RET_DEFAULT_int'
687 | DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/lsm_hook_defs.h:392:1: note: in expansion of macro 'LSM_HOOK'
392 | LSM_HOOK(int, 0, locked_down, enum lockdown_reason what)
| ^~~~~~~~
include/linux/lsm_hook_defs.h:388:18: warning: 'bpf_prog_alloc_security_default' defined but not used [-Wunused-const-variable=]
388 | LSM_HOOK(int, 0, bpf_prog_alloc_security, struct bpf_prog_aux *aux)
| ^~~~~~~~~~~~~~~~~~~~~~~
security/security.c:682:32: note: in definition of macro 'LSM_RET_DEFAULT'
682 | #define LSM_RET_DEFAULT(NAME) (NAME##_default)
| ^~~~
security/security.c:687:2: note: in expansion of macro 'DECLARE_LSM_RET_DEFAULT_int'
687 | DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/lsm_hook_defs.h:388:1: note: in expansion of macro 'LSM_HOOK'
388 | LSM_HOOK(int, 0, bpf_prog_alloc_security, struct bpf_prog_aux *aux)
| ^~~~~~~~
include/linux/lsm_hook_defs.h:386:18: warning: 'bpf_map_alloc_security_default' defined but not used [-Wunused-const-variable=]
386 | LSM_HOOK(int, 0, bpf_map_alloc_security, struct bpf_map *map)
| ^~~~~~~~~~~~~~~~~~~~~~
security/security.c:682:32: note: in definition of macro 'LSM_RET_DEFAULT'
682 | #define LSM_RET_DEFAULT(NAME) (NAME##_default)
| ^~~~
security/security.c:687:2: note: in expansion of macro 'DECLARE_LSM_RET_DEFAULT_int'
687 | DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/lsm_hook_defs.h:386:1: note: in expansion of macro 'LSM_HOOK'
386 | LSM_HOOK(int, 0, bpf_map_alloc_security, struct bpf_map *map)
| ^~~~~~~~
include/linux/lsm_hook_defs.h:385:18: warning: 'bpf_prog_default' defined but not used [-Wunused-const-variable=]
385 | LSM_HOOK(int, 0, bpf_prog, struct bpf_prog *prog)
| ^~~~~~~~
security/security.c:682:32: note: in definition of macro 'LSM_RET_DEFAULT'
682 | #define LSM_RET_DEFAULT(NAME) (NAME##_default)
| ^~~~
security/security.c:687:2: note: in expansion of macro 'DECLARE_LSM_RET_DEFAULT_int'
687 | DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/lsm_hook_defs.h:385:1: note: in expansion of macro 'LSM_HOOK'
385 | LSM_HOOK(int, 0, bpf_prog, struct bpf_prog *prog)
| ^~~~~~~~
include/linux/lsm_hook_defs.h:384:18: warning: 'bpf_map_default' defined but not used [-Wunused-const-variable=]
--
In file included from security/apparmor/include/audit.h:14,
from security/apparmor/policy_unpack.c:22:
include/linux/audit.h: In function 'audit_syscall_exit':
>> include/linux/audit.h:337:22: error: implicit declaration of function 'syscall_get_return_value' [-Werror=implicit-function-declaration]
337 | long return_code = syscall_get_return_value(current, pt_regs);
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from security/apparmor/policy_unpack.c:1237:
security/apparmor/policy_unpack_test.c: At top level:
security/apparmor/policy_unpack_test.c:51:16: warning: no previous prototype for 'build_aa_ext_struct' [-Wmissing-prototypes]
51 | struct aa_ext *build_aa_ext_struct(struct policy_unpack_fixture *puf,
| ^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
In file included from security/integrity/ima/ima.h:22,
from security/integrity/ima/ima_asymmetric_keys.c:14:
include/linux/audit.h: In function 'audit_syscall_exit':
>> include/linux/audit.h:337:22: error: implicit declaration of function 'syscall_get_return_value' [-Werror=implicit-function-declaration]
337 | long return_code = syscall_get_return_value(current, pt_regs);
| ^~~~~~~~~~~~~~~~~~~~~~~~
security/integrity/ima/ima_asymmetric_keys.c: At top level:
security/integrity/ima/ima_asymmetric_keys.c:28:6: warning: no previous prototype for 'ima_post_key_create_or_update' [-Wmissing-prototypes]
28 | void ima_post_key_create_or_update(struct key *keyring, struct key *key,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +/syscall_get_return_value +337 include/linux/audit.h

315
316 static inline bool audit_dummy_context(void)
317 {
318 void *p = audit_context();
319 return !p || *(int *)p;
320 }
321 static inline void audit_free(struct task_struct *task)
322 {
323 if (unlikely(task->audit_context))
324 __audit_free(task);
325 }
326 static inline void audit_syscall_entry(int major, unsigned long a0,
327 unsigned long a1, unsigned long a2,
328 unsigned long a3)
329 {
330 if (unlikely(audit_context()))
331 __audit_syscall_entry(major, a0, a1, a2, a3);
332 }
333 static inline void audit_syscall_exit(void *pt_regs)
334 {
335 if (unlikely(audit_context())) {
336 int success = is_syscall_success(pt_regs);
> 337 long return_code = syscall_get_return_value(current, pt_regs);
338
339 __audit_syscall_exit(success, return_code);
340 }
341 }
342 static inline struct filename *audit_reusename(const __user char *name)
343 {
344 if (unlikely(!audit_dummy_context()))
345 return __audit_reusename(name);
346 return NULL;
347 }
348 static inline void audit_getname(struct filename *name)
349 {
350 if (unlikely(!audit_dummy_context()))
351 __audit_getname(name);
352 }
353 static inline void audit_inode(struct filename *name,
354 const struct dentry *dentry,
355 unsigned int aflags) {
356 if (unlikely(!audit_dummy_context()))
357 __audit_inode(name, dentry, aflags);
358 }
359 static inline void audit_file(struct file *file)
360 {
361 if (unlikely(!audit_dummy_context()))
362 __audit_file(file);
363 }
364 static inline void audit_inode_parent_hidden(struct filename *name,
365 const struct dentry *dentry)
366 {
367 if (unlikely(!audit_dummy_context()))
368 __audit_inode(name, dentry,
369 AUDIT_INODE_PARENT | AUDIT_INODE_HIDDEN);
370 }
371 static inline void audit_inode_child(struct inode *parent,
372 const struct dentry *dentry,
373 const unsigned char type) {
374 if (unlikely(!audit_dummy_context()))
375 __audit_inode_child(parent, dentry, type);
376 }
377 void audit_core_dumps(long signr);
378

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip