From nobody Fri Apr 17 00:23:19 2026 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D08E38E129 for ; Tue, 24 Feb 2026 16:54:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771952055; cv=none; b=GP80lOWp0MIqoCq81yt43VBB64PjSzzcWvRnYDuyOvn1ZI76uTm2iTzhzJio8adZwkQIZ4YA/mLQg1RQ1OHgCQQUgqpYLI6ha/Jh8cRKDcn47nzyj463YwZc/8EttDqpjhWA5S9lKRfoq2dY9Z5qt+S4MegJYXQSxUOhG7Br2AE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771952055; c=relaxed/simple; bh=cnJU8rZdLWQWPFew+45Pq8J7YL2NwOosyjk7gdwivFU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fzZEopt+SPd5pRvbwGLwqnWADoqS5KB/sfSK6aGXcdME9jgNd13n0blOeflA5DUBfLFF/z8uavORdxRfmr3kqMx1Gm5JSFuoMMD+mHF+3utZI2mNoBYkNUQNEPdBC2MeynzpCgAdRJUcmlh6r9hG8tft9axZXjEDtojDKwUJYpA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EgrvlTUr; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EgrvlTUr" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2aad6094702so5730335ad.0 for ; Tue, 24 Feb 2026 08:54:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771952054; x=1772556854; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+9GXa4UNt9CSm+kLhVLx7XY7ItraJjuFAoNvdJgLB50=; b=EgrvlTUrrquRHLgCuFZgmeQ6c2xdNkVbzQnuMH4c/s0f/HB+HsgFvRe2elRdIxj2PA ynZik95FdXX97HTQOlbBEqSDNfzsSQ3ar3HPAiAeunUY+NYmuXmjijiama5tbeH29f3C cVmZrLszbKqbNFHqcKcN/07c0HFkPOLAWdwVOhN5YXG1N9iq4Reap60B70I8FH5QQoDJ 80WhhDPXJUrvn6Mddr7Mj4uRJTqhXaVmUE+1BHGXaTcIg+yu/J7uAllg/fkMRLvZxGxz 4vJV1OaT2YrlGdM+P3tJ+Vt9urYNNE4m9YNKNs8qf7qt1bF4LACcg8og6F6PuAMZcwq3 79cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771952054; x=1772556854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+9GXa4UNt9CSm+kLhVLx7XY7ItraJjuFAoNvdJgLB50=; b=mP0P5WBb0PN9GvJXILiGWU3yyfdvU5DN8mdieAl/bE11uVr0266dbAHeVQVQCMmiBk dR7RhXofMTnazx0m6NXJlAU1JKy4ZiBhDcxzgDOQP6D9CStqL+Bl+UtqaonjUrgqZFCg 3rNHErdhg/Tg/ZeNdY4wc4IGRUyuGjRkVJ37dZz2vGq56MAx+MnIV8wzuIsdHbdAllFC NnXSrDszTjNn4VY3e+onuWr5z5abtOqS/wBThqsADeh7VAFs+Bt1oZkHA2YtOoaBZG2k 7wHkO5tRq99GXjbKlEFs3FHfSpJd79bU72mYCVRa9BAGLx5hg9ZCvxSdciBKXvhbtlEy MQLA== X-Forwarded-Encrypted: i=1; AJvYcCWz3rf4mqEeGvKBWwTZnlr8AZCAl7pFrm7ofHeRb9yNu1/vh0mhdirTlVXKBDJg1hTAZoqr8cvPGdFxWrY=@vger.kernel.org X-Gm-Message-State: AOJu0YzMh0DYhYt614WCtN/Q8/WZdt9gaMmAe8Hascoegb+CoCENKs+I p+uqanZYKXpeFJcSNIizJryT+/k0Giq/HeX9HcQesL0Qhs9tOPn/7tCGhKaPti2R X-Gm-Gg: ATEYQzzMDdyT0XpQTpq5hpkh9SFBsPHVvbAKBwNn6AhK0KF11U4VeXCP9ENrAW9wSur vnjnKd2H+lkSzvk6s67EiiTjwVNHaX6nLNMn5ndJfk/bMQVn2b757uNPiWtY2nYdl1fr2f+lpjU FRQqpvdqE6dEGnG/dIq72fkHymsgV4QvCVMvXBX8pbk7j74zxb0RYSBiFHdZQS8wJDQQj0d+d4p lhHxa0/Ba2CeEBXM75zSStoA94LuViQqu0U4s3xByUTIVOguI6xGtSzbkOAJFycJ+8NTrlG20FD 65wkxwFOwXGDLAKNEMYXWbrdZEypP7BKugSRbNCMhPg6JexNpCRlQMOU6IgC3blkeCSBKttD3Ol vrxtC30/GQLI2Bg8F+KgmxVgTw42KxpctevJCipGxg1XqbPJXcX1T/+YdXJSTWy82VIwrfWWPBY 1NRW4t/Ek1VN+oI4ZmYdGpS9CUu9b98A== X-Received: by 2002:a17:902:cf05:b0:2aa:de29:65c with SMTP id d9443c01a7336-2ad7452014emr85930935ad.6.1771952053477; Tue, 24 Feb 2026 08:54:13 -0800 (PST) Received: from kt5965-NUC8i3BEH.. ([182.217.14.201]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ad7505bf1asm112635745ad.92.2026.02.24.08.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 08:54:12 -0800 (PST) From: Taerang Kim To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, syzbot+fc026e87558558f75c00@syzkaller.appspotmail.com, Taerang Kim Subject: [PATCH v2] f2fs: evict: truncate page cache before clear_inode Date: Wed, 25 Feb 2026 01:54:08 +0900 Message-ID: <20260224165408.450957-1-kth5965@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260224160654.448538-1-kth5965@gmail.com> References: <20260224160654.448538-1-kth5965@gmail.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" syzbot reports a BUG_ON(inode->i_data.nrpages) in clear_inode() when mounting a corrupted f2fs image. I agree with Dmitry's RFC that dropping page #0 in f2fs_truncate() can address this reproducer, since f2fs_convert_inline_inode() may grab page #0 via f2fs_grab_cache_folio() and leave it cached on the clear_out success path. However, clear_inode() requires the inode mapping to be empty, and it is hard to guarantee that the page cache can only be populated from this truncate/inline-conversion path. Make f2fs_evict_inode() defensively truncate any remaining page cache before calling clear_inode(), so nrpages is guaranteed to be 0 regardless of how the cache was populated. Link: https://lore.kernel.org/linux-f2fs-devel/20260206092958.578191-1-dman= tipov@yandex.ru/ Reported-by: syzbot+fc026e87558558f75c00@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Dfc026e87558558f75c00 Signed-off-by: Taerang Kim --- v2: rebase onto torvalds/master (fsverity_cleanup_inode() not present); fix patch context, no functional change. fs/f2fs/inode.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index e0f850b3f0c3..e7942e6e312c 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -1006,6 +1006,13 @@ void f2fs_evict_inode(struct inode *inode) } out_clear: fscrypt_put_encryption_info(inode); + /* + * Defensively truncate any remaining page cache, e.g. + * f2fs_convert_inline_inode() called from f2fs_truncate() + * may leave page #0 behind in the page cache when the + * inline conversion takes the clear_out success path. + */ + truncate_inode_pages_final(&inode->i_data); clear_inode(inode); } =20 --=20 2.43.0