From nobody Thu Dec 18 11:27:50 2025 Received: from smtp134-25.sina.com.cn (smtp134-25.sina.com.cn [180.149.134.25]) (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 9D14119D88D for ; Fri, 14 Jun 2024 13:19:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=180.149.134.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718371160; cv=none; b=oPpll4IdKATvPwqfYtynIvIMLQsZum8P4tMFHbg2I6BXRceKNBBYKq3fIKt+OXQxIft2GIamBWvc3JlEix5SchO+31z+Z8UKnXTSiBJuhpkvDVidTffcVbkdhW3GATN0zGd5IK8yOsGPU9uvPbZTxWEkw8L5cL+1UvZgq70842E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718371160; c=relaxed/simple; bh=1MhR2TcXm95uJHU+I2E41M5gAlUJJj/9KjISZ3PB4vc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ONNlOB2+zOdO9pUZmfRWgCB2Au7oxHwEgAh77VxTU63RC6dvtAVUeZRGjAH6eY4yqc9S8pniPnKmyN7+A6MlIAnni0uHBkJNH9sCveEgFIOlhYL38C9qkaUMcIRj+My/PIK1RFJvZoU6BwU/mTYABqOFx1TZsfegGn+VtlHnsdM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=180.149.134.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.118.70.97]) by sina.com (10.185.250.21) with ESMTP id 666C4347000079B5; Fri, 14 Jun 2024 21:19:06 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 9204823408221 X-SMAIL-UIID: 2489B2222DC64EE7B35CC5094DD93C5D-20240614-211906-1 From: Hillf Danton To: linux-mm@kvack.org Cc: Hugh Dickins , Matthew Wilcox , Johannes Weiner , Jan Kara , Andrew Morton , linux-kernel@vger.kernel.org, syzbot+d79afb004be235636ee8@syzkaller.appspotmail.com, Hillf Danton Subject: [RFC PATCH] mm: truncate: flush lru cache for evicted inode Date: Fri, 14 Jun 2024 21:18:56 +0800 Message-Id: <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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Flush lru cache to avoid folio->mapping uaf in case of inode teardown. Reported-and-tested-by: syzbot+d79afb004be235636ee8@syzkaller.appspotmail.c= om 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); =20 --