From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51B5DC11F68 for ; Wed, 30 Jun 2021 12:29:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DA0EE619A5 for ; Wed, 30 Jun 2021 12:29:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA0EE619A5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 213E18D01A5; Wed, 30 Jun 2021 08:29:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C52B8D01A2; Wed, 30 Jun 2021 08:29:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 064C28D01A5; Wed, 30 Jun 2021 08:29:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0220.hostedemail.com [216.40.44.220]) by kanga.kvack.org (Postfix) with ESMTP id D156D8D01A2 for ; Wed, 30 Jun 2021 08:29:26 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A61F118216B70 for ; Wed, 30 Jun 2021 12:29:26 +0000 (UTC) X-FDA: 78310320732.15.4D295CE Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf30.hostedemail.com (Postfix) with ESMTP id 43C21E00304F for ; Wed, 30 Jun 2021 12:29:26 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id ECF4B61494; Wed, 30 Jun 2021 12:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1625056165; bh=EHmQTb8e2YECJNCJlq3BRBtEN7eaK8TcnhlyN2zl1Hs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=t6abjA0D+JFT5yVpRLqglk9ebYLSi+YqwIN6uwyR99YPpXfR6ESoifyNJnQMKCXoy x85Lh5y/mN1Cmd/g4TBcrYu6eI/1Fw52Aea8A8pzBtycj1scru8n4sOHxVcp0Z9sD2 hqtQA9kcsrWHBI0cqIxkg65etcteWT1GD1USZHyE= Date: Wed, 30 Jun 2021 14:29:23 +0200 From: "gregkh@linuxfoundation.org" To: Matthew Wilcox Cc: =?utf-8?B?6raM7Jik7ZuI?= , "akpm@linux-foundation.org" , "konrad.wilk@oracle.com" , "ohkwon1043@gmail.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] mm: cleancache: fix potential race in cleancache apis Message-ID: References: <20210630073310epcms1p2ad6803cfd9dbc8ab501c4c99f799f4da@epcms1p2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=t6abjA0D; spf=pass (imf30.hostedemail.com: domain of gregkh@linuxfoundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 43C21E00304F X-Stat-Signature: tpj65f3txdo3u7tdaz6hrcjjmuf8wy4j X-HE-Tag: 1625056166-349450 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Jun 30, 2021 at 12:26:57PM +0100, Matthew Wilcox wrote: > On Wed, Jun 30, 2021 at 10:13:28AM +0200, gregkh@linuxfoundation.org wr= ote: > > On Wed, Jun 30, 2021 at 04:33:10PM +0900, =EA=B6=8C=EC=98=A4=ED=9B=88= wrote: > > > Current cleancache api implementation has potential race as follows= , > > > which might lead to corruption in filesystems using cleancache. > > >=20 > > > thread 0 thread 1 thread 2 > > >=20 > > > in put_page > > > get pool_id K for fs1 > > > invalidate_fs on fs1 > > > frees pool_id K > > > init_fs for= fs2 > > > allocates p= ool_id K > > > put_page puts page > > > which belongs to fs1 > > > into cleancache pool for fs2 > > >=20 > > > At this point, a file cache which originally belongs to fs1 might b= e > > > copied back to cleancache pool of fs2, which might be later used as= if > > > it were normal cleancache of fs2, and could eventually corrupt fs2 = when > > > flushed back. > > >=20 > > > Add rwlock in order to synchronize invalidate_fs with other cleanca= che > > > operations. > > >=20 > > > In normal situations where filesystems are not frequently mounted o= r > > > unmounted, there will be little performance impact since > > > read_lock/read_unlock apis are used. > > >=20 > > > Signed-off-by: Ohhoon Kwon > >=20 > > What commit does this fix? Should it go to stable kernels? >=20 > I have a commit I haven't submitted yet with this changelog: >=20 > Remove cleancache >=20 > The last cleancache backend was deleted in v5.3 ("xen: remove tmem > driver"), so it has been unused since. Remove all its filesystem h= ooks. >=20 > Signed-off-by: Matthew Wilcox (Oracle) That's even better! But if so, how is the above reported problem even a problem if no one is using cleancache? thanks, greg k-h