Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp860136lqs; Fri, 14 Jun 2024 07:44:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+plRb5P9sfZndsJyY2EclbM09XjBfyqOlL44sUS0B5rfprZrEGrorgexVpIvLJiIYE/pU3ezPwqd2ZYG8iRP7+ryyRTExsWqNKgWHwg== X-Google-Smtp-Source: AGHT+IE0Wt8po+y/93yoBTsTeJGn+uB3rmkjJVkTFlVUFUjtfJs0Wi/bipkkpTiwheYZFf80pLax X-Received: by 2002:a05:6870:6491:b0:254:832e:c0ed with SMTP id 586e51a60fabf-25842be26b7mr3087046fac.51.1718376262052; Fri, 14 Jun 2024 07:44:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718376262; cv=pass; d=google.com; s=arc-20160816; b=p2D2g7ihQcQHShl7yROI8dvXC5/A25Lpye1qijTlhtO5057IllyYP/M5/4VGJjhsxF SuDlzFCleNykbzQ3SBvpFUm3OjEsL/9upml7yon5uhHVBf/WpBPvm1yPul3axFMgSJgL b6xetyWxXDpVJVH/JVkbhOIcRbn6aSAtjs987fSKL2hvqfXJ9WB1Tr4AVv1BLjhy6NY0 SN1hElxhpridxuzVfEDmFYbzYu/M7pK+bw0uUDFWvcKDmY9hdh4Lm5YQ1LOFopstYh17 LmuwVFifhxyipH+R5LMQo3f5m8TXQMIKpKUWXwsWaVfqnjL5t4hNnCERgzaDOROjRIq5 du+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FOEDNVsvnyrjERCR6kvUw9fLHGQTorC8TxMyHmBMNMk=; fh=dzfo9NzOoZ+oEgJKNStNOoY44i915q2rqoMpvX0gfqc=; b=yROpvRKFb3BETZ6r0eQI1llop8wZYZFihBnPpbv9IlU7rsDpnyqVACfsCYCfmQnVQE gLfYbGixPqy1b55+qcnt4SLox1gxPHyRZUezCZIcCZkwvEorK7wz86KOZGx8h1vG7Idb Q4WO3qkS64u/IYg6fwmw4NbuYTrWpG9lHMCNkYAGGWhr6hmI1OPyrtuQqdPB2zCzXNfV BseskjfJygSN5OtOS46ILhcNkunQzswZxKzng4h25sMad488hMj5uBybxv5yxbqPWMnk HcSLIqaUNpmmQWvCqWoQP62vTIeERCfEc4OesBtYXFNLHmtACvciGpf7Vf12I7Dl7A0O viMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=aJOro4ox; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-214950-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214950-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fee310c78dsi3830371a12.390.2024.06.14.07.44.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 07:44:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214950-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=aJOro4ox; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-214950-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214950-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 45997288664 for ; Fri, 14 Jun 2024 13:42:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49DAC19D8B3; Fri, 14 Jun 2024 13:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="aJOro4ox" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 992FE63B for ; Fri, 14 Jun 2024 13:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718372557; cv=none; b=BHt6IdbJzUeWswZa4PVAbkahq40BiSlGkrOEmmnFwetjzBKEiVZNC9zOX9IH8hc0X48b9yL2eJJCvtbuW4EbdMZBWGw63Htkp7bn0Ssefuw0eEFeeCH3VU2o+4SZ/KYyy97xaM9YPReptQpgJksB6x1uqLsKgAooXJJrIjAIZ2g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718372557; c=relaxed/simple; bh=esMGgyY1W25P7oUFv/eBPQQ0NO1tlRMBciGtesHw7yo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=M6vyuaqRQ7w7qYS1pADxA+B1ycDxvp+RaRu13HZLAKQ7d1pB96vUk4mY23uAPAv/46cwVTO4H0JoI6s8pF6ZvkMNmHgx4qGz9qWuvOaZsE2smk2DZABPSLHbmj8nSf/mzjJICcKO+mxpQK3Nbl+eaDLe/aRDdjtRinOBpf+m6xg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=aJOro4ox; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=FOEDNVsvnyrjERCR6kvUw9fLHGQTorC8TxMyHmBMNMk=; b=aJOro4oxeGoIKSfgHm+gSn3UCP 20XioKN1lO12GHRSUaf8O4SgNjuxK8vKU3J7edTOFIOAGiiqeynHV7nR6/to4xfky6NkWvyg3Iib6 UI3+s/eBycdgp4QWJ+/bTOs7VMRTZCkMlNjGpZa8tATcw+XNUG4Cgv6mMyCMTMuHB3i3cOFTVTHQ1 NXAcyLZocOMZTZK2/oSZyf7QIG00hJGdKdcFN8xAj2ALBLjP2HI//I+GnXWdkIETlcj4m9l+q5TIs 4wmuazHJ10FMgDRIhx+5qQobgMpw5Zrqn4GLuJaiZJdLsLErDOJRBA97tb60yoodwetWPCwTmOBC8 grvqdFBQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sI7C9-0000000H0o7-0Gwf; Fri, 14 Jun 2024 13:42:21 +0000 Date: Fri, 14 Jun 2024 14:42:20 +0100 From: Matthew Wilcox To: Hillf Danton Cc: linux-mm@kvack.org, Hugh Dickins , Johannes Weiner , Jan Kara , Andrew Morton , linux-kernel@vger.kernel.org, syzbot+d79afb004be235636ee8@syzkaller.appspotmail.com Subject: Re: [RFC PATCH] mm: truncate: flush lru cache for evicted inode Message-ID: References: <20240614131856.754-1-hdanton@sina.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240614131856.754-1-hdanton@sina.com> On Fri, Jun 14, 2024 at 09:18:56PM +0800, Hillf Danton wrote: > Flush lru cache to avoid folio->mapping uaf in case of inode teardown. What? inodes are supposed to have all their folios removed before being freed. Part of removing a folio sets the folio->mapping to NULL. Where is the report? > Reported-and-tested-by: syzbot+d79afb004be235636ee8@syzkaller.appspotmail.com > Signed-off-by: Hillf Danton > --- > Post for comments because lru_add_drain_all() is too haevy a hammer. > > --- x/mm/truncate.c > +++ y/mm/truncate.c > @@ -419,6 +419,9 @@ void truncate_inode_pages_range(struct a > truncate_folio_batch_exceptionals(mapping, &fbatch, indices); > folio_batch_release(&fbatch); > } > + > + if (mapping_exiting(mapping)) > + lru_add_drain_all(); > } > EXPORT_SYMBOL(truncate_inode_pages_range); > > --