]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: relock CACHE_MTX after calling ->write_error master next
authorDarrick J. Wong <djwong@kernel.org>
Fri, 15 Aug 2025 16:25:58 +0000 (09:25 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 21 Aug 2025 00:00:54 +0000 (17:00 -0700)
In the UNIX I/O manager, we drop CACHE_MTX before calling the
->write_error handler in case it decides to retry the failed write.
Therefore, we must retake the lock after it returns, to ensure
consistent lock state when flush_cached_blocks returns.

Cc: <linux-ext4@vger.kernel.org> # v1.46.6
Fixes: 0e0c7537eb5fdc ("libext2fs: unix_io: fix_potential error path deadlock in flush_cached_blocks()")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
lib/ext2fs/unix_io.c

index 1af246da345bca519fdf047f577f7f801983895d..cb408f51779aa7a3c2f382cb2da923ff353605e2 100644 (file)
@@ -734,6 +734,7 @@ retry:
                                        retval2);
                                if (err_buf)
                                        ext2fs_free_mem(&err_buf);
+                               mutex_lock(data, CACHE_MTX);
                                goto retry;
                        } else
                                cache->write_err = 0;