From f38062317b6fdf8100d65b0e4e54ca2fd9e34fac Mon Sep 17 00:00:00 2001 From: Qian Yingjin Date: Wed, 14 Jul 2021 15:27:19 +0800 Subject: [PATCH] EX-3478 pcc: avoid uninitialized pcc mutext lock in cleanup 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 Change-Id: I612c79a5b8eb4fa9daeb9e446a457e95c666c04a Reviewed-on: https://review.whamcloud.com/44300 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo --- lustre/llite/pcc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lustre/llite/pcc.c b/lustre/llite/pcc.c index 9f57900..9c34d87 100644 --- a/lustre/llite/pcc.c +++ b/lustre/llite/pcc.c @@ -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); -- 1.8.3.1