From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C77462848BB for ; Tue, 17 Feb 2026 12:52:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771332744; cv=none; b=NkWHK23vXm2GJjFU9bt34tSZQ2EblF/0GGBQ+jNO5HkUphmLNAdr1fVUEbcfFk73EPXuoXrPQt1GRmT9VNUxsoL4FjC8FZ3/2z+XHuzOQzeUmBtEPso9yJUD1jsmAUppeubEnT/nQxCsDEc9KZS5trA6ZK41OJ6tQp0TSuuVyXo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771332744; c=relaxed/simple; bh=k7RfeF4pEmyodpq+IrFBnqV72ECnGrLfmySpg43MhoA=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=Wkteox1uk8FSzBbRgAURH3Jo43VZCW+AnmeoNXo4LL6YGoF5Gg5FgYksD3COd/HQD3etxgjtVGJCn9iWeyXnxF0HWZWS/eHQzHN+fi25G1Jf3jwergLPF+tE1lEwLpHLzovG4Z0mMPsrzItuVfCk8jQMvGcauwDfcw6AQDjnLU0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QubvaU5H; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="QubvaU5H" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37291C4CEF7; Tue, 17 Feb 2026 12:52:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1771332744; bh=k7RfeF4pEmyodpq+IrFBnqV72ECnGrLfmySpg43MhoA=; h=Subject:To:Cc:From:Date:From; b=QubvaU5HjEASkWqNMSN1D7JP/hGmogiWmLyHcSHT53xYRooBnC2vw1ipcSZ0EUgLQ UizH1xj3Imw7y9KkYkyGIGweJTLlQSflx1N1uolioP7AQEwrBqQcH7v4pKdZ5ClRgq gzExA/qzzdb+oeSUwCtb2LQOH1mflS+QJi77oUWw= Subject: FAILED: patch "[PATCH] f2fs: fix to avoid UAF in f2fs_write_end_io()" failed to apply to 5.15-stable tree To: chao@kernel.org,jaegeuk@kernel.org Cc: From: Date: Tue, 17 Feb 2026 13:52:10 +0100 Message-ID: <2026021710-tantrum-seldom-fb6c@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.15-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y git checkout FETCH_HEAD git cherry-pick -x ce2739e482bce8d2c014d76c4531c877f382aa54 # git commit -s git send-email --to '' --in-reply-to '2026021710-tantrum-seldom-fb6c@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From ce2739e482bce8d2c014d76c4531c877f382aa54 Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Wed, 7 Jan 2026 19:22:18 +0800 Subject: [PATCH] f2fs: fix to avoid UAF in f2fs_write_end_io() As syzbot reported an use-after-free issue in f2fs_write_end_io(). It is caused by below race condition: loop device umount - worker_thread - loop_process_work - do_req_filebacked - lo_rw_aio - lo_rw_aio_complete - blk_mq_end_request - blk_update_request - f2fs_write_end_io - dec_page_count - folio_end_writeback - kill_f2fs_super - kill_block_super - f2fs_put_super : free(sbi) : get_pages(, F2FS_WB_CP_DATA) accessed sbi which is freed In kill_f2fs_super(), we will drop all page caches of f2fs inodes before call free(sbi), it guarantee that all folios should end its writeback, so it should be safe to access sbi before last folio_end_writeback(). Let's relocate ckpt thread wakeup flow before folio_end_writeback() to resolve this issue. Cc: stable@kernel.org Fixes: e234088758fc ("f2fs: avoid wait if IO end up when do_checkpoint for better performance") Reported-by: syzbot+b4444e3c972a7a124187@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=b4444e3c972a7a124187 Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 2e133a723b99..f461f1318b4c 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -378,14 +378,20 @@ static void f2fs_write_end_io(struct bio *bio) folio->index != nid_of_node(folio)); dec_page_count(sbi, type); + + /* + * we should access sbi before folio_end_writeback() to + * avoid racing w/ kill_f2fs_super() + */ + if (type == F2FS_WB_CP_DATA && !get_pages(sbi, type) && + wq_has_sleeper(&sbi->cp_wait)) + wake_up(&sbi->cp_wait); + if (f2fs_in_warm_node_list(sbi, folio)) f2fs_del_fsync_node_entry(sbi, folio); folio_clear_f2fs_gcing(folio); folio_end_writeback(folio); } - if (!get_pages(sbi, F2FS_WB_CP_DATA) && - wq_has_sleeper(&sbi->cp_wait)) - wake_up(&sbi->cp_wait); bio_put(bio); }