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]
Message-Id: <20230323145404.21381-2-jack@suse.cz>
Date:   Thu, 23 Mar 2023 15:53:59 +0100
From:   Jan Kara <jack@...e.cz>
To:     Ted Tso <tytso@....edu>
Cc:     <linux-ext4@...r.kernel.org>, Eric Biggers <ebiggers@...nel.org>,
        Jan Kara <jack@...e.cz>
Subject: [PATCH 2/2] ext4: Fix crash on shutdown filesystem

Test generic/388 triggered a crash in mpage_release_unused_pages()
because a page in mpd->first_page..mpd->next_page range was not locked.
This can happen in data=journal mode when we exit from
mpage_prepare_extent_to_map() before actually initializing
mpd->next_page. Move the initialization to a place before we can exit
with error from mpage_prepare_extent_to_map().

Fixes: f7233fb54d18 ("ext4: Convert data=journal writeback to use ext4_writepages()")
Signed-off-by: Jan Kara <jack@...e.cz>
---
 fs/ext4/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 15bac8181798..dbcc8b48c7ba 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2428,6 +2428,8 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
 	else
 		tag = PAGECACHE_TAG_DIRTY;
 
+	mpd->map.m_len = 0;
+	mpd->next_page = index;
 	/*
 	 * Start a transaction for writeback of journalled data. We don't start
 	 * the transaction if the filesystem is frozen. In that case we
@@ -2443,8 +2445,6 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
 			return PTR_ERR(handle);
 	}
 	folio_batch_init(&fbatch);
-	mpd->map.m_len = 0;
-	mpd->next_page = index;
 	while (index <= end) {
 		nr_folios = filemap_get_folios_tag(mapping, &index, end,
 				tag, &fbatch);
-- 
2.35.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ