From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B91A132C8B; Fri, 6 Dec 2024 14:50:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733496657; cv=none; b=JF3UozlgWCkjMKerzkq18T7K5dmn2z3gGBPUFz/4hR+NAxeCOyYmOqKi1gUKegkW/J6FqAHJdTKWGCcIz4sqr4MztnLpOwDAqdCw6qSZFAHBwtQepoFQJtcBD0M0YlLYgyFGMFyvdzjed4KeG32zsxabTXywzAl4jx+4h92xniY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733496657; c=relaxed/simple; bh=NY3WnSXOzhfsc+8WSN8fForkbIFIixblKYw/Zi2PaRs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g20E1YVm69rJf9WLgA+epL+gbkYbtRzCB+JJBf86mvljXKxLPeyA3Wt40cutECT+zpXXwzYFh3uHFCMg2ELQ/Wp7pB0RdG+3qpjsAsU/q8tDlxR7KuVG6DejQ2Tpjk9oNzYnP8yXrB0bsvKbxu//x4iCBWL1XVCgdKKYeTHPGtc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Qe3cOFUU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Qe3cOFUU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30B37C4CED1; Fri, 6 Dec 2024 14:50:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733496657; bh=NY3WnSXOzhfsc+8WSN8fForkbIFIixblKYw/Zi2PaRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qe3cOFUUiuSl0vbESFoBFyKpJ+JKqmGclenPClZTXh6LCFj/g05UgXmjmErbf4Q9g nkekKpqQpruv9ddRVlWbL/LzL51GM8edJRDvPpF/PDOlk8i/9bF0NHO92tGAS4oDO4 8+yT9SJ3IqOqFf6L39JFcS1zoEt/GbeaaYIxKAHY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zizhi Wo , David Howells , Christian Brauner , Sasha Levin Subject: [PATCH 6.6 067/676] netfs/fscache: Add a memory barrier for FSCACHE_VOLUME_CREATING Date: Fri, 6 Dec 2024 15:28:06 +0100 Message-ID: <20241206143655.976243061@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206143653.344873888@linuxfoundation.org> References: <20241206143653.344873888@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zizhi Wo [ Upstream commit 22f9400a6f3560629478e0a64247b8fcc811a24d ] In fscache_create_volume(), there is a missing memory barrier between the bit-clearing operation and the wake-up operation. This may cause a situation where, after a wake-up, the bit-clearing operation hasn't been detected yet, leading to an indefinite wait. The triggering process is as follows: [cookie1] [cookie2] [volume_work] fscache_perform_lookup fscache_create_volume fscache_perform_lookup fscache_create_volume fscache_create_volume_work cachefiles_acquire_volume clear_and_wake_up_bit test_and_set_bit test_and_set_bit goto maybe_wait goto no_wait In the above process, cookie1 and cookie2 has the same volume. When cookie1 enters the -no_wait- process, it will clear the bit and wake up the waiting process. If a barrier is missing, it may cause cookie2 to remain in the -wait- process indefinitely. In commit 3288666c7256 ("fscache: Use clear_and_wake_up_bit() in fscache_create_volume_work()"), barriers were added to similar operations in fscache_create_volume_work(), but fscache_create_volume() was missed. By combining the clear and wake operations into clear_and_wake_up_bit() to fix this issue. Fixes: bfa22da3ed65 ("fscache: Provide and use cache methods to lookup/create/free a volume") Signed-off-by: Zizhi Wo Link: https://lore.kernel.org/r/20241107110649.3980193-6-wozizhi@huawei.com Acked-by: David Howells Signed-off-by: Christian Brauner Signed-off-by: Sasha Levin --- fs/fscache/volume.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/fscache/volume.c b/fs/fscache/volume.c index cb75c07b5281a..ced14ac78cc1c 100644 --- a/fs/fscache/volume.c +++ b/fs/fscache/volume.c @@ -322,8 +322,7 @@ void fscache_create_volume(struct fscache_volume *volume, bool wait) } return; no_wait: - clear_bit_unlock(FSCACHE_VOLUME_CREATING, &volume->flags); - wake_up_bit(&volume->flags, FSCACHE_VOLUME_CREATING); + clear_and_wake_up_bit(FSCACHE_VOLUME_CREATING, &volume->flags); } /* -- 2.43.0