[kbuild:kunit 16/17] kernel/sysctl-test.c:185:37: warning: integer overflow in expression of type 'long int' results in '2147483647'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kunit
head:   c505c0b2e6237c729634327c178f5b0094f1c958
commit: b3c54f027d78b71240b2572cf2dabb3381aa68de [16/17] kernel/sysctl-test: Add null pointer test for sysctl.c:proc_dointvec()
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-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
        git checkout b3c54f027d78b71240b2572cf2dabb3381aa68de
        # save the attached .config to linux build tree
        GCC_VERSION=8.1.0 make.cross ARCH=xtensa 

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

All warnings (new ones prefixed by >>):

   kernel/sysctl-test.c: In function 'sysctl_test_dointvec_single_less_int_min':
>> kernel/sysctl-test.c:185:37: warning: integer overflow in expression of type 'long int' results in '2147483647' [-Woverflow]
     long less_than_min = (long)INT_MIN - 1;
                                        ^
   kernel/sysctl-test.c: In function 'sysctl_test_dointvec_single_greater_int_max':
   kernel/sysctl-test.c:213:40: warning: integer overflow in expression of type 'long int' results in '-2147483648' [-Woverflow]
     long greater_than_max = (long)INT_MAX + 1;
                                           ^

vim +185 kernel/sysctl-test.c

   170	
   171	static void sysctl_test_dointvec_single_less_int_min(struct kunit *test)
   172	{
   173		struct ctl_table table = {
   174			.procname = "foo",
   175			.data		= &test_data.int_0001,
   176			.maxlen		= sizeof(int),
   177			.mode		= 0644,
   178			.proc_handler	= proc_dointvec,
   179			.extra1		= &i_zero,
   180			.extra2         = &i_one_hundred,
   181		};
   182		char input[32];
   183		size_t len = sizeof(input) - 1;
   184		loff_t pos = 0;
 > 185		long less_than_min = (long)INT_MIN - 1;
   186	
   187		KUNIT_EXPECT_LT(test, less_than_min, INT_MIN);
   188		KUNIT_EXPECT_LT(test,
   189				snprintf(input, sizeof(input), "%ld", less_than_min),
   190				sizeof(input));
   191	
   192		table.data = kunit_kzalloc(test, sizeof(int), GFP_USER);
   193		KUNIT_EXPECT_EQ(test, -EINVAL,
   194				proc_dointvec(&table, 1, input, &len, &pos));
   195		KUNIT_EXPECT_EQ(test, sizeof(input) - 1, len);
   196		KUNIT_EXPECT_EQ(test, 0, *(int *)table.data);
   197	}
   198	

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

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux