lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 23 Apr 2020 20:37:00 -0300
From:   Mauricio Faria de Oliveira <mfo@...onical.com>
To:     linux-ext4@...r.kernel.org, "Theodore Y. Ts'o" <tytso@....edu>
Cc:     dann frazier <dann.frazier@...onical.com>,
        Andreas Dilger <adilger@...ger.ca>, Jan Kara <jack@...e.com>
Subject: [RFC PATCH 06/11] ext4: data=journal: prevent journalled writeback deadlock in ext4_write_begin()

This patch checks for and prevents the deadlock with a page in
journalled writeback in ext4_write_begin().

Finally, add wait_on_page_writeback() if data=journal mode.

Note: similar changes are not needed in ext4_da_write_begin()
as delayed allocation is not applicable to data journalling
(different struct address_space_operations).

Signed-off-by: Mauricio Faria de Oliveira <mfo@...onical.com>
---
 fs/ext4/inode.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 401313be8a5b..f58c426aaca1 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1149,6 +1149,8 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
 	page = grab_cache_page_write_begin(mapping, index, flags);
 	if (!page)
 		return -ENOMEM;
+	if (ext4_should_journal_data(inode))
+		wait_on_page_writeback(page);
 	unlock_page(page);
 
 retry_journal:
@@ -1165,9 +1167,19 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
 		put_page(page);
 		ext4_journal_stop(handle);
 		goto retry_grab;
+	} else if (ext4_should_journal_data(inode) &&
+		   ext4_check_journalled_writeback(handle, page)) {
+		/* Or transaction may block page writeback */
+		unlock_page(page);
+		put_page(page);
+		ext4_journal_stop(handle);
+		ext4_start_commit_datasync(inode);
+		goto retry_grab;
 	}
 	/* In case writeback began while the page was unlocked */
 	wait_for_stable_page(page);
+	if (ext4_should_journal_data(inode))
+		wait_on_page_writeback(page);
 
 #ifdef CONFIG_FS_ENCRYPTION
 	if (ext4_should_dioread_nolock(inode))
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ