Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp810913lqs; Fri, 14 Jun 2024 06:30:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwLXUUlRlC/LUpIWBCwOgDbxwuUkVViPTmPjKGY50YUV910yuuCZgzT8CIkYCEbiEzlvTis+R8/n9iHX791u4KuuaBudzQaeqNY0gWyg== X-Google-Smtp-Source: AGHT+IHH8XFdkLUQtpX0BF0dGlz6HGlSC9mHa0ZLzWhy4bvUiokqBBnU6E4ezp8kKA749j3DXy0Z X-Received: by 2002:a05:6870:96a5:b0:250:7a43:aefd with SMTP id 586e51a60fabf-25842887ac4mr2326915fac.2.1718371824263; Fri, 14 Jun 2024 06:30:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718371824; cv=pass; d=google.com; s=arc-20160816; b=HHAUs8BtVti2G/ZbkKwx9/FPZvLhn6HH7WLIc4GTcGgviUsecJ8k6dASzsWz7B2j3+ drxuWk2MbAoYlkmClGqJsQQ8NsXlFDIbYp7j8qYCq5wfejFFq+TvRb3YCZ1UN49vaq/A L/3ERfMFADovyORz/mNlUc7Z1acwQRQ5uTpXpiQ45j/smbS+4sdsKW67nzaoyeNGs3Bl QadoreuCUGUncgdXh1p8LygIaTf0eCw6vDbxXU8/adJVFKGSP+ONEH8SaDB2MC0H9V3q 0b6HsydNigh+en5Ddr+dpzdW/9cDccEHr83IIaCWv9g4H2dc96T7qvzv+Siri/weOoX3 AhJQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=2d5C9Ao/VD/3Vepk31pfFRRIxYN+5eJln2uTdrBjwq0=; fh=heExb/4T0eCQZ1QeR9QZgyO4vpcaaeHuDFv37fHTpQo=; b=b39Wwi7q97l/j6mDbPPQD86NaCxBS9FX4neRhk1T77f+gmQesquTjj/B35PVsX4WzD zQgbn7eCCgkY/skOqHJUKInv3TuHaEbguTITKv2O6Q6G0XJZ9SaBPIEl+qGY/NXWnWbJ ZuWh2kZ/X9a+PUmSFjy3MXZH+NAzJP2k+bTMpT69m/xcv5fG+cSxJbNDRy+dveTv0Apq g5VdYYJUrnphGSYy78+6ujRzhKcq6F/pp0QxPIeB1gGjBfcDsu7I8bQADlwZG9O1OwYs RFdPUBKjjWPYjF/lwnEGD1qFLoWfd/9tnH7yEVhsLanrKtfobRuyhsdDuHn6cajxOJgl d8ew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-214935-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214935-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fee3108ad2si3564870a12.304.2024.06.14.06.30.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 06:30:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214935-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-214935-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214935-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 25B98B2137D for ; Fri, 14 Jun 2024 13:19:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39C2B19AA4F; Fri, 14 Jun 2024 13:19:21 +0000 (UTC) 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: 8bit Flush lru cache to avoid folio->mapping uaf in case of inode teardown. 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); --