On Sat, Jul 2, 2022 at 12:46 PM kernel test robot wrote: > > Hi Alexander, > > I love your patch! Yet something to improve: > > [auto build test ERROR on masahiroy-kbuild/for-next] > [also build test ERROR on linus/master v5.19-rc4 next-20220701] > [cannot apply to tip/x86/core tip/x86/mm] > [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/Alexander-Potapenko/Add-KernelMemorySanitizer-infrastructure/20220701-222712 > base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next > config: i386-randconfig-a011 (https://download.01.org/0day-ci/archive/20220702/202207021844.0J4s1Gjz-lkp@intel.com/config) > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project a9119143a2d1f4d0d0bc1fe0d819e5351b4e0deb) > 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/intel-lab-lkp/linux/commit/0ca0e4029535365a65588446ba55a952ca186079 > git remote add linux-review https://github.com/intel-lab-lkp/linux > git fetch --no-tags linux-review Alexander-Potapenko/Add-KernelMemorySanitizer-infrastructure/20220701-222712 > git checkout 0ca0e4029535365a65588446ba55a952ca186079 > # save the config file > mkdir build_dir && cp config build_dir/.config > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash > > If you fix the issue, kindly add following tag where applicable > Reported-by: kernel test robot Uh oh, this is a very good catch. > All errors (new ones prefixed by >>): > > >> arch/x86/math-emu/reg_ld_str.c:1043:3: error: address of bit-field requested > FPU_get_user(instruction_address.selector, > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/x86/math-emu/fpu_system.h:127:36: note: expanded from macro 'FPU_get_user' > #define FPU_get_user(x,y) do { if (get_user((x),(y))) FPU_abort; } while (0) > ~~~~^~~~~~~~~~~~~~~~~~ > arch/x86/include/asm/uaccess.h:131:43: note: expanded from macro 'get_user' > #define get_user(x,ptr) ({ might_fault(); do_get_user_call(get_user,x,ptr); }) > ^ > arch/x86/include/asm/uaccess.h:103:43: note: expanded from macro 'do_get_user_call' > instrument_copy_from_user_before((void *)&(x), ptr, sizeof(*(ptr))); \ > ^ > include/linux/compiler.h:56:47: note: expanded from macro 'if' > #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) ) > ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ > include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var' > #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond)) > ^~~~ > >> arch/x86/math-emu/reg_ld_str.c:1043:3: error: address of bit-field requested > FPU_get_user(instruction_address.selector, > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Actually `x` in get_user(x, ptr) and put_user(x, ptr) is not guaranteed to be addressable (e.g. in this case it is a bitfield). We can copy the values to a local var, like it's done in __put_user_size: 254 __typeof__(*(ptr)) __pus_val = x; \ 255 __chk_user_ptr(ptr); \ 256 instrument_copy_to_user(ptr, &(__pus_val), size); \ , but this won't help KASAN or KCSAN detect the bugs accessing x. Perhaps a better solution would be to declare instrument_get_user() and instrument_put_user(), which will unpoison/check the values for KMSAN and do nothing for other tools. -- Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Straße, 33 80636 München Geschäftsführer: Paul Manicle, Liana Sebastian Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg