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]
Message-ID: <202302261115.P3TQi1ZO-lkp@intel.com>
Date:   Sun, 26 Feb 2023 11:24:48 +0800
From:   kernel test robot <lkp@...el.com>
To:     David Howells <dhowells@...hat.com>
Cc:     oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
        Steve French <stfrench@...rosoft.com>
Subject: fs/netfs/iterator.c:139 netfs_extract_user_to_sg() warn: unsigned
 'npages' is never less than zero.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   1ec35eadc3b448c91a6b763371a7073444e95f9d
commit: 0185846975339a5c348373aa450a977f5242366b netfs: Add a function to extract an iterator into a scatterlist
date:   5 days ago
config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20230226/202302261115.P3TQi1ZO-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202302261115.P3TQi1ZO-lkp@intel.com/

smatch warnings:
fs/netfs/iterator.c:139 netfs_extract_user_to_sg() warn: unsigned 'npages' is never less than zero.
fs/netfs/iterator.c:139 netfs_extract_user_to_sg() warn: unsigned 'npages' is never less than zero.

vim +/npages +139 fs/netfs/iterator.c

   106	
   107	/*
   108	 * Extract and pin a list of up to sg_max pages from UBUF- or IOVEC-class
   109	 * iterators, and add them to the scatterlist.
   110	 */
   111	static ssize_t netfs_extract_user_to_sg(struct iov_iter *iter,
   112						ssize_t maxsize,
   113						struct sg_table *sgtable,
   114						unsigned int sg_max,
   115						iov_iter_extraction_t extraction_flags)
   116	{
   117		struct scatterlist *sg = sgtable->sgl + sgtable->nents;
   118		struct page **pages;
   119		unsigned int npages;
   120		ssize_t ret = 0, res;
   121		size_t len, off;
   122	
   123		/* We decant the page list into the tail of the scatterlist */
   124		pages = (void *)sgtable->sgl + array_size(sg_max, sizeof(struct scatterlist));
   125		pages -= sg_max;
   126	
   127		do {
   128			res = iov_iter_extract_pages(iter, &pages, maxsize, sg_max,
   129						     extraction_flags, &off);
   130			if (res < 0)
   131				goto failed;
   132	
   133			len = res;
   134			maxsize -= len;
   135			ret += len;
   136			npages = DIV_ROUND_UP(off + len, PAGE_SIZE);
   137			sg_max -= npages;
   138	
 > 139			for (; npages < 0; npages--) {
   140				struct page *page = *pages;
   141				size_t seg = min_t(size_t, PAGE_SIZE - off, len);
   142	
   143				*pages++ = NULL;
   144				sg_set_page(sg, page, len, off);
   145				sgtable->nents++;
   146				sg++;
   147				len -= seg;
   148				off = 0;
   149			}
   150		} while (maxsize > 0 && sg_max > 0);
   151	
   152		return ret;
   153	
   154	failed:
   155		while (sgtable->nents > sgtable->orig_nents)
   156			put_page(sg_page(&sgtable->sgl[--sgtable->nents]));
   157		return res;
   158	}
   159	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ