From nobody Mon May 25 08:11:41 2026 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (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 0FA7470830 for ; Sun, 17 May 2026 00:52:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778979161; cv=none; b=R8iXyrQKpB7IAh/nYmhaDiJ2fKA2o2/MFfA3XHzcsMHZtVrfOPF0bGewKTfio2Yyo0myNuwGmTdEw9TLgFOEPZRa3FxsXbCYpcVivr3wyPyLDA3BKrfmncP8wPT1QwowB7bI+1aNuir5oj3PAC3uobvgsfd75CIS2YmuckaNgOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778979161; c=relaxed/simple; bh=8xOjpNewE17A4u0awbUh8LEi5KIk6/mX2I5eZ+nBSyY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Xr4vCBEnMg8aXCUi150YRXMwiHRs69w/FfgjzgKMcy7s/R8JnRvGxW+bBG/g8DlbjSj65hBcTC4AKZE2HNrfMf0Lb0UBEZ4enm5knOMNCXS66T79DE037lMeDRax2NPjKfMeydp88yagSLtOarS+1BY+AReHpWlAG/72wzKc2Qo= 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=DHwNghNI; arc=none smtp.client-ip=209.85.215.169 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="DHwNghNI" Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-c80227b1f6cso343346a12.1 for ; Sat, 16 May 2026 17:52:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778979159; x=1779583959; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Af16G8zYt4/YY8vU9QwSZfvcmcjmWzXY8R6f0FYmWII=; b=DHwNghNIYisiqsvahbsLINaLNmsgG4OMfyvQNg1yPCIqtB0K1seZdQT79noHlpu9in Ipoy+gzah0GubnrGqMMO9JfsJyMUURLGtCKGLrtPnxHbLJQpyvAtJb+33RZZXf9qN+NP A7wnbFEIx5l5UZSgR0JIxzvlhgsDkzSm93nZ6zitTIy/PiE8tmgmOQKFmMSsWO6FwvDL awLrE92gfaGWOFpXVremfJz2NsdL2yrdzeTZSa3xVbVrh778W/r12AX2pB6NdLJIMgDw PdNu7Yiz5rXo8spuE7VDTAiBJPtKZJkLdoxdhfymhbeUgKz9N8CXcQB+Du/INcLCeCjt hcwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778979159; x=1779583959; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Af16G8zYt4/YY8vU9QwSZfvcmcjmWzXY8R6f0FYmWII=; b=HvBVXr1A0F/m+HDdGjJWqqbLzWOmsu3OetFAkpUxjdDAy/Ed7wNgJcuYoSmOZrf+S1 MxQ40qpFwnVrzbxflNIGlBRJQaLA/JAfuXNyFf50u2maDkHyjBllyRhhTx/7qgvwHldF 75vty0YwMWt7wZb8Kfvj1rmLpL2UqzsCyp+7oebSj1w8EJZDMPx6Z+ZqGjkRRegBJXWq LmIk7rJAXXeF9JYPmbPf0w5CdnWT7SQFHjFoVGwayBu9nbl3Tno1GymOlBkn3VkT5PGo OShYsj5HBlfip+AAaSjCiuO1dJwb1Vk+rD02y6HNe8zpkjgYKGPFJQCP7cz5huyj/ETl cOSw== X-Forwarded-Encrypted: i=1; AFNElJ+YlqQmNdWABeC6LfviS+kEfsDlGP8gT5sd4WeELo4XnPNRWtYzPZPaxlQFLVyHI0MozgbwiKx7vv7v+gc=@vger.kernel.org X-Gm-Message-State: AOJu0YwFqAkfWCsDyFkGsFRc56aJ4wuyj3OIjGeD6JeM+8+QXyIwl8T7 NBfrEjUKogKQjP23+X/VVusSzBs1nffkX/5H3VG0T1pk+m/CZdtm5SlK X-Gm-Gg: Acq92OHCXX9wYw9EW2fwaXwOhOpiioM+MkXeOOP9eEsJZhS0VcoB3Axv0j4nHl9Kje1 sLOrNzS75mWA37dVTVyciU5+NHRyLQhGmLjJJz7Gc7e5rQ5YXOR8YYGWbqOd2IDfmcvCe88iRZY MfxzKXZI0QE7PX2Vdj0Hl/vkMnv6eC/uNwpuc6yjfVfkvMrkQUD5J+FGYE9UZ+qZehYlWlbktSF 16gA9baFS2McwbB5aUeqo8eQSVi5egcwHA0amzt2SYklLVBAEqlikDYgQcO3zmWmPXc6cjZyJNx RmSo4kYba7fBRHcVaXHVVCPE1qom/urh9UtcCIPnx/5mLofNMXrB2uj96Kyv3vh359AbUClEYZT nbIeYXOzeYlthfFWyWP3pOlj5qqjvOfhjzBT04yEZg8jYUkFI3auxbmhVMGyuPhML4ZSTXIO6dD n2o8oaPOMudmV4n8uY4zsjvy/cfF8VEmWK/NY70K1wzKENvyUjhw1WCm4NEBe+reKYiTYjC8mUr ufBqXg= X-Received: by 2002:a05:6a00:1904:b0:82f:38:a5b2 with SMTP id d2e1a72fcca58-83f33d835b8mr10093396b3a.40.1778979159339; Sat, 16 May 2026 17:52:39 -0700 (PDT) Received: from deepanshu-kernel-hacker.. ([2405:201:682f:383f:29ea:98ba:649e:3b6e]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f19c7809esm12627735b3a.44.2026.05.16.17.52.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2026 17:52:38 -0700 (PDT) From: Deepanshu Kartikey To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Deepanshu Kartikey , syzbot+4af46ee83100e99bce09@syzkaller.appspotmail.com Subject: [PATCH] f2fs: don't BUG on node footer mismatch in f2fs_write_end_io Date: Sun, 17 May 2026 06:22:30 +0530 Message-ID: <20260517005230.28172-1-kartikey406@gmail.com> X-Mailer: git-send-email 2.43.0 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 recurrence of the kernel BUG in f2fs_write_end_io: kernel BUG at fs/f2fs/data.c:388! Oops: invalid opcode: 0000 [#1] SMP KASAN PTI CPU: 0 UID: 0 PID: 15 Comm: ksoftirqd/0 PREEMPT_{RT,(full)} RIP: 0010:f2fs_write_end_io+0x16df/0x1740 Call Trace: blk_update_request+0x57e/0xe60 blk_mq_end_request+0x3e/0x70 blk_done_softirq+0x10a/0x160 handle_softirqs+0x1de/0x6d0 run_ksoftirqd+0x52/0x180 Commit 50ac3ecd8e05 ("f2fs: fix to do sanity check on node footer in {read,write}_end_io") added f2fs_sanity_check_node_footer() to both end_io paths to catch corrupted node footers reachable from fuzzed on-disk images. In f2fs_write_end_io(), however, the existing f2fs_bug_on(sbi, folio->index !=3D nid_of_node(folio)); was left in place immediately after the new helper call. The helper detects the mismatch, sets SBI_NEED_FSCK and emits a ratelimited warning, but its return value is discarded and the following f2fs_bug_on() panics on the exact same condition. Tracing the reproducer confirms the failure path. A node folio with index=3D11 is looked up via __get_node_folio(), the synchronous sanity check at page_hit fails with -EFSCORRUPTED and out_err clears uptodate but leaves the dirty bit set from the folio's earlier lifecycle. A subsequent read_node_folio() fails with the same error (footer_nid=3D0, ino=3D0), and folio_end_read(folio, false) does not clear dirty either. The writeback iterator then finds the still-dirty folio via the PAGECACHE_TAG_DIRTY tag and submits it. f2fs_write_end_io() observes folio->index=3D11 with nid_of_node(folio)=3D0 and panics from softirq context via blk_done_softirq, even though f2fs_sanity_check_node_footer() has already correctly identified the corruption and would have signalled it via its return value. A filesystem inconsistency reachable from a mounted image must not panic the kernel. Mirror the handling already used in f2fs_finish_read_bio(): capture the helper's return value and mark the bio with BLK_STS_IOERR on mismatch instead of issuing BUG_ON. SBI_NEED_FSCK is set by the helper, so fsck.f2fs will repair the inconsistency on the next mount. Reported-by: syzbot+4af46ee83100e99bce09@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D4af46ee83100e99bce09 Fixes: 50ac3ecd8e05 ("f2fs: fix to do sanity check on node footer in {read,= write}_end_io") Signed-off-by: Deepanshu Kartikey --- fs/f2fs/data.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 8d4f1e75dee3..c149b0ccf22d 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -382,11 +382,11 @@ static void f2fs_write_end_io(struct bio *bio) STOP_CP_REASON_WRITE_FAIL); } =20 - if (is_node_folio(folio)) { - f2fs_sanity_check_node_footer(sbi, folio, - folio->index, NODE_TYPE_REGULAR, true); - f2fs_bug_on(sbi, folio->index !=3D nid_of_node(folio)); - } + if (is_node_folio(folio) && + f2fs_sanity_check_node_footer(sbi, folio, + folio->index, NODE_TYPE_REGULAR, true)) + bio->bi_status =3D BLK_STS_IOERR; + if (f2fs_in_warm_node_list(folio)) f2fs_del_fsync_node_entry(sbi, folio); =20 --=20 2.43.0