Re: [PATCH] sysctl: do not allow a 64bit value write in a 32bit knob

From: kbuild test robot
Date: Tue Aug 28 2018 - 00:44:44 EST


Hi Aristeu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.19-rc1 next-20180827]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Aristeu-Rozanski/sysctl-do-not-allow-a-64bit-value-write-in-a-32bit-knob/20180828-043801
config: microblaze-mmu_defconfig (attached as .config)
compiler: microblaze-linux-gcc (GCC) 8.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=8.1.0 make.cross ARCH=microblaze

All warnings (new ones prefixed by >>):

kernel/sysctl.c: In function 'do_proc_dointvec_minmax_conv':
>> kernel/sysctl.c:2558:14: warning: right shift count >= width of type [-Wshift-count-overflow]
*lvalp >> (sizeof(int) * 8))
^~

vim +2558 kernel/sysctl.c

2548
2549 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2550 int *valp,
2551 int write, void *data)
2552 {
2553 struct do_proc_dointvec_minmax_conv_param *param = data;
2554 if (write) {
2555 int val = *negp ? -*lvalp : *lvalp;
2556 if ((param->min && *param->min > val) ||
2557 (param->max && *param->max < val) ||
> 2558 *lvalp >> (sizeof(int) * 8))
2559 return -EINVAL;
2560 *valp = val;
2561 } else {
2562 int val = *valp;
2563 if (val < 0) {
2564 *negp = true;
2565 *lvalp = -(unsigned long)val;
2566 } else {
2567 *negp = false;
2568 *lvalp = (unsigned long)val;
2569 }
2570 }
2571 return 0;
2572 }
2573

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip