Skip to contentSkip to conversation

nilfs2-make-block-erasure-safe-in-nilfs_finish_roll_forward.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message May 19, 2024

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: nilfs2: make block erasure safe in nilfs_finish_roll_forward()
has been removed from the -mm tree. Its filename was
nilfs2-make-block-erasure-safe-in-nilfs_finish_roll_forward.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Ryusuke Konishi <[email protected]>
Subject: nilfs2: make block erasure safe in nilfs_finish_roll_forward()
Date: Sat, 11 May 2024 09:29:42 +0900

The implementation of writing a zero-fill block in nilfs_finish_roll_forward() is not safe. The buffer is being cleared without acquiring a lock or setting the uptodate flag, so theoretically, between the time the buffer's data is cleared and the time it is written back to the block device using sync_dirty_buffer(), that zero data can be undone by concurrent block device reads.

Since this buffer points to a location that has been read from disk once, the uptodate flag will most likely remain, but since it was obtained with __getblk(), that is not guaranteed. In other words, this is exceptional, and this function itself is not normally called (only once when mounting after a specific pattern of unclean shutdown), so it is highly unlikely that this will actually cause a problem.

Anyway, eliminate this potential race issue by protecting the clearing of buffer data with a buffer lock and setting the buffer's uptodate flag within the protected section.

---

 fs/nilfs2/recovery.c |    4 ++++
 1 file changed, 4 insertions(+)
fs/nilfs2/recovery.c renamed from fs/nilfs2/recovery.c~nilfs2-make-block-erasure-safe-in-nilfs_finish_roll_forward +4 -0
@@ -702,8 +702,12 @@ static void nilfs_finish_roll_forward(st
 	if (WARN_ON(!bh))
 		return;  /* should never happen */
 
+	lock_buffer(bh);
 	memset(bh->b_data, 0, bh->b_size);
+	set_buffer_uptodate(bh);
 	set_buffer_dirty(bh);
+	unlock_buffer(bh);
+
 	err = sync_dirty_buffer(bh);
 	if (unlikely(err))
 		nilfs_warn(nilfs->ns_sb,

_

Patches currently in -mm which might be from [email protected] are