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 for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202107061359.Kbeos4Ny-lkp@intel.com>
Date:   Tue, 6 Jul 2021 13:24:02 +0800
From:   kernel test robot <lkp@...el.com>
To:     Jason Gunthorpe <jgg@...dia.com>
Cc:     clang-built-linux@...glegroups.com, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org
Subject: [jgunthorpe:vfio_reflck_cleanup 5/12]
 drivers/vfio/pci/vfio_pci.c:2218:2: warning: variable 'to_reset' is used
 uninitialized whenever 'for' loop exits because its condition is false

tree:   https://github.com/jgunthorpe/linux vfio_reflck_cleanup
head:   092133ba5f5e5101af30de3b9448693753131849
commit: 58e8550548d133d11ebdea41a627de87dacc4168 [5/12] vfio/pci: Change vfio_pci_try_bus_reset() to use the dev_set
config: x86_64-randconfig-a011-20210705 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 873e8b96b1226d64e4f95083147d8592ba7bd5d8)
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
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/jgunthorpe/linux/commit/58e8550548d133d11ebdea41a627de87dacc4168
        git remote add jgunthorpe https://github.com/jgunthorpe/linux
        git fetch --no-tags jgunthorpe vfio_reflck_cleanup
        git checkout 58e8550548d133d11ebdea41a627de87dacc4168
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

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 >>):

>> drivers/vfio/pci/vfio_pci.c:2218:2: warning: variable 'to_reset' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
           list_for_each_entry(cur, &dev_set->device_list, vdev.dev_set_list) {
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/list.h:629:7: note: expanded from macro 'list_for_each_entry'
                !list_entry_is_head(pos, head, member);                    \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/vfio/pci/vfio_pci.c:2224:7: note: uninitialized use occurs here
           if (!to_reset)
                ^~~~~~~~
   drivers/vfio/pci/vfio_pci.c:2218:2: note: remove the condition if it is always true
           list_for_each_entry(cur, &dev_set->device_list, vdev.dev_set_list) {
           ^
   include/linux/list.h:629:7: note: expanded from macro 'list_for_each_entry'
                !list_entry_is_head(pos, head, member);                    \
                ^
   drivers/vfio/pci/vfio_pci.c:2196:34: note: initialize the variable 'to_reset' to silence this warning
           struct vfio_pci_device *to_reset;
                                           ^
                                            = NULL
   1 warning generated.


vim +2218 drivers/vfio/pci/vfio_pci.c

  2177	
  2178	/*
  2179	 * If a bus or slot reset is available for the provided device and:
  2180	 *  - All of the devices affected by that bus or slot reset are unused
  2181	 *    (!refcnt)
  2182	 *  - At least one of the affected devices is marked dirty via
  2183	 *    needs_reset (such as by lack of FLR support)
  2184	 * Then attempt to perform that bus or slot reset.  Callers are required
  2185	 * to hold vdev->dev_set->lock, protecting the bus/slot reset group from
  2186	 * concurrent opens.
  2187	 *
  2188	 * NB: vfio-core considers a group to be viable even if some devices are
  2189	 * bound to drivers like pci-stub or pcieport.  Here we require all devices
  2190	 * to be bound to vfio_pci since that's the only way we can be sure they
  2191	 * stay put.
  2192	 */
  2193	static void vfio_pci_try_bus_reset(struct vfio_pci_device *vdev)
  2194	{
  2195		struct vfio_device_set *dev_set = vdev->vdev.dev_set;
  2196		struct vfio_pci_device *to_reset;
  2197		struct vfio_pci_device *cur;
  2198		int ret;
  2199	
  2200		if (pci_probe_reset_slot(vdev->pdev->slot) ||
  2201		    pci_probe_reset_bus(vdev->pdev->bus))
  2202			return;
  2203	
  2204		lockdep_assert_held(&vdev->vdev.dev_set->lock);
  2205	
  2206		/* All VFIO devices have a closed FD */
  2207		list_for_each_entry(cur, &dev_set->device_list, vdev.dev_set_list)
  2208			if (cur->vdev.open_count)
  2209				return;
  2210	
  2211		/* All devices in the group to be reset need VFIO devices */
  2212		if (vfio_pci_for_each_slot_or_bus(
  2213			    vdev->pdev, vfio_pci_check_all_devices_bound, dev_set,
  2214			    !pci_probe_reset_slot(vdev->pdev->slot)))
  2215			return;
  2216	
  2217		/* Does at least one need a reset? */
> 2218		list_for_each_entry(cur, &dev_set->device_list, vdev.dev_set_list) {
  2219			if (cur->needs_reset) {
  2220				to_reset = cur;
  2221				break;
  2222			}
  2223		}
  2224		if (!to_reset)
  2225			return;
  2226	
  2227		ret = pci_reset_bus(to_reset->pdev);
  2228		if (ret)
  2229			return;
  2230	
  2231		list_for_each_entry(cur, &dev_set->device_list, vdev.dev_set_list) {
  2232			cur->needs_reset = false;
  2233	
  2234			if (cur != to_reset && !disable_idle_d3)
  2235				vfio_pci_set_power_state(cur, PCI_D3hot);
  2236		}
  2237	}
  2238	

---
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" (45781 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ