FAILED: patch "[PATCH] f2fs: fix to avoid potential deadloop in" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe 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 <[email protected]>.
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 ce366bfa821ec81dd45bde547ee31e659306cc61
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090958-plastic-payee-9f0a@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From ce366bfa821ec81dd45bde547ee31e659306cc61 Mon Sep 17 00:00:00 2001
From: Chao Yu <[email protected]>
Date: Mon, 24 Aug 2026 21:17:29 +0800
Subject: [PATCH] f2fs: fix to avoid potential deadloop in
f2fs_fsync_node_pages()
There is potential deadloop in race condition:
Thread A Thread B
- fsync
- f2fs_do_sync_file
- f2fs_fsync_node_pages
- last_fsync_dnode
- folio_get(last_folio)
- f2fs_setattr
- f2fs_truncate
- f2fs_truncate_blocks
- f2fs_do_truncate_blocks
- f2fs_truncate_inode_blocks
- truncate_dnode
- truncate_node
- invalidate_mapping_pages
- folio->mapping = NULL
- is_node_folio alwasy return false
- atomic && !marked is always true,
then goto retry
fs/f2fs/node.c +5 -0
@@ -2016,6 +2016,11 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,f2fs_debug (sbi,"Retry to write fsync mark: ino=%u, idx=%lx" , ino, last_folio->index);folio_lock (last_folio); +if (unlikely (!is_node_folio (last_folio))) { +f2fs_folio_put (last_folio, true); + ret = -EAGAIN ; + goto out; + }f2fs_folio_wait_writeback (last_folio,NODE , true, true);folio_mark_dirty (last_folio);folio_unlock (last_folio);
Sasha Levin
maintainerPATCH 1/1 f2fs: fix to avoid potential deadloop in f2fs_fsync_node_pages()
From: Chao Yu <[email protected]>
[ Upstream commit ce366bfa821ec81dd45bde547ee31e659306cc61 ]
There is potential deadloop in race condition:
Thread A Thread B
- fsync
- f2fs_do_sync_file
- f2fs_fsync_node_pages
- last_fsync_dnode
- folio_get(last_folio)
- f2fs_setattr
- f2fs_truncate
- f2fs_truncate_blocks
- f2fs_do_truncate_blocks
- f2fs_truncate_inode_blocks
- truncate_dnode
- truncate_node
- invalidate_mapping_pages
- folio->mapping = NULL
- is_node_folio alwasy return false
- atomic && !marked is always true,
then goto retry
--- fs/f2fs/node.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/f2fs/node.c +5 -0
@@ -1847,6 +1847,11 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,f2fs_debug (sbi,"Retry to write fsync mark: ino=%u, idx=%lx" , ino, last_page->index);lock_page (last_page); +if (unlikely (last_page->mapping !=NODE_MAPPING (sbi))) { +f2fs_put_page (last_page,1 ); + ret = -EAGAIN ; + goto out; + }f2fs_wait_on_page_writeback (last_page,NODE , true, true);set_page_dirty (last_page);unlock_page (last_page);
Signature · 1 line
2.53.0