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: <202201281547.sPuZ2yPF-lkp@intel.com>
Date:   Fri, 28 Jan 2022 15:28:15 +0800
From:   kernel test robot <lkp@...el.com>
To:     Philip Yang <Philip.Yang@....com>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        Alex Deucher <alexander.deucher@....com>,
        Felix Kuehling <Felix.Kuehling@....com>
Subject: [agd5f:drm-next 185/212]
 drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.c:2067:22: warning: variable
 'p' set but not used

tree:   https://gitlab.freedesktop.org/agd5f/linux.git drm-next
head:   af60f9540e16fe6300d2e57f69484d364f76da34
commit: 367c9b0f1b8750a704070e7ae85234d591290434 [185/212] drm/amdkfd: Ensure mm remain valid in svm deferred_list work
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20220128/202201281547.sPuZ2yPF-lkp@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        git remote add agd5f https://gitlab.freedesktop.org/agd5f/linux.git
        git fetch --no-tags agd5f drm-next
        git checkout 367c9b0f1b8750a704070e7ae85234d591290434
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/

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/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.c: In function 'svm_range_deferred_list_work':
>> drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.c:2067:22: warning: variable 'p' set but not used [-Wunused-but-set-variable]
    2067 |  struct kfd_process *p;
         |                      ^


vim +/p +2067 drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.c

373e3ccd859b4b Philip Yang    2021-04-19  2061  
4683cfecadeb38 Philip Yang    2020-04-08  2062  static void svm_range_deferred_list_work(struct work_struct *work)
4683cfecadeb38 Philip Yang    2020-04-08  2063  {
4683cfecadeb38 Philip Yang    2020-04-08  2064  	struct svm_range_list *svms;
4683cfecadeb38 Philip Yang    2020-04-08  2065  	struct svm_range *prange;
4683cfecadeb38 Philip Yang    2020-04-08  2066  	struct mm_struct *mm;
a0c55ecee10055 Philip Yang    2021-11-16 @2067  	struct kfd_process *p;
4683cfecadeb38 Philip Yang    2020-04-08  2068  
4683cfecadeb38 Philip Yang    2020-04-08  2069  	svms = container_of(work, struct svm_range_list, deferred_list_work);
4683cfecadeb38 Philip Yang    2020-04-08  2070  	pr_debug("enter svms 0x%p\n", svms);
4683cfecadeb38 Philip Yang    2020-04-08  2071  
a0c55ecee10055 Philip Yang    2021-11-16  2072  	p = container_of(svms, struct kfd_process, svms);
367c9b0f1b8750 Philip Yang    2022-01-18  2073  
367c9b0f1b8750 Philip Yang    2022-01-18  2074  	spin_lock(&svms->deferred_list_lock);
367c9b0f1b8750 Philip Yang    2022-01-18  2075  	while (!list_empty(&svms->deferred_range_list)) {
367c9b0f1b8750 Philip Yang    2022-01-18  2076  		prange = list_first_entry(&svms->deferred_range_list,
367c9b0f1b8750 Philip Yang    2022-01-18  2077  					  struct svm_range, deferred_list);
367c9b0f1b8750 Philip Yang    2022-01-18  2078  		spin_unlock(&svms->deferred_list_lock);
367c9b0f1b8750 Philip Yang    2022-01-18  2079  
367c9b0f1b8750 Philip Yang    2022-01-18  2080  		pr_debug("prange 0x%p [0x%lx 0x%lx] op %d\n", prange,
367c9b0f1b8750 Philip Yang    2022-01-18  2081  			 prange->start, prange->last, prange->work_item.op);
367c9b0f1b8750 Philip Yang    2022-01-18  2082  
367c9b0f1b8750 Philip Yang    2022-01-18  2083  		mm = prange->work_item.mm;
a44fe9ee051aca Felix Kuehling 2021-11-05  2084  retry:
4683cfecadeb38 Philip Yang    2020-04-08  2085  		mmap_write_lock(mm);
4683cfecadeb38 Philip Yang    2020-04-08  2086  
a0c55ecee10055 Philip Yang    2021-11-16  2087  		/* Checking for the need to drain retry faults must be inside
a44fe9ee051aca Felix Kuehling 2021-11-05  2088  		 * mmap write lock to serialize with munmap notifiers.
4683cfecadeb38 Philip Yang    2020-04-08  2089  		 */
2e4477282c8cff Philip Yang    2021-11-19  2090  		if (unlikely(atomic_read(&svms->drain_pagefaults))) {
a44fe9ee051aca Felix Kuehling 2021-11-05  2091  			mmap_write_unlock(mm);
a44fe9ee051aca Felix Kuehling 2021-11-05  2092  			svm_range_drain_retry_fault(svms);
a44fe9ee051aca Felix Kuehling 2021-11-05  2093  			goto retry;
a44fe9ee051aca Felix Kuehling 2021-11-05  2094  		}
a0c55ecee10055 Philip Yang    2021-11-16  2095  
367c9b0f1b8750 Philip Yang    2022-01-18  2096  		/* Remove from deferred_list must be inside mmap write lock, for
367c9b0f1b8750 Philip Yang    2022-01-18  2097  		 * two race cases:
367c9b0f1b8750 Philip Yang    2022-01-18  2098  		 * 1. unmap_from_cpu may change work_item.op and add the range
367c9b0f1b8750 Philip Yang    2022-01-18  2099  		 *    to deferred_list again, cause use after free bug.
367c9b0f1b8750 Philip Yang    2022-01-18  2100  		 * 2. svm_range_list_lock_and_flush_work may hold mmap write
367c9b0f1b8750 Philip Yang    2022-01-18  2101  		 *    lock and continue because deferred_list is empty, but
367c9b0f1b8750 Philip Yang    2022-01-18  2102  		 *    deferred_list work is actually waiting for mmap lock.
367c9b0f1b8750 Philip Yang    2022-01-18  2103  		 */
a0c55ecee10055 Philip Yang    2021-11-16  2104  		spin_lock(&svms->deferred_list_lock);
4683cfecadeb38 Philip Yang    2020-04-08  2105  		list_del_init(&prange->deferred_list);
4683cfecadeb38 Philip Yang    2020-04-08  2106  		spin_unlock(&svms->deferred_list_lock);
4683cfecadeb38 Philip Yang    2020-04-08  2107  
a0c55ecee10055 Philip Yang    2021-11-16  2108  		mutex_lock(&svms->lock);
0b0e518d61af8e Felix Kuehling 2021-02-24  2109  		mutex_lock(&prange->migrate_mutex);
4683cfecadeb38 Philip Yang    2020-04-08  2110  		while (!list_empty(&prange->child_list)) {
4683cfecadeb38 Philip Yang    2020-04-08  2111  			struct svm_range *pchild;
4683cfecadeb38 Philip Yang    2020-04-08  2112  
4683cfecadeb38 Philip Yang    2020-04-08  2113  			pchild = list_first_entry(&prange->child_list,
4683cfecadeb38 Philip Yang    2020-04-08  2114  						struct svm_range, child_list);
4683cfecadeb38 Philip Yang    2020-04-08  2115  			pr_debug("child prange 0x%p op %d\n", pchild,
4683cfecadeb38 Philip Yang    2020-04-08  2116  				 pchild->work_item.op);
4683cfecadeb38 Philip Yang    2020-04-08  2117  			list_del_init(&pchild->child_list);
367c9b0f1b8750 Philip Yang    2022-01-18  2118  			svm_range_handle_list_op(svms, pchild, mm);
4683cfecadeb38 Philip Yang    2020-04-08  2119  		}
0b0e518d61af8e Felix Kuehling 2021-02-24  2120  		mutex_unlock(&prange->migrate_mutex);
4683cfecadeb38 Philip Yang    2020-04-08  2121  
367c9b0f1b8750 Philip Yang    2022-01-18  2122  		svm_range_handle_list_op(svms, prange, mm);
4683cfecadeb38 Philip Yang    2020-04-08  2123  		mutex_unlock(&svms->lock);
367c9b0f1b8750 Philip Yang    2022-01-18  2124  		mmap_write_unlock(mm);
367c9b0f1b8750 Philip Yang    2022-01-18  2125  
367c9b0f1b8750 Philip Yang    2022-01-18  2126  		/* Pairs with mmget in svm_range_add_list_work */
367c9b0f1b8750 Philip Yang    2022-01-18  2127  		mmput(mm);
4683cfecadeb38 Philip Yang    2020-04-08  2128  
4683cfecadeb38 Philip Yang    2020-04-08  2129  		spin_lock(&svms->deferred_list_lock);
4683cfecadeb38 Philip Yang    2020-04-08  2130  	}
4683cfecadeb38 Philip Yang    2020-04-08  2131  	spin_unlock(&svms->deferred_list_lock);
4683cfecadeb38 Philip Yang    2020-04-08  2132  	pr_debug("exit svms 0x%p\n", svms);
4683cfecadeb38 Philip Yang    2020-04-08  2133  }
4683cfecadeb38 Philip Yang    2020-04-08  2134  

:::::: The code at line 2067 was first introduced by commit
:::::: a0c55ecee10055901c9c1b46d0d129cb6b51fa5d drm/amdkfd: process exit and retry fault race

:::::: TO: Philip Yang <Philip.Yang@....com>
:::::: CC: Alex Deucher <alexander.deucher@....com>

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ