From: Mike Marciniszyn Date: Wed, 7 Jul 2021 19:16:00 +0000 (-0400) Subject: LU-14733 o2iblnd: Move racy NULL assignment X-Git-Tag: 2.12.8~31 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F16%2F44216%2F2;p=fs%2Flustre-release.git LU-14733 o2iblnd: Move racy NULL assignment kiblnd_fmr_pool_unmap() can race map and subsequent processing because of this flaw in unmap: if (frd) { frd->frd_valid = false; spin_lock(&fps->fps_lock); list_add_tail(&frd->frd_list, &fpo->fast_reg.fpo_pool_list); spin_unlock(&fps->fps_lock); fmr->fmr_frd = NULL; } The fmr can be pulled off the list in kiblnd_fmr_pool_unmap() on another CPU an fmr_frd could be in a state of flux and potentially be seen incorrectly later on as the kib_tx is processed. Fix my moving the fmr_frd assignment to before the fmr is added to the list. Lustre-change: https://review.whamcloud.com/44189 Lustre-commit: 023113fb8946f3565529e7327fdcd90ab9db3ba3 Signed-off-by: Mike Marciniszyn Change-Id: Ibddf132a363ecfe9db3cc06287cec873c021d2fb Reviewed-by: Amir Shehata Reviewed-by: Serguei Smirnov Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/44216 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lnet/klnds/o2iblnd/o2iblnd.c b/lnet/klnds/o2iblnd/o2iblnd.c index 91c02c4..86a77c7 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.c +++ b/lnet/klnds/o2iblnd/o2iblnd.c @@ -1823,10 +1823,10 @@ kiblnd_fmr_pool_unmap(struct kib_fmr *fmr, int status) if (frd) { frd->frd_valid = false; + fmr->fmr_frd = NULL; spin_lock(&fps->fps_lock); list_add_tail(&frd->frd_list, &fpo->fast_reg.fpo_pool_list); spin_unlock(&fps->fps_lock); - fmr->fmr_frd = NULL; } } fmr->fmr_pool = NULL;