[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202206060703.BhX0IBxu-lkp@intel.com>
Date: Mon, 6 Jun 2022 07:45:06 +0800
From: kernel test robot <lkp@...el.com>
To: Kees Cook <keescook@...omium.org>
Cc: kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org
Subject: drivers/hid/hid-hyperv.c:218:9: sparse: sparse: cast from restricted
__le16
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: d717180e7f9775d468f415c10a4a474640146001
commit: f68f2ff91512c199ec24883001245912afc17873 fortify: Detect struct member overflows in memcpy() at compile-time
date: 4 months ago
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20220606/202206060703.BhX0IBxu-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-1) 11.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-18-g56afb504-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f68f2ff91512c199ec24883001245912afc17873
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout f68f2ff91512c199ec24883001245912afc17873
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash drivers/hid/ samples/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>
sparse warnings: (new ones prefixed by >>)
drivers/hid/hid-hyperv.c:202:40: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] report_desc_size @@ got restricted __le16 [usertype] wDescriptorLength @@
drivers/hid/hid-hyperv.c:202:40: sparse: expected unsigned int [usertype] report_desc_size
drivers/hid/hid-hyperv.c:202:40: sparse: got restricted __le16 [usertype] wDescriptorLength
>> drivers/hid/hid-hyperv.c:218:9: sparse: sparse: cast from restricted __le16
vim +218 drivers/hid/hid-hyperv.c
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 180
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 181 static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 182 struct synthhid_device_info *device_info)
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 183 {
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 184 int ret = 0;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 185 struct hid_descriptor *desc;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 186 struct mousevsc_prt_msg ack;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 187
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 188 input_device->dev_info_status = -ENOMEM;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 189
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 190 input_device->hid_dev_info = device_info->hid_dev_info;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 191 desc = &device_info->hid_descriptor;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 192 if (desc->bLength == 0)
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 193 goto cleanup;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 194
af13f9ed6f9aa6 Dexuan Cui 2019-11-19 195 /* The pointer is not NULL when we resume from hibernation */
af13f9ed6f9aa6 Dexuan Cui 2019-11-19 196 kfree(input_device->hid_desc);
a4a23f6d68ad2c Thomas Meyer 2013-06-01 197 input_device->hid_desc = kmemdup(desc, desc->bLength, GFP_ATOMIC);
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 198
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 199 if (!input_device->hid_desc)
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 200 goto cleanup;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 201
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 @202 input_device->report_desc_size = desc->desc[0].wDescriptorLength;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 203 if (input_device->report_desc_size == 0) {
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 204 input_device->dev_info_status = -EINVAL;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 205 goto cleanup;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 206 }
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 207
af13f9ed6f9aa6 Dexuan Cui 2019-11-19 208 /* The pointer is not NULL when we resume from hibernation */
af13f9ed6f9aa6 Dexuan Cui 2019-11-19 209 kfree(input_device->report_desc);
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 210 input_device->report_desc = kzalloc(input_device->report_desc_size,
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 211 GFP_ATOMIC);
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 212
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 213 if (!input_device->report_desc) {
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 214 input_device->dev_info_status = -ENOMEM;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 215 goto cleanup;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 216 }
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 217
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 @218 memcpy(input_device->report_desc,
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 219 ((unsigned char *)desc) + desc->bLength,
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 220 desc->desc[0].wDescriptorLength);
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 221
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 222 /* Send the ack */
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 223 memset(&ack, 0, sizeof(struct mousevsc_prt_msg));
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 224
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 225 ack.type = PIPE_MESSAGE_DATA;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 226 ack.size = sizeof(struct synthhid_device_info_ack);
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 227
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 228 ack.ack.header.type = SYNTH_HID_INITIAL_DEVICE_INFO_ACK;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 229 ack.ack.header.size = 1;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 230 ack.ack.reserved = 0;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 231
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 232 ret = vmbus_sendpacket(input_device->device->channel,
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 233 &ack,
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 234 sizeof(struct pipe_prt_msg) - sizeof(unsigned char) +
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 235 sizeof(struct synthhid_device_info_ack),
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 236 (unsigned long)&ack,
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 237 VM_PKT_DATA_INBAND,
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 238 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 239
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 240 if (!ret)
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 241 input_device->dev_info_status = 0;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 242
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 243 cleanup:
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 244 complete(&input_device->wait_event);
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 245
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 246 return;
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 247 }
b95f5bcb811e39 K. Y. Srinivasan 2011-11-17 248
:::::: The code at line 218 was first introduced by commit
:::::: b95f5bcb811e3905b5376f87789da8d097fee682 HID: Move the hid-hyperv driver out of staging
:::::: TO: K. Y. Srinivasan <kys@...rosoft.com>
:::::: CC: Jiri Kosina <jkosina@...e.cz>
--
0-DAY CI Kernel Test Service
https://01.org/lkp
Powered by blists - more mailing lists