Whamcloud - gitweb
EX-3478 pcc: avoid uninitialized pcc mutext lock in cleanup
authorQian Yingjin <qian@ddn.com>
Wed, 14 Jul 2021 07:27:19 +0000 (15:27 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 15 Jul 2021 06:15:06 +0000 (06:15 +0000)
Running racer concurrently crashed in the following way:
  RIP: 0010:[...]  [...] __list_add+0x1b/0xc0
  __mutex_lock_slowpath+0xa6/0x1d0
  mutex_lock+0x1f/0x2f
  pcc_inode_free+0x1e/0x60 [lustre]
  ll_clear_inode+0x64/0x6a0 [lustre]
  ll_delete_inode+0x5d/0x220 [lustre]
  evict+0xb4/0x180
  iput+0xfc/0x190
  ll_iget+0x156/0x350 [lustre]
  ll_prep_inode+0x212/0x9b0 [lustre]

After analysis, we found that the mutex @lli_pcc_lock is not
initialized. The reason is that ll_lli_init() is not called to
initialize @lli.
When call pcc_inode_free(), it will call mutex_lock() on the
uniniitialized @lli_pcc_lock, thus crash the kernel.

Test-Parameters: testlist=racer env=DURATION=3600
Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: I612c79a5b8eb4fa9daeb9e446a457e95c666c04a
Reviewed-on: https://review.whamcloud.com/44300
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/llite/pcc.c

index 9f57900..9c34d87 100644 (file)
@@ -1363,7 +1363,10 @@ static void pcc_inode_put(struct pcc_inode *pcci)
 
 void pcc_inode_free(struct inode *inode)
 {
-       struct pcc_inode *pcci;
+       struct pcc_inode *pcci = ll_i2pcci(inode);
+
+       if (!pcci)
+               return;
 
        pcc_inode_lock(inode);
        pcci = ll_i2pcci(inode);