From: Qian Yingjin Date: Wed, 17 Apr 2024 08:22:02 +0000 (-0400) Subject: LU-17625 statahead: avoid to use @sai after its has been freed X-Git-Tag: 2.15.64~220 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=85fe3cfff866083db8e9b1d72fc7f07e123b6f4c;p=fs%2Flustre-release.git LU-17625 statahead: avoid to use @sai after its has been freed There is a race between a statahead thread startup and another statahead reqeust trying to access the same statahead structure. But the statahead thread startup was failed and free the statahead structure too earlier. The user stat() request will use the statahead structure which memory has been freed already wrongly... In this patch, we repace the @ll_sai_free/@ll_sax_free with @ll_sai_put/@ll_sax_put to avoid freeing the statahead structure too eariler when they were still being used by user stat() request. Signed-off-by: Qian Yingjin Change-Id: I3840be959160aed2887a91be81da05f796306cd9 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54826 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/statahead.c b/lustre/llite/statahead.c index 94923a3..77b2c02 100644 --- a/lustre/llite/statahead.c +++ b/lustre/llite/statahead.c @@ -2436,10 +2436,10 @@ out: spin_unlock(&lli->lli_sa_lock); if (sai) - ll_sai_free(sai); + ll_sai_put(sai); if (ctx) - ll_sax_free(ctx); + ll_sax_put(dir, ctx); if (rc) atomic_dec(&sbi->ll_sa_running); @@ -2659,10 +2659,10 @@ out: } if (sai) - ll_sai_free(sai); + ll_sai_put(sai); if (ctx) - ll_sax_free(ctx); + ll_sax_put(dir, ctx); atomic_dec(&sbi->ll_sa_running); RETURN(rc);