All of lore.kernel.org
 help / color / mirror / Atom feed
* [openeuler:OLK-5.10 20910/30000] drivers/iommu/intel/iommu.c:5894 intel_iommu_unmap() warn: variable dereferenced before check 'gather' (see line 5885)
@ 2024-09-09 12:03 kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2024-09-09 12:03 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Jason Zeng <jason.zeng@intel.com>

tree:   https://gitee.com/openeuler/kernel.git OLK-5.10
head:   3e6d44ea60eb8609ba59273c12276e3236cd76b2
commit: 004c9426acfc9d9dcb19ec63f0f6aa2f754a06ee [20910/30000] iommu/vt-d: Avoid superfluous IOTLB tracking in lazy mode
:::::: branch date: 11 hours ago
:::::: commit date: 10 months ago
config: x86_64-randconfig-161-20240906 (https://download.01.org/0day-ci/archive/20240909/202409091900.JffgO6qd-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202409091900.JffgO6qd-lkp@intel.com/

New smatch warnings:
drivers/iommu/intel/iommu.c:5894 intel_iommu_unmap() warn: variable dereferenced before check 'gather' (see line 5885)

Old smatch warnings:
drivers/iommu/intel/iommu.c:263 context_copied() warn: test_bit() takes a bit number
drivers/iommu/intel/iommu.c:951 device_to_iommu() error: we previously assumed 'pdev' could be null (see line 924)
drivers/iommu/intel/iommu.c:275 clear_context_copied() warn: clear_bit() takes a bit number
drivers/iommu/intel/iommu.c:2471 __domain_mapping() error: we previously assumed 'sg' could be null (see line 2462)
drivers/iommu/intel/iommu.c:269 set_context_copied() warn: set_bit() takes a bit number

vim +/gather +5894 drivers/iommu/intel/iommu.c

38717946425792 drivers/pci/intel-iommu.c   Kay, Allen M    2008-09-09  5865  
5009065d38c954 drivers/iommu/intel-iommu.c Ohad Ben-Cohen  2011-11-10  5866  static size_t intel_iommu_unmap(struct iommu_domain *domain,
56f8af5e9d38f1 drivers/iommu/intel-iommu.c Will Deacon     2019-07-02  5867  				unsigned long iova, size_t size,
56f8af5e9d38f1 drivers/iommu/intel-iommu.c Will Deacon     2019-07-02  5868  				struct iommu_iotlb_gather *gather)
38717946425792 drivers/pci/intel-iommu.c   Kay, Allen M    2008-09-09  5869  {
00a77deb0f2f2c drivers/iommu/intel-iommu.c Joerg Roedel    2015-03-26  5870  	struct dmar_domain *dmar_domain = to_dmar_domain(domain);
ea8ea460c9ace6 drivers/iommu/intel-iommu.c David Woodhouse 2014-03-05  5871  	unsigned long start_pfn, last_pfn;
4a2e7b3a540ffb drivers/iommu/intel/iommu.c Tom Murphy      2020-11-24  5872  	int level = 0;
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5873  
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5874  	/* Cope with horrid API which requires us to unmap more than the
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5875  	   size argument if it happens to be a large-page mapping. */
dc02e46e8d0234 drivers/iommu/intel-iommu.c Joerg Roedel    2015-08-13  5876  	BUG_ON(!pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT, &level));
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5877  
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5878  	if (size < VTD_PAGE_SIZE << level_to_offset_bits(level))
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5879  		size = VTD_PAGE_SIZE << level_to_offset_bits(level);
4b99d3527041be drivers/pci/intel-iommu.c   Sheng Yang      2009-07-08  5880  
ea8ea460c9ace6 drivers/iommu/intel-iommu.c David Woodhouse 2014-03-05  5881  	start_pfn = iova >> VTD_PAGE_SHIFT;
ea8ea460c9ace6 drivers/iommu/intel-iommu.c David Woodhouse 2014-03-05  5882  	last_pfn = (iova + size - 1) >> VTD_PAGE_SHIFT;
ea8ea460c9ace6 drivers/iommu/intel-iommu.c David Woodhouse 2014-03-05  5883  
4a2e7b3a540ffb drivers/iommu/intel/iommu.c Tom Murphy      2020-11-24  5884  	gather->freelist = domain_unmap(dmar_domain, start_pfn,
4a2e7b3a540ffb drivers/iommu/intel/iommu.c Tom Murphy      2020-11-24 @5885  					last_pfn, gather->freelist);
fe40f1e020d092 drivers/pci/intel-iommu.c   Weidong Han     2008-12-08  5886  
163cc52ccd2cc5 drivers/pci/intel-iommu.c   David Woodhouse 2009-06-28  5887  	if (dmar_domain->max_addr == iova + size)
163cc52ccd2cc5 drivers/pci/intel-iommu.c   David Woodhouse 2009-06-28  5888  		dmar_domain->max_addr = iova;
b146a1c9f7f1fe drivers/pci/intel-iommu.c   Joerg Roedel    2010-01-20  5889  
004c9426acfc9d drivers/iommu/intel/iommu.c Jacob Pan       2023-02-16  5890  	/*
004c9426acfc9d drivers/iommu/intel/iommu.c Jacob Pan       2023-02-16  5891  	 * We do not use page-selective IOTLB invalidation in flush queue,
004c9426acfc9d drivers/iommu/intel/iommu.c Jacob Pan       2023-02-16  5892  	 * so there is no need to track page and sync iotlb.
004c9426acfc9d drivers/iommu/intel/iommu.c Jacob Pan       2023-02-16  5893  	 */
004c9426acfc9d drivers/iommu/intel/iommu.c Jacob Pan       2023-02-16 @5894  	if (!(gather && gather->queued))
4a2e7b3a540ffb drivers/iommu/intel/iommu.c Tom Murphy      2020-11-24  5895  		iommu_iotlb_gather_add_page(domain, gather, iova, size);
4a2e7b3a540ffb drivers/iommu/intel/iommu.c Tom Murphy      2020-11-24  5896  
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5897  	return size;
38717946425792 drivers/pci/intel-iommu.c   Kay, Allen M    2008-09-09  5898  }
38717946425792 drivers/pci/intel-iommu.c   Kay, Allen M    2008-09-09  5899  

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [openeuler:OLK-5.10 20910/30000] drivers/iommu/intel/iommu.c:5894 intel_iommu_unmap() warn: variable dereferenced before check 'gather' (see line 5885)
@ 2024-09-10  9:30 Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2024-09-10  9:30 UTC (permalink / raw)
  To: oe-kbuild, kernel, Jason Zeng; +Cc: lkp, oe-kbuild-all

tree:   https://gitee.com/openeuler/kernel.git OLK-5.10
head:   3e6d44ea60eb8609ba59273c12276e3236cd76b2
commit: 004c9426acfc9d9dcb19ec63f0f6aa2f754a06ee [20910/30000] iommu/vt-d: Avoid superfluous IOTLB tracking in lazy mode
config: x86_64-randconfig-161-20240906 (https://download.01.org/0day-ci/archive/20240909/202409091900.JffgO6qd-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202409091900.JffgO6qd-lkp@intel.com/

New smatch warnings:
drivers/iommu/intel/iommu.c:5894 intel_iommu_unmap() warn: variable dereferenced before check 'gather' (see line 5885)

Old smatch warnings:
drivers/iommu/intel/iommu.c:951 device_to_iommu() error: we previously assumed 'pdev' could be null (see line 924)
drivers/iommu/intel/iommu.c:2471 __domain_mapping() error: we previously assumed 'sg' could be null (see line 2462)

vim +/gather +5894 drivers/iommu/intel/iommu.c

5009065d38c954 drivers/iommu/intel-iommu.c Ohad Ben-Cohen  2011-11-10  5866  static size_t intel_iommu_unmap(struct iommu_domain *domain,
56f8af5e9d38f1 drivers/iommu/intel-iommu.c Will Deacon     2019-07-02  5867  				unsigned long iova, size_t size,
56f8af5e9d38f1 drivers/iommu/intel-iommu.c Will Deacon     2019-07-02  5868  				struct iommu_iotlb_gather *gather)
38717946425792 drivers/pci/intel-iommu.c   Kay, Allen M    2008-09-09  5869  {
00a77deb0f2f2c drivers/iommu/intel-iommu.c Joerg Roedel    2015-03-26  5870  	struct dmar_domain *dmar_domain = to_dmar_domain(domain);
ea8ea460c9ace6 drivers/iommu/intel-iommu.c David Woodhouse 2014-03-05  5871  	unsigned long start_pfn, last_pfn;
4a2e7b3a540ffb drivers/iommu/intel/iommu.c Tom Murphy      2020-11-24  5872  	int level = 0;
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5873  
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5874  	/* Cope with horrid API which requires us to unmap more than the
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5875  	   size argument if it happens to be a large-page mapping. */
dc02e46e8d0234 drivers/iommu/intel-iommu.c Joerg Roedel    2015-08-13  5876  	BUG_ON(!pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT, &level));
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5877  
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5878  	if (size < VTD_PAGE_SIZE << level_to_offset_bits(level))
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5879  		size = VTD_PAGE_SIZE << level_to_offset_bits(level);
4b99d3527041be drivers/pci/intel-iommu.c   Sheng Yang      2009-07-08  5880  
ea8ea460c9ace6 drivers/iommu/intel-iommu.c David Woodhouse 2014-03-05  5881  	start_pfn = iova >> VTD_PAGE_SHIFT;
ea8ea460c9ace6 drivers/iommu/intel-iommu.c David Woodhouse 2014-03-05  5882  	last_pfn = (iova + size - 1) >> VTD_PAGE_SHIFT;
ea8ea460c9ace6 drivers/iommu/intel-iommu.c David Woodhouse 2014-03-05  5883  
4a2e7b3a540ffb drivers/iommu/intel/iommu.c Tom Murphy      2020-11-24  5884  	gather->freelist = domain_unmap(dmar_domain, start_pfn,
                                                                                ^^^^^^^^^^^^^^^^
This code assumes gather is a valid pointer

4a2e7b3a540ffb drivers/iommu/intel/iommu.c Tom Murphy      2020-11-24 @5885  					last_pfn, gather->freelist);
                                                                                                                          ^^^^^^^^^^^^^^^^

fe40f1e020d092 drivers/pci/intel-iommu.c   Weidong Han     2008-12-08  5886  
163cc52ccd2cc5 drivers/pci/intel-iommu.c   David Woodhouse 2009-06-28  5887  	if (dmar_domain->max_addr == iova + size)
163cc52ccd2cc5 drivers/pci/intel-iommu.c   David Woodhouse 2009-06-28  5888  		dmar_domain->max_addr = iova;
b146a1c9f7f1fe drivers/pci/intel-iommu.c   Joerg Roedel    2010-01-20  5889  
004c9426acfc9d drivers/iommu/intel/iommu.c Jacob Pan       2023-02-16  5890  	/*
004c9426acfc9d drivers/iommu/intel/iommu.c Jacob Pan       2023-02-16  5891  	 * We do not use page-selective IOTLB invalidation in flush queue,
004c9426acfc9d drivers/iommu/intel/iommu.c Jacob Pan       2023-02-16  5892  	 * so there is no need to track page and sync iotlb.
004c9426acfc9d drivers/iommu/intel/iommu.c Jacob Pan       2023-02-16  5893  	 */
004c9426acfc9d drivers/iommu/intel/iommu.c Jacob Pan       2023-02-16 @5894  	if (!(gather && gather->queued))
                                                                                      ^^^^^^
Checked too late

4a2e7b3a540ffb drivers/iommu/intel/iommu.c Tom Murphy      2020-11-24  5895  		iommu_iotlb_gather_add_page(domain, gather, iova, size);
4a2e7b3a540ffb drivers/iommu/intel/iommu.c Tom Murphy      2020-11-24  5896  
5cf0a76fa2179d drivers/iommu/intel-iommu.c David Woodhouse 2014-03-19  5897  	return size;
38717946425792 drivers/pci/intel-iommu.c   Kay, Allen M    2008-09-09  5898  }

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-10  9:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-09 12:03 [openeuler:OLK-5.10 20910/30000] drivers/iommu/intel/iommu.c:5894 intel_iommu_unmap() warn: variable dereferenced before check 'gather' (see line 5885) kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2024-09-10  9:30 Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.