Re: [PATCH] VMCI: Enforce queuepair max size for IOCTL_VMCI_QUEUEPAIR_ALLOC

From: kernel test robot
Date: Mon Jan 11 2021 - 10:46:45 EST


Hi Jorgen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on char-misc/char-misc-testing linus/master v5.11-rc3 next-20210111]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Jorgen-Hansen/VMCI-Enforce-queuepair-max-size-for-IOCTL_VMCI_QUEUEPAIR_ALLOC/20210111-204259
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 09162bc32c880a791c6c0668ce0745cf7958f576
config: i386-randconfig-s001-20210111 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.3-208-g46a52ca4-dirty
# https://github.com/0day-ci/linux/commit/0923aeac7af9635dd6bf0141e8188f4815e573d2
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jorgen-Hansen/VMCI-Enforce-queuepair-max-size-for-IOCTL_VMCI_QUEUEPAIR_ALLOC/20210111-204259
git checkout 0923aeac7af9635dd6bf0141e8188f4815e573d2
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386

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


"sparse warnings: (new ones prefixed by >>)"
>> drivers/misc/vmw_vmci/vmci_queue_pair.c:533:20: sparse: sparse: incompatible types in comparison expression (different type sizes):
>> drivers/misc/vmw_vmci/vmci_queue_pair.c:533:20: sparse: unsigned int *
>> drivers/misc/vmw_vmci/vmci_queue_pair.c:533:20: sparse: unsigned long *

vim +533 drivers/misc/vmw_vmci/vmci_queue_pair.c

519
520 /*
521 * Allocates kernel VA space of specified size plus space for the queue
522 * and kernel interface. This is different from the guest queue allocator,
523 * because we do not allocate our own queue header/data pages here but
524 * share those of the guest.
525 */
526 static struct vmci_queue *qp_host_alloc_queue(u64 size)
527 {
528 struct vmci_queue *queue;
529 size_t queue_page_size;
530 u64 num_pages;
531 const size_t queue_size = sizeof(*queue) + sizeof(*(queue->kernel_if));
532
> 533 if (size > min(VMCI_MAX_GUEST_QP_MEMORY, SIZE_MAX - PAGE_SIZE))
534 return NULL;
535 num_pages = DIV_ROUND_UP(size, PAGE_SIZE) + 1;
536 if (num_pages > (SIZE_MAX - queue_size) /
537 sizeof(*queue->kernel_if->u.h.page))
538 return NULL;
539
540 queue_page_size = num_pages * sizeof(*queue->kernel_if->u.h.page);
541
542 queue = kzalloc(queue_size + queue_page_size, GFP_KERNEL);
543 if (queue) {
544 queue->q_header = NULL;
545 queue->saved_header = NULL;
546 queue->kernel_if = (struct vmci_queue_kern_if *)(queue + 1);
547 queue->kernel_if->host = true;
548 queue->kernel_if->mutex = NULL;
549 queue->kernel_if->num_pages = num_pages;
550 queue->kernel_if->u.h.header_page =
551 (struct page **)((u8 *)queue + queue_size);
552 queue->kernel_if->u.h.page =
553 &queue->kernel_if->u.h.header_page[1];
554 }
555
556 return queue;
557 }
558

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip