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 4CED9C11F69 for ; Wed, 30 Jun 2021 08:13:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D169161D28 for ; Wed, 30 Jun 2021 08:13:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D169161D28 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 138746B00AA; Wed, 30 Jun 2021 04:13:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C2076B00AB; Wed, 30 Jun 2021 04:13:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7E146B00AC; Wed, 30 Jun 2021 04:13:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id BC9186B00AA for ; Wed, 30 Jun 2021 04:13:32 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 88C4518ED8 for ; Wed, 30 Jun 2021 08:13:32 +0000 (UTC) X-FDA: 78309675864.01.AE9739A Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf04.hostedemail.com (Postfix) with ESMTP id 1F28F5000096 for ; Wed, 30 Jun 2021 08:13:32 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 9CA7D61C9F; Wed, 30 Jun 2021 08:13:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1625040811; bh=KO4vyaUivIt0ADyQShDhV1aCw7X6viddALTw7vTzn4g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=allzi4pTPxU9HtC2mQ2IL+I/Ef0+0nuO719xRyraDLXt2ZvCbXedwNHZn+qxDl5Vd 2bKhVaRFNk8LHJ94UbXIBgyUa5jK/5MtIgFp81gWHpYCfxiST6dUr2d1atgQ0IxHPJ W6f3X8pCYm8OSzfEYjw+laO/meyF2++Lk4r4NAh8= Date: Wed, 30 Jun 2021 10:13:28 +0200 From: "gregkh@linuxfoundation.org" To: =?utf-8?B?6raM7Jik7ZuI?= Cc: "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: <20210630073310epcms1p2ad6803cfd9dbc8ab501c4c99f799f4da@epcms1p2> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 1F28F5000096 X-Stat-Signature: anweag3xd63zforqatrgzm81jhx46o67 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=allzi4pT; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf04.hostedemail.com: domain of gregkh@linuxfoundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org X-HE-Tag: 1625040812-795845 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 04:33:10PM +0900, =EA=B6=8C=EC=98=A4=ED=9B=88 wro= te: > 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 pool_= 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 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 cleancache > 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 What commit does this fix? Should it go to stable kernels? thanks, greg k-h