lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <202210310759.iwMoLzLT-lkp@intel.com>
Date:   Mon, 31 Oct 2022 07:35:36 +0800
From:   kernel test robot <lkp@...el.com>
To:     Kenneth Lee <klee33@...edu>
Cc:     oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
        Marc Kleine-Budde <mkl@...gutronix.de>
Subject: drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:65: warning:
 array subscript 'struct kvaser_cmd_ext[0]' is partly outside array bounds of
 'unsigned char[32]'

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   30a0b95b1335e12efef89dd78518ed3e4a71a763
commit: 00784da3e6b8c1f0e58d813272503d014de8f64b can: kvaser_usb: kvaser_usb_hydra: Use kzalloc for allocating only one element
date:   8 weeks ago
config: i386-randconfig-r021-20221031
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=00784da3e6b8c1f0e58d813272503d014de8f64b
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 00784da3e6b8c1f0e58d813272503d014de8f64b
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make 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 <lkp@...el.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/byteorder/little_endian.h:5,
                    from arch/x86/include/uapi/asm/byteorder.h:5,
                    from include/asm-generic/bitops/le.h:6,
                    from arch/x86/include/asm/bitops.h:416,
                    from include/linux/bitops.h:68,
                    from include/linux/kernel.h:22,
                    from arch/x86/include/asm/percpu.h:27,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:55,
                    from include/linux/swait.h:7,
                    from include/linux/completion.h:12,
                    from drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:16:
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c: In function 'kvaser_usb_hydra_send_simple_cmd':
>> drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:65: warning: array subscript 'struct kvaser_cmd_ext[0]' is partly outside array bounds of 'unsigned char[32]' [-Warray-bounds]
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
   include/uapi/linux/byteorder/little_endian.h:37:51: note: in definition of macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:23: note: in expansion of macro 'le16_to_cpu'
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
         |                       ^~~~~~~~~~~
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:537:15: note: referencing an object of size 32 allocated by 'kzalloc'
     537 |         cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/byteorder/little_endian.h:5,
                    from arch/x86/include/uapi/asm/byteorder.h:5,
                    from include/asm-generic/bitops/le.h:6,
                    from arch/x86/include/asm/bitops.h:416,
                    from include/linux/bitops.h:68,
                    from include/linux/kernel.h:22,
                    from arch/x86/include/asm/percpu.h:27,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:55,
                    from include/linux/swait.h:7,
                    from include/linux/completion.h:12,
                    from drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:16:
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c: In function 'kvaser_usb_hydra_set_opt_mode':
>> drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:65: warning: array subscript 'struct kvaser_cmd_ext[0]' is partly outside array bounds of 'unsigned char[32]' [-Warray-bounds]
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
   include/uapi/linux/byteorder/little_endian.h:37:51: note: in definition of macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:23: note: in expansion of macro 'le16_to_cpu'
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
         |                       ^~~~~~~~~~~
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:1854:15: note: referencing an object of size 32 allocated by 'kzalloc'
    1854 |         cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/byteorder/little_endian.h:5,
                    from arch/x86/include/uapi/asm/byteorder.h:5,
                    from include/asm-generic/bitops/le.h:6,
                    from arch/x86/include/asm/bitops.h:416,
                    from include/linux/bitops.h:68,
                    from include/linux/kernel.h:22,
                    from arch/x86/include/asm/percpu.h:27,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:55,
                    from include/linux/swait.h:7,
                    from include/linux/completion.h:12,
                    from drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:16:
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c: In function 'kvaser_usb_hydra_set_data_bittiming':
>> drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:65: warning: array subscript 'struct kvaser_cmd_ext[0]' is partly outside array bounds of 'unsigned char[32]' [-Warray-bounds]
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
   include/uapi/linux/byteorder/little_endian.h:37:51: note: in definition of macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:23: note: in expansion of macro 'le16_to_cpu'
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
         |                       ^~~~~~~~~~~
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:1570:15: note: referencing an object of size 32 allocated by 'kzalloc'
    1570 |         cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/byteorder/little_endian.h:5,
                    from arch/x86/include/uapi/asm/byteorder.h:5,
                    from include/asm-generic/bitops/le.h:6,
                    from arch/x86/include/asm/bitops.h:416,
                    from include/linux/bitops.h:68,
                    from include/linux/kernel.h:22,
                    from arch/x86/include/asm/percpu.h:27,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:55,
                    from include/linux/swait.h:7,
                    from include/linux/completion.h:12,
                    from drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:16:
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c: In function 'kvaser_usb_hydra_set_bittiming':
>> drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:65: warning: array subscript 'struct kvaser_cmd_ext[0]' is partly outside array bounds of 'unsigned char[32]' [-Warray-bounds]
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
   include/uapi/linux/byteorder/little_endian.h:37:51: note: in definition of macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:23: note: in expansion of macro 'le16_to_cpu'
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
         |                       ^~~~~~~~~~~
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:1536:15: note: referencing an object of size 32 allocated by 'kzalloc'
    1536 |         cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/byteorder/little_endian.h:5,
                    from arch/x86/include/uapi/asm/byteorder.h:5,
                    from include/asm-generic/bitops/le.h:6,
                    from arch/x86/include/asm/bitops.h:416,
                    from include/linux/bitops.h:68,
                    from include/linux/kernel.h:22,
                    from arch/x86/include/asm/percpu.h:27,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:55,
                    from include/linux/swait.h:7,
                    from include/linux/completion.h:12,
                    from drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:16:
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c: In function 'kvaser_usb_hydra_get_single_capability':
>> drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:65: warning: array subscript 'struct kvaser_cmd_ext[0]' is partly outside array bounds of 'unsigned char[32]' [-Warray-bounds]
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
   include/uapi/linux/byteorder/little_endian.h:37:51: note: in definition of macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:23: note: in expansion of macro 'le16_to_cpu'
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
         |                       ^~~~~~~~~~~
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:738:15: note: referencing an object of size 32 allocated by 'kzalloc'
     738 |         cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/byteorder/little_endian.h:5,
                    from arch/x86/include/uapi/asm/byteorder.h:5,
                    from include/asm-generic/bitops/le.h:6,
                    from arch/x86/include/asm/bitops.h:416,
                    from include/linux/bitops.h:68,
                    from include/linux/kernel.h:22,
                    from arch/x86/include/asm/percpu.h:27,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:55,
                    from include/linux/swait.h:7,
                    from include/linux/completion.h:12,
                    from drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:16:
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c: In function 'kvaser_usb_hydra_get_software_details':
>> drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:65: warning: array subscript 'struct kvaser_cmd_ext[0]' is partly outside array bounds of 'unsigned char[32]' [-Warray-bounds]
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
   include/uapi/linux/byteorder/little_endian.h:37:51: note: in definition of macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:23: note: in expansion of macro 'le16_to_cpu'
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
         |                       ^~~~~~~~~~~
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:1714:15: note: referencing an object of size 32 allocated by 'kzalloc'
    1714 |         cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/byteorder/little_endian.h:5,
                    from arch/x86/include/uapi/asm/byteorder.h:5,
                    from include/asm-generic/bitops/le.h:6,
                    from arch/x86/include/asm/bitops.h:416,
                    from include/linux/bitops.h:68,
                    from include/linux/kernel.h:22,
                    from arch/x86/include/asm/percpu.h:27,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:55,
                    from include/linux/swait.h:7,
                    from include/linux/completion.h:12,
                    from drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:16:
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c: In function 'kvaser_usb_hydra_send_simple_cmd_async.constprop.isra':
>> drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:65: warning: array subscript 'struct kvaser_cmd_ext[0]' is partly outside array bounds of 'unsigned char[32]' [-Warray-bounds]
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
   include/uapi/linux/byteorder/little_endian.h:37:51: note: in definition of macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:23: note: in expansion of macro 'le16_to_cpu'
     489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
         |                       ^~~~~~~~~~~
   drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:576:15: note: referencing an object of size 32 allocated by 'kzalloc'
     576 |         cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +489 drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c

aec5fb2268b700 Jimmy Assarsson 2018-07-18  483  
aec5fb2268b700 Jimmy Assarsson 2018-07-18  484  static size_t kvaser_usb_hydra_cmd_size(struct kvaser_cmd *cmd)
aec5fb2268b700 Jimmy Assarsson 2018-07-18  485  {
aec5fb2268b700 Jimmy Assarsson 2018-07-18  486  	size_t ret;
aec5fb2268b700 Jimmy Assarsson 2018-07-18  487  
aec5fb2268b700 Jimmy Assarsson 2018-07-18  488  	if (cmd->header.cmd_no == CMD_EXTENDED)
aec5fb2268b700 Jimmy Assarsson 2018-07-18 @489  		ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
aec5fb2268b700 Jimmy Assarsson 2018-07-18  490  	else
aec5fb2268b700 Jimmy Assarsson 2018-07-18  491  		ret = sizeof(struct kvaser_cmd);
aec5fb2268b700 Jimmy Assarsson 2018-07-18  492  
aec5fb2268b700 Jimmy Assarsson 2018-07-18  493  	return ret;
aec5fb2268b700 Jimmy Assarsson 2018-07-18  494  }
aec5fb2268b700 Jimmy Assarsson 2018-07-18  495  

:::::: The code at line 489 was first introduced by commit
:::::: aec5fb2268b700f3c4e8481ab431eefcd33893f6 can: kvaser_usb: Add support for Kvaser USB hydra family

:::::: TO: Jimmy Assarsson <extja@...ser.com>
:::::: CC: Marc Kleine-Budde <mkl@...gutronix.de>

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

View attachment "config" of type "text/plain" (178628 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ