From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) (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 BC7B01D5CFE for ; Fri, 15 May 2026 01:00:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778806806; cv=none; b=sdABLWi8rZZkcnIJQX8lvGWz8M3Dm5MAu6mM84r51/3f3JivW2O2wriSJ9AtgbHvD6vbGUsiCKaQZowv4zCkXqZBQ9YeInEMaYMxQZS8ZaNuf96IcZqtotJCf9KHule5/pfL1I6GSS9qLdrM6ev7JAY5j96mfmYGW0hOdBJpTi8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778806806; c=relaxed/simple; bh=YIIt10kZha8520h1iDaVQEAh6YsxR9Voe75slsWVp1I=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=iufwAaloBSpAf+I13iCc42Mx7MOBhgijxUQx71Dbp78wb1zOfY6T0tlIk/1m/Egnrpx+M4SxBt7xg63FAOMhfwb7kcmNu+OfCo0+8B85dgiMqe3i/v3LCPLnZIpA7C2z2u1t6LkyBzKyyxDr4TUIRBYt8An4O3MvuSTZLylW6z0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.210.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-ot1-f72.google.com with SMTP id 46e09a7af769-7dcc59fe0d8so12872806a34.2 for ; Thu, 14 May 2026 18:00:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778806804; x=1779411604; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RZHYgdw8zjaaJNS23Tc3Uoj/n4eHf5j654j42sBhMTI=; b=F5lBYGEargnNM7upw8xp15ibTTGnbpIXOe7CfNfd/iJ5F0uutDvjTsjvAVSY91SMFR d8qU62TGSpEf9asNCqVaDJMOJJJjDZpNyZB+3fnpM/K+Ss//rUbb0oOAJoVs7n2o5UwO ZOXbc8kxYEJ/lr/3OxiccAClrLf6OBN5LHDORmy14mPuci54i/K8CQqFM4D1lsdwuReW Owh2mrAlRale0WwzOkAp/9xgJSB0txeP+tVn1nw/av4SNX7ILqn6IpEVFiJhma/8Yato DZdASquoEIzXYIE87RypHzF5/HaI4ED6GiL8IaND/mvCorWg3Kbra2nT8BWkXa1875Z4 uE1A== X-Gm-Message-State: AOJu0YwKzcPp8ukd3QOO3L2qySnQxYqQpeJMcTf3tYCU4Gr1X+9F43pp xOEje1pziZaK1xgB0narHmVto04t5RqU77oFgGVTJ5YlF6ou5tFpI8YO8pZ25P2LkBDKRRsVU4P 58/G3j+Rpibxch5nrCDuazH8+GYdm0bVjkv++3F0r9O3PMZ9tmL9pZElI+Zk= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:6ae5:b0:68e:b81b:d81b with SMTP id 006d021491bc7-69c94372a7cmr1097668eaf.31.1778806803806; Thu, 14 May 2026 18:00:03 -0700 (PDT) Date: Thu, 14 May 2026 18:00:03 -0700 In-Reply-To: <6a062e5c.170a0220.196691.0007.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6a067013.050a0220.2921a.0003.GAE@google.com> Subject: Forwarded: [PATCH] f2fs: DEBUG: full lifecycle trace for node folio write-end-io BUG From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] f2fs: DEBUG: full lifecycle trace for node folio write-end-io BUG Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master Not for upstream. Instrumentation to identify how a node folio with mismatched folio->index and nid_of_node(folio) reaches f2fs_write_end_io and triggers the BUG_ON reported by syzbot. Previous test run confirmed the read-side sanity check fires (rc=-EFSCORRUPTED) yet the same folio still reaches writeback. This round adds traces at every cache lifecycle event so the leak path can be pinned down: - f2fs_finish_read_bio - async read footer check, page state - f2fs_write_end_io - write footer check, page state - f2fs_new_node_folio - entry, after grab, after fill_footer, after mark_dirty - read_node_folio - entry, with current page state - __get_node_folio - entry and after grab, page state - __get_node_folio - sync sanity failure on page_hit Each trace logs folio->index, footer nid/ino, and the relevant page flags (uptodate, dirty, writeback, refcount) so the journey of a single NID can be reconstructed across read failure, cache reuse, and writeback submission. BUG_ON in f2fs_write_end_io() is intentionally retained so the kernel halts at the failing folio and the preceding trace output appears in the syzbot console log. Link: https://syzkaller.appspot.com/bug?extid=4af46ee83100e99bce09 Not-Signed-off-by: Deepanshu Kartikey --- fs/f2fs/data.c | 16 +++++++++++----- fs/f2fs/node.c | 19 ++++++++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 8d4f1e75dee3..571ba13916ef 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -174,10 +174,14 @@ static void f2fs_finish_read_bio(struct bio *bio, bool in_task) dec_page_count(F2FS_F_SB(folio), __read_io_type(folio)); if (bio->bi_status == BLK_STS_OK && - F2FS_F_SB(folio)->node_inode && is_node_folio(folio) && - f2fs_sanity_check_node_footer(F2FS_F_SB(folio), - folio, folio->index, NODE_TYPE_REGULAR, true)) - bio->bi_status = BLK_STS_IOERR; + F2FS_F_SB(folio)->node_inode && is_node_folio(folio)) { + int rc = f2fs_sanity_check_node_footer(F2FS_F_SB(folio), + folio, folio->index, NODE_TYPE_REGULAR, true); + pr_info("f2fs-dbg: READ end_io: index=%lu footer_nid=%u ino=%u uptodate=%d dirty=%d rc=%d\n", + folio->index,nid_of_node(folio),ino_of_node(folio),folio_test_uptodate(folio),folio_test_dirty(folio),rc); + if (rc) + bio->bi_status = BLK_STS_IOERR; + } if (finished) folio_end_read(folio, bio->bi_status == BLK_STS_OK); @@ -383,8 +387,10 @@ static void f2fs_write_end_io(struct bio *bio) } if (is_node_folio(folio)) { - f2fs_sanity_check_node_footer(sbi, folio, + int rc = f2fs_sanity_check_node_footer(sbi, folio, folio->index, NODE_TYPE_REGULAR, true); + pr_info("f2fs-dbg: WRITE end_io: index=%lu footer_nid=%u ino=%u uptodate=%d dirty=%d rc=%d\n", + folio->index,nid_of_node(folio),ino_of_node(folio),folio_test_uptodate(folio),folio_test_dirty(folio),rc); f2fs_bug_on(sbi, folio->index != nid_of_node(folio)); } if (f2fs_in_warm_node_list(folio)) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 4e5bd9e4cfc3..d38b32fe7ee9 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1384,6 +1384,8 @@ struct folio *f2fs_new_node_folio(struct dnode_of_data *dn, unsigned int ofs) struct folio *folio; int err; + pr_info("f2fs-dbg: NEW entry: nid=%u ino=%lu ofs=%u\n", + dn->nid, dn->inode->i_ino, ofs); if (unlikely(is_inode_flag_set(dn->inode, FI_NO_ALLOC))) return ERR_PTR(-EPERM); @@ -1391,6 +1393,8 @@ struct folio *f2fs_new_node_folio(struct dnode_of_data *dn, unsigned int ofs) if (IS_ERR(folio)) return folio; + pr_info("f2fs-dbg: NEW grabbed: nid=%u uptodate=%d dirty=%d writeback=%d refcount=%d\n", + dn->nid,folio_test_uptodate(folio),folio_test_dirty(folio),folio_test_writeback(folio),folio_ref_count(folio)); if (unlikely((err = inc_valid_node_count(sbi, dn->inode, !ofs)))) goto fail; @@ -1423,10 +1427,14 @@ struct folio *f2fs_new_node_folio(struct dnode_of_data *dn, unsigned int ofs) f2fs_folio_wait_writeback(folio, NODE, true, true); fill_node_footer(folio, dn->nid, dn->inode->i_ino, ofs, true); set_cold_node(folio, S_ISDIR(dn->inode->i_mode)); + pr_info("f2fs-dbg: NEW after fill_footer: nid=%u footer_nid=%u footer_ino=%u\n", + dn->nid, nid_of_node(folio), ino_of_node(folio)); if (!folio_test_uptodate(folio)) folio_mark_uptodate(folio); - if (folio_mark_dirty(folio)) + if (folio_mark_dirty(folio)) { + pr_info("f2fs-dbg: NEW marked dirty: nid=%u\n", dn->nid); dn->node_changed = true; + } if (f2fs_has_xattr_block(ofs)) f2fs_i_xnid_write(dn->inode, dn->nid); @@ -1459,6 +1467,10 @@ static int read_node_folio(struct folio *folio, blk_opf_t op_flags) }; int err; + pr_info("f2fs-dbg: read_node_folio entry: index=%lu uptodate=%d dirty=%d\n", + folio->index, + folio_test_uptodate(folio), + folio_test_dirty(folio)); if (folio_test_uptodate(folio)) { if (!f2fs_inode_chksum_verify(sbi, folio)) { folio_clear_uptodate(folio); @@ -1565,6 +1577,7 @@ static struct folio *__get_node_folio(struct f2fs_sb_info *sbi, pgoff_t nid, struct folio *folio; int err; + pr_info("f2fs-dbg: GET node_folio: nid=%lu ntype=%d\n", nid, ntype); if (!nid) return ERR_PTR(-ENOENT); if (f2fs_check_nid_range(sbi, nid)) @@ -1574,6 +1587,8 @@ static struct folio *__get_node_folio(struct f2fs_sb_info *sbi, pgoff_t nid, if (IS_ERR(folio)) return folio; + pr_info("f2fs-dbg: GET grabbed: nid=%lu uptodate=%d dirty=%d writeback=%d refcount=%d\n", + nid,folio_test_uptodate(folio),folio_test_dirty(folio),folio_test_writeback(folio),folio_ref_count(folio)); err = read_node_folio(folio, 0); if (err < 0) goto out_put_err; @@ -1603,6 +1618,8 @@ static struct folio *__get_node_folio(struct f2fs_sb_info *sbi, pgoff_t nid, err = f2fs_sanity_check_node_footer(sbi, folio, nid, ntype, false); if (!err) return folio; + pr_info("f2fs-dbg: SYNC sanity fail: nid=%lu footer_nid=%u ino=%u err=%d\n", + nid,nid_of_node(folio),ino_of_node(folio),err); out_err: folio_clear_uptodate(folio); out_put_err: -- 2.43.0