Re: [PATCH 1/2] audit: add call argument to socketcall auditing

From: kernel test robot
Date: Tue May 03 2022 - 09:32:50 EST


Hi Sven,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on pcmoore-audit/next v5.18-rc5 next-20220503]
[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/intel-lab-lkp/linux/commits/Sven-Schnelle/audit-add-call-argument-to-socketcall-auditing/20220503-170442
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 9050ba3a61a4b5bd84c2cde092a100404f814f31
config: x86_64-randconfig-a013 (https://download.01.org/0day-ci/archive/20220503/202205032108.vBdGwIXf-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.2.0-20) 11.2.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/b89caaec1c1bd3382c6cef08d08beadbaf808513
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Sven-Schnelle/audit-add-call-argument-to-socketcall-auditing/20220503-170442
git checkout b89caaec1c1bd3382c6cef08d08beadbaf808513
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

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

All error/warnings (new ones prefixed by >>):

net/socket.c: In function '__sys_getsockopt':
net/socket.c:2206:13: warning: variable 'max_optlen' set but not used [-Wunused-but-set-variable]
2206 | int max_optlen;
| ^~~~~~~~~~
net/socket.c: In function '__do_sys_socketcall':
>> net/socket.c:2924:50: warning: passing argument 2 of 'audit_socketcall' makes pointer from integer without a cast [-Wint-conversion]
2924 | err = audit_socketcall(call, nargs[call] / sizeof(unsigned long), a);
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
| |
| long unsigned int
In file included from net/socket.c:82:
include/linux/audit.h:643:62: note: expected 'long unsigned int *' but argument is of type 'long unsigned int'
643 | static inline int audit_socketcall(int nargs, unsigned long *args)
| ~~~~~~~~~~~~~~~^~~~
>> net/socket.c:2924:15: error: too many arguments to function 'audit_socketcall'
2924 | err = audit_socketcall(call, nargs[call] / sizeof(unsigned long), a);
| ^~~~~~~~~~~~~~~~
In file included from net/socket.c:82:
include/linux/audit.h:643:19: note: declared here
643 | static inline int audit_socketcall(int nargs, unsigned long *args)
| ^~~~~~~~~~~~~~~~


vim +/audit_socketcall +2924 net/socket.c

2896
2897 /*
2898 * System call vectors.
2899 *
2900 * Argument checking cleaned up. Saved 20% in size.
2901 * This function doesn't need to set the kernel lock because
2902 * it is set by the callees.
2903 */
2904
2905 SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
2906 {
2907 unsigned long a[AUDITSC_ARGS];
2908 unsigned long a0, a1;
2909 int err;
2910 unsigned int len;
2911
2912 if (call < 1 || call > SYS_SENDMMSG)
2913 return -EINVAL;
2914 call = array_index_nospec(call, SYS_SENDMMSG + 1);
2915
2916 len = nargs[call];
2917 if (len > sizeof(a))
2918 return -EINVAL;
2919
2920 /* copy_from_user should be SMP safe. */
2921 if (copy_from_user(a, args, len))
2922 return -EFAULT;
2923
> 2924 err = audit_socketcall(call, nargs[call] / sizeof(unsigned long), a);
2925 if (err)
2926 return err;
2927
2928 a0 = a[0];
2929 a1 = a[1];
2930
2931 switch (call) {
2932 case SYS_SOCKET:
2933 err = __sys_socket(a0, a1, a[2]);
2934 break;
2935 case SYS_BIND:
2936 err = __sys_bind(a0, (struct sockaddr __user *)a1, a[2]);
2937 break;
2938 case SYS_CONNECT:
2939 err = __sys_connect(a0, (struct sockaddr __user *)a1, a[2]);
2940 break;
2941 case SYS_LISTEN:
2942 err = __sys_listen(a0, a1);
2943 break;
2944 case SYS_ACCEPT:
2945 err = __sys_accept4(a0, (struct sockaddr __user *)a1,
2946 (int __user *)a[2], 0);
2947 break;
2948 case SYS_GETSOCKNAME:
2949 err =
2950 __sys_getsockname(a0, (struct sockaddr __user *)a1,
2951 (int __user *)a[2]);
2952 break;
2953 case SYS_GETPEERNAME:
2954 err =
2955 __sys_getpeername(a0, (struct sockaddr __user *)a1,
2956 (int __user *)a[2]);
2957 break;
2958 case SYS_SOCKETPAIR:
2959 err = __sys_socketpair(a0, a1, a[2], (int __user *)a[3]);
2960 break;
2961 case SYS_SEND:
2962 err = __sys_sendto(a0, (void __user *)a1, a[2], a[3],
2963 NULL, 0);
2964 break;
2965 case SYS_SENDTO:
2966 err = __sys_sendto(a0, (void __user *)a1, a[2], a[3],
2967 (struct sockaddr __user *)a[4], a[5]);
2968 break;
2969 case SYS_RECV:
2970 err = __sys_recvfrom(a0, (void __user *)a1, a[2], a[3],
2971 NULL, NULL);
2972 break;
2973 case SYS_RECVFROM:
2974 err = __sys_recvfrom(a0, (void __user *)a1, a[2], a[3],
2975 (struct sockaddr __user *)a[4],
2976 (int __user *)a[5]);
2977 break;
2978 case SYS_SHUTDOWN:
2979 err = __sys_shutdown(a0, a1);
2980 break;
2981 case SYS_SETSOCKOPT:
2982 err = __sys_setsockopt(a0, a1, a[2], (char __user *)a[3],
2983 a[4]);
2984 break;
2985 case SYS_GETSOCKOPT:
2986 err =
2987 __sys_getsockopt(a0, a1, a[2], (char __user *)a[3],
2988 (int __user *)a[4]);
2989 break;
2990 case SYS_SENDMSG:
2991 err = __sys_sendmsg(a0, (struct user_msghdr __user *)a1,
2992 a[2], true);
2993 break;
2994 case SYS_SENDMMSG:
2995 err = __sys_sendmmsg(a0, (struct mmsghdr __user *)a1, a[2],
2996 a[3], true);
2997 break;
2998 case SYS_RECVMSG:
2999 err = __sys_recvmsg(a0, (struct user_msghdr __user *)a1,
3000 a[2], true);
3001 break;
3002 case SYS_RECVMMSG:
3003 if (IS_ENABLED(CONFIG_64BIT))
3004 err = __sys_recvmmsg(a0, (struct mmsghdr __user *)a1,
3005 a[2], a[3],
3006 (struct __kernel_timespec __user *)a[4],
3007 NULL);
3008 else
3009 err = __sys_recvmmsg(a0, (struct mmsghdr __user *)a1,
3010 a[2], a[3], NULL,
3011 (struct old_timespec32 __user *)a[4]);
3012 break;
3013 case SYS_ACCEPT4:
3014 err = __sys_accept4(a0, (struct sockaddr __user *)a1,
3015 (int __user *)a[2], a[3]);
3016 break;
3017 default:
3018 err = -EINVAL;
3019 break;
3020 }
3021 return err;
3022 }
3023

--
0-DAY CI Kernel Test Service
https://01.org/lkp