From patchwork Fri Jun 14 13:18:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hillf Danton X-Patchwork-Id: 13698699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57F4CC27C6E for ; Fri, 14 Jun 2024 13:19:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 490166B00B6; Fri, 14 Jun 2024 09:19:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43E4F6B00B7; Fri, 14 Jun 2024 09:19:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32C5C6B00BA; Fri, 14 Jun 2024 09:19:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1458E6B00B6 for ; Fri, 14 Jun 2024 09:19:17 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6706EA0735 for ; Fri, 14 Jun 2024 13:19:16 +0000 (UTC) X-FDA: 82229550312.28.344E578 Received: from smtp134-33.sina.com.cn (smtp134-33.sina.com.cn [180.149.134.33]) by imf06.hostedemail.com (Postfix) with ESMTP id 725A318001B for ; Fri, 14 Jun 2024 13:19:12 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of hdanton@sina.com designates 180.149.134.33 as permitted sender) smtp.mailfrom=hdanton@sina.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718371153; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=2d5C9Ao/VD/3Vepk31pfFRRIxYN+5eJln2uTdrBjwq0=; b=4ohsJljwo6uW1qltozXRd/nYNaCVmfvMBN61iM/kbrrQciHiPoDnCqqaKay/5Ih3lFaQRe gmRZRMcAwLdSdVymx9SOzpNa2fGzg3DIXLxJemBJtEz53CqjmWMCheO9crHZ1F37XH3ati EmOVPyh9yFjhnLpC1LBfp/rIwqQq+go= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of hdanton@sina.com designates 180.149.134.33 as permitted sender) smtp.mailfrom=hdanton@sina.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718371153; a=rsa-sha256; cv=none; b=wPMifd+EGFbung6ufHzxWSjuTGPI6Yy+sL7lu9whK+DPMXdUqqpfBHNHB9iefwPAjhUkpc t/SEW0m0j6KCItAy5erDqfWM/tq31VKSt5q7X8HUnXawRnynhDHTd5lcDQGsztjzCJs7J7 zqQGlpm+76i2BLXDuytZvqKau5h/hm0= 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 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> MIME-Version: 1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PmZJ8ank1HaSby7vU4C2ydemNfxk/VO2 NyfX4CkC 6bR196Ryar7i8xX/ueQM1zFzVH/W8S3aOugOdJLrM0U1OklZnkwmtm4UB9ROC+GzW1TYMUBGwF/2+H3nYZtHhYCjIHY0A0XlZtIYXCD1WWAZoeG+iL+0IeuMh6/iDnZHrd0qzjpi563V57qFdLyt0CjbtYaQtuo3yyowa+ENGYA8UsZW9a56ogkV54ZTQMd5UyM8WztKwkq8c6IjJKlgV0MPVxt9OHZz06ICl2xYGBuBUGGfyH+dMLZuJ27ir2KsQLDcZDFuIFKSaRbKRIJsxzO8Efl7EHyq6mDA7SIkvsUmBEAWE8nMe288I+ShLvF8xWWwzsHIOQYKzWaNlYjR2GISj8/rxrMwKlcnHFJY4okHAxQ8LDA7wFdtGgqgrU5ZGymS4rxam9C6Ka98= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000006, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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);