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>] [day] [month] [year] [list]
Date:   Tue, 20 Jul 2021 02:17:25 +0800
From:   kernel test robot <lkp@...el.com>
To:     Souptick Joarder <jrdr.linux@...il.com>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Dan Carpenter <error27@...il.com>,
        John Hubbard <jhubbard@...dia.com>,
        Sasha Levin <sashal@...nel.org>
Subject: [linux-stable-rc:linux-4.4.y 671/1016]
 drivers/virt/fsl_hypervisor.c:299:17: warning: comparison of integer
 expressions of different signedness: 'unsigned int' and 'int'

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.4.y
head:   f299fb634f3b99d7462b2321c3ccf6773812a44e
commit: c0562d5581442d5df3395674f82b80e8c243505f [671/1016] drivers/virt/fsl_hypervisor: Fix error handling path
config: powerpc-randconfig-r005-20210719 (attached as .config)
compiler: powerpc-linux-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/commit/?id=c0562d5581442d5df3395674f82b80e8c243505f
        git remote add linux-stable-rc https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
        git fetch --no-tags linux-stable-rc linux-4.4.y
        git checkout c0562d5581442d5df3395674f82b80e8c243505f
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross ARCH=powerpc 

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

All warnings (new ones prefixed by >>):

   In file included from drivers/virt/fsl_hypervisor.c:32:
   include/linux/mm.h: In function 'is_vmalloc_addr':
   include/linux/mm.h:386:14: warning: comparison of integer expressions of different signedness: 'long unsigned int' and 'long int' [-Wsign-compare]
     386 |  return addr >= VMALLOC_START && addr < VMALLOC_END;
         |              ^~
   In file included from drivers/virt/fsl_hypervisor.c:33:
   include/linux/pagemap.h: In function 'fault_in_multipages_readable':
   include/linux/pagemap.h:632:16: warning: variable 'c' set but not used [-Wunused-but-set-variable]
     632 |  volatile char c;
         |                ^
   In file included from arch/powerpc/include/asm/fsl_hcalls.h:46,
                    from drivers/virt/fsl_hypervisor.c:44:
   arch/powerpc/include/asm/epapr_hcalls.h: In function 'epapr_hypercall':
   arch/powerpc/include/asm/epapr_hcalls.h:469:2: warning: 'register' is not at beginning of declaration [-Wold-style-declaration]
     469 |  unsigned long register r0 asm("r0");
         |  ^~~~~~~~
   arch/powerpc/include/asm/epapr_hcalls.h:470:2: warning: 'register' is not at beginning of declaration [-Wold-style-declaration]
     470 |  unsigned long register r3 asm("r3") = in[0];
         |  ^~~~~~~~
   arch/powerpc/include/asm/epapr_hcalls.h:471:2: warning: 'register' is not at beginning of declaration [-Wold-style-declaration]
     471 |  unsigned long register r4 asm("r4") = in[1];
         |  ^~~~~~~~
   arch/powerpc/include/asm/epapr_hcalls.h:472:2: warning: 'register' is not at beginning of declaration [-Wold-style-declaration]
     472 |  unsigned long register r5 asm("r5") = in[2];
         |  ^~~~~~~~
   arch/powerpc/include/asm/epapr_hcalls.h:473:2: warning: 'register' is not at beginning of declaration [-Wold-style-declaration]
     473 |  unsigned long register r6 asm("r6") = in[3];
         |  ^~~~~~~~
   arch/powerpc/include/asm/epapr_hcalls.h:474:2: warning: 'register' is not at beginning of declaration [-Wold-style-declaration]
     474 |  unsigned long register r7 asm("r7") = in[4];
         |  ^~~~~~~~
   arch/powerpc/include/asm/epapr_hcalls.h:475:2: warning: 'register' is not at beginning of declaration [-Wold-style-declaration]
     475 |  unsigned long register r8 asm("r8") = in[5];
         |  ^~~~~~~~
   arch/powerpc/include/asm/epapr_hcalls.h:476:2: warning: 'register' is not at beginning of declaration [-Wold-style-declaration]
     476 |  unsigned long register r9 asm("r9") = in[6];
         |  ^~~~~~~~
   arch/powerpc/include/asm/epapr_hcalls.h:477:2: warning: 'register' is not at beginning of declaration [-Wold-style-declaration]
     477 |  unsigned long register r10 asm("r10") = in[7];
         |  ^~~~~~~~
   arch/powerpc/include/asm/epapr_hcalls.h:478:2: warning: 'register' is not at beginning of declaration [-Wold-style-declaration]
     478 |  unsigned long register r11 asm("r11") = nr;
         |  ^~~~~~~~
   arch/powerpc/include/asm/epapr_hcalls.h:479:2: warning: 'register' is not at beginning of declaration [-Wold-style-declaration]
     479 |  unsigned long register r12 asm("r12");
         |  ^~~~~~~~
   drivers/virt/fsl_hypervisor.c: In function 'ioctl_memcpy':
   drivers/virt/fsl_hypervisor.c:173:20: warning: comparison of integer expressions of different signedness: '__u32' {aka 'unsigned int'} and 'int' [-Wsign-compare]
     173 |  if ((param.source == -1) == (param.target == -1))
         |                    ^~
   drivers/virt/fsl_hypervisor.c:173:44: warning: comparison of integer expressions of different signedness: '__u32' {aka 'unsigned int'} and 'int' [-Wsign-compare]
     173 |  if ((param.source == -1) == (param.target == -1))
         |                                            ^~
   drivers/virt/fsl_hypervisor.c:252:17: warning: comparison of integer expressions of different signedness: '__u32' {aka 'unsigned int'} and 'int' [-Wsign-compare]
     252 |   (param.source == -1) ? 0 : FOLL_WRITE,
         |                 ^~
   drivers/virt/fsl_hypervisor.c:256:17: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
     256 |  if (num_pinned != num_pages) {
         |                 ^~
   drivers/virt/fsl_hypervisor.c:266:19: warning: comparison of integer expressions of different signedness: '__u32' {aka 'unsigned int'} and 'int' [-Wsign-compare]
     266 |  if (param.source == -1) {
         |                   ^~
   drivers/virt/fsl_hypervisor.c:279:20: warning: comparison of integer expressions of different signedness: '__u32' {aka 'unsigned int'} and 'int' [-Wsign-compare]
     279 |   if (param.source == -1) {
         |                    ^~
>> drivers/virt/fsl_hypervisor.c:299:17: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
     299 |   for (i = 0; i < num_pinned; i++)
         |                 ^


vim +299 drivers/virt/fsl_hypervisor.c

   137	
   138	/*
   139	 * Ioctl interface for FSL_HV_IOCTL_MEMCPY
   140	 *
   141	 * The FH_MEMCPY hypercall takes an array of address/address/size structures
   142	 * to represent the data being copied.  As a convenience to the user, this
   143	 * ioctl takes a user-create buffer and a pointer to a guest physically
   144	 * contiguous buffer in the remote partition, and creates the
   145	 * address/address/size array for the hypercall.
   146	 */
   147	static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
   148	{
   149		struct fsl_hv_ioctl_memcpy param;
   150	
   151		struct page **pages = NULL;
   152		void *sg_list_unaligned = NULL;
   153		struct fh_sg_list *sg_list = NULL;
   154	
   155		unsigned int num_pages;
   156		unsigned long lb_offset; /* Offset within a page of the local buffer */
   157	
   158		unsigned int i;
   159		long ret = 0;
   160		int num_pinned = 0; /* return value from get_user_pages_fast() */
   161		phys_addr_t remote_paddr; /* The next address in the remote buffer */
   162		uint32_t count; /* The number of bytes left to copy */
   163	
   164		/* Get the parameters from the user */
   165		if (copy_from_user(&param, p, sizeof(struct fsl_hv_ioctl_memcpy)))
   166			return -EFAULT;
   167	
   168		/*
   169		 * One partition must be local, the other must be remote.  In other
   170		 * words, if source and target are both -1, or are both not -1, then
   171		 * return an error.
   172		 */
   173		if ((param.source == -1) == (param.target == -1))
   174			return -EINVAL;
   175	
   176		/*
   177		 * The array of pages returned by get_user_pages_fast() covers only
   178		 * page-aligned memory.  Since the user buffer is probably not
   179		 * page-aligned, we need to handle the discrepancy.
   180		 *
   181		 * We calculate the offset within a page of the S/G list, and make
   182		 * adjustments accordingly.  This will result in a page list that looks
   183		 * like this:
   184		 *
   185		 *      ----    <-- first page starts before the buffer
   186		 *     |    |
   187		 *     |////|-> ----
   188		 *     |////|  |    |
   189		 *      ----   |    |
   190		 *             |    |
   191		 *      ----   |    |
   192		 *     |////|  |    |
   193		 *     |////|  |    |
   194		 *     |////|  |    |
   195		 *      ----   |    |
   196		 *             |    |
   197		 *      ----   |    |
   198		 *     |////|  |    |
   199		 *     |////|  |    |
   200		 *     |////|  |    |
   201		 *      ----   |    |
   202		 *             |    |
   203		 *      ----   |    |
   204		 *     |////|  |    |
   205		 *     |////|-> ----
   206		 *     |    |   <-- last page ends after the buffer
   207		 *      ----
   208		 *
   209		 * The distance between the start of the first page and the start of the
   210		 * buffer is lb_offset.  The hashed (///) areas are the parts of the
   211		 * page list that contain the actual buffer.
   212		 *
   213		 * The advantage of this approach is that the number of pages is
   214		 * equal to the number of entries in the S/G list that we give to the
   215		 * hypervisor.
   216		 */
   217		lb_offset = param.local_vaddr & (PAGE_SIZE - 1);
   218		if (param.count == 0 ||
   219		    param.count > U64_MAX - lb_offset - PAGE_SIZE + 1)
   220			return -EINVAL;
   221		num_pages = (param.count + lb_offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
   222	
   223		/* Allocate the buffers we need */
   224	
   225		/*
   226		 * 'pages' is an array of struct page pointers that's initialized by
   227		 * get_user_pages_fast().
   228		 */
   229		pages = kzalloc(num_pages * sizeof(struct page *), GFP_KERNEL);
   230		if (!pages) {
   231			pr_debug("fsl-hv: could not allocate page list\n");
   232			return -ENOMEM;
   233		}
   234	
   235		/*
   236		 * sg_list is the list of fh_sg_list objects that we pass to the
   237		 * hypervisor.
   238		 */
   239		sg_list_unaligned = kmalloc(num_pages * sizeof(struct fh_sg_list) +
   240			sizeof(struct fh_sg_list) - 1, GFP_KERNEL);
   241		if (!sg_list_unaligned) {
   242			pr_debug("fsl-hv: could not allocate S/G list\n");
   243			ret = -ENOMEM;
   244			goto free_pages;
   245		}
   246		sg_list = PTR_ALIGN(sg_list_unaligned, sizeof(struct fh_sg_list));
   247	
   248		/* Get the physical addresses of the source buffer */
   249		down_read(&current->mm->mmap_sem);
   250		num_pinned = get_user_pages(current, current->mm,
   251			param.local_vaddr - lb_offset, num_pages,
   252			(param.source == -1) ? 0 : FOLL_WRITE,
   253			pages, NULL);
   254		up_read(&current->mm->mmap_sem);
   255	
   256		if (num_pinned != num_pages) {
   257			pr_debug("fsl-hv: could not lock source buffer\n");
   258			ret = (num_pinned < 0) ? num_pinned : -EFAULT;
   259			goto exit;
   260		}
   261	
   262		/*
   263		 * Build the fh_sg_list[] array.  The first page is special
   264		 * because it's misaligned.
   265		 */
   266		if (param.source == -1) {
   267			sg_list[0].source = page_to_phys(pages[0]) + lb_offset;
   268			sg_list[0].target = param.remote_paddr;
   269		} else {
   270			sg_list[0].source = param.remote_paddr;
   271			sg_list[0].target = page_to_phys(pages[0]) + lb_offset;
   272		}
   273		sg_list[0].size = min_t(uint64_t, param.count, PAGE_SIZE - lb_offset);
   274	
   275		remote_paddr = param.remote_paddr + sg_list[0].size;
   276		count = param.count - sg_list[0].size;
   277	
   278		for (i = 1; i < num_pages; i++) {
   279			if (param.source == -1) {
   280				/* local to remote */
   281				sg_list[i].source = page_to_phys(pages[i]);
   282				sg_list[i].target = remote_paddr;
   283			} else {
   284				/* remote to local */
   285				sg_list[i].source = remote_paddr;
   286				sg_list[i].target = page_to_phys(pages[i]);
   287			}
   288			sg_list[i].size = min_t(uint64_t, count, PAGE_SIZE);
   289	
   290			remote_paddr += sg_list[i].size;
   291			count -= sg_list[i].size;
   292		}
   293	
   294		param.ret = fh_partition_memcpy(param.source, param.target,
   295			virt_to_phys(sg_list), num_pages);
   296	
   297	exit:
   298		if (pages && (num_pinned > 0)) {
 > 299			for (i = 0; i < num_pinned; i++)
   300				put_page(pages[i]);
   301		}
   302	
   303		kfree(sg_list_unaligned);
   304	free_pages:
   305		kfree(pages);
   306	
   307		if (!ret)
   308			if (copy_to_user(&p->ret, &param.ret, sizeof(__u32)))
   309				return -EFAULT;
   310	
   311		return ret;
   312	}
   313	

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

Download attachment ".config.gz" of type "application/gzip" (23553 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ