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: i386-randconfig-x017-201834 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/linux/export.h:45:0,
                    from include/linux/linkage.h:7,
                    from include/linux/kernel.h:7,
                    from include/linux/list.h:9,
                    from include/linux/module.h:9,
                    from kernel/sysctl.c:21:
   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))
                 ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> kernel/sysctl.c:2556:3: note: in expansion of macro 'if'
      if ((param->min && *param->min > val) ||
      ^~
   kernel/sysctl.c:2558:14: warning: right shift count >= width of type 
[-Wshift-count-overflow]
          *lvalp >> (sizeof(int) * 8))
                 ^
   include/linux/compiler.h:58:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
>> kernel/sysctl.c:2556:3: note: in expansion of macro 'if'
      if ((param->min && *param->min > val) ||
      ^~
   kernel/sysctl.c:2558:14: warning: right shift count >= width of type 
[-Wshift-count-overflow]
          *lvalp >> (sizeof(int) * 8))
                 ^
   include/linux/compiler.h:69:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
>> kernel/sysctl.c:2556:3: note: in expansion of macro 'if'
      if ((param->min && *param->min > val) ||
      ^~

vim +/if +2556 kernel/sysctl.c

^1da177e Linus Torvalds   2005-04-16  2548  
00b7c339 Amerigo Wang     2010-05-05  2549  static int 
do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
^1da177e Linus Torvalds   2005-04-16  2550                                      
int *valp,
^1da177e Linus Torvalds   2005-04-16  2551                                      
int write, void *data)
^1da177e Linus Torvalds   2005-04-16  2552  {
^1da177e Linus Torvalds   2005-04-16  2553      struct 
do_proc_dointvec_minmax_conv_param *param = data;
^1da177e Linus Torvalds   2005-04-16  2554      if (write) {
^1da177e Linus Torvalds   2005-04-16  2555              int val = *negp ? 
-*lvalp : *lvalp;
^1da177e Linus Torvalds   2005-04-16 @2556              if ((param->min && 
*param->min > val) ||
b79ce51f Aristeu Rozanski 2018-08-27  2557                  (param->max && 
*param->max < val) ||
b79ce51f Aristeu Rozanski 2018-08-27  2558                  *lvalp >> 
(sizeof(int) * 8))
^1da177e Linus Torvalds   2005-04-16  2559                      return -EINVAL;
^1da177e Linus Torvalds   2005-04-16  2560              *valp = val;
^1da177e Linus Torvalds   2005-04-16  2561      } else {
^1da177e Linus Torvalds   2005-04-16  2562              int val = *valp;
^1da177e Linus Torvalds   2005-04-16  2563              if (val < 0) {
00b7c339 Amerigo Wang     2010-05-05  2564                      *negp = true;
9a5bc726 Ilya Dryomov     2015-09-09  2565                      *lvalp = 
-(unsigned long)val;
^1da177e Linus Torvalds   2005-04-16  2566              } else {
00b7c339 Amerigo Wang     2010-05-05  2567                      *negp = false;
^1da177e Linus Torvalds   2005-04-16  2568                      *lvalp = 
(unsigned long)val;
^1da177e Linus Torvalds   2005-04-16  2569              }
^1da177e Linus Torvalds   2005-04-16  2570      }
^1da177e Linus Torvalds   2005-04-16  2571      return 0;
^1da177e Linus Torvalds   2005-04-16  2572  }
^1da177e Linus Torvalds   2005-04-16  2573  

:::::: The code at line 2556 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torva...@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torva...@ppc970.osdl.org>

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

Attachment: .config.gz
Description: application/gzip

Reply via email to