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 C81C6C11F65 for ; Wed, 30 Jun 2021 11:27:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4C9DC61919 for ; Wed, 30 Jun 2021 11:27:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C9DC61919 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AA13A8D01A1; Wed, 30 Jun 2021 07:27:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A2ABA8D017A; Wed, 30 Jun 2021 07:27:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A2B28D01A1; Wed, 30 Jun 2021 07:27:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0009.hostedemail.com [216.40.44.9]) by kanga.kvack.org (Postfix) with ESMTP id 6043C8D017A for ; Wed, 30 Jun 2021 07:27:35 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3158982319A8 for ; Wed, 30 Jun 2021 11:27:35 +0000 (UTC) X-FDA: 78310164870.26.26090AF Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id 993CF4002085 for ; Wed, 30 Jun 2021 11:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=YcUqSyb80R0ASzDoWxv2Nvd88ZLCZUq6ve4o6p7i3Ak=; b=MUCOpy6PjkSvywNfWoKvM57NpI 0NO2Ps32CpkfQS9cSMf93CERw2kuAXGH/qxxGL2IEuhTV2BsvFebQyw6hrDit3J3Fbxx33yYCMKJ0 98ZPG0mtPfuC2Ik5rZubWJXXbtI31zXYeJBKrcxq0gPRH40kZd3OnqQrO/YPpG5B3AqngUSkJs4ym +AsIOq5iZTIX6I+VklqGv7X+NtRd3ArU/7CH6tdqRVYoyZbb5qIbD6bQaYCQ7oE9ewUgZKRJiCboB om1RCRz6ZCV9pU66hk7LEsp96ZC6aSP3h6yz0A3qSt5RHqKWjOT3GdQyOSEiAx0P48P6setvhe51U bMV8/ZGw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyYMr-005H5W-7v; Wed, 30 Jun 2021 11:27:07 +0000 Date: Wed, 30 Jun 2021 12:26:57 +0100 From: Matthew Wilcox To: "gregkh@linuxfoundation.org" 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: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=MUCOpy6P; dmarc=none; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam02 X-Stat-Signature: j1m6ujwxcuueedb9tncnahzbw3ntrygc X-Rspamd-Queue-Id: 993CF4002085 X-HE-Tag: 1625052454-327154 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 10:13:28AM +0200, gregkh@linuxfoundation.org wrot= e: > On Wed, Jun 30, 2021 at 04:33:10PM +0900, =EA=B6=8C=EC=98=A4=ED=9B=88 w= rote: > > 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 f= s2 > > allocates poo= l_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 be > > copied back to cleancache pool of fs2, which might be later used as i= f > > it were normal cleancache of fs2, and could eventually corrupt fs2 wh= en > > flushed back. > >=20 > > Add rwlock in order to synchronize invalidate_fs with other cleancach= e > > operations. > >=20 > > In normal situations where filesystems are not frequently mounted or > > 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? I have a commit I haven't submitted yet with this changelog: Remove cleancache The last cleancache backend was deleted in v5.3 ("xen: remove tmem driver"), so it has been unused since. Remove all its filesystem hoo= ks. Signed-off-by: Matthew Wilcox (Oracle)