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: <20140827213103.GV11317@thunk.org>
Date:	Wed, 27 Aug 2014 17:31:03 -0400
From:	Theodore Ts'o <tytso@....edu>
To:	Dmitry Monakhov <dmonakhov@...nvz.org>
Cc:	linux-ext4@...r.kernel.org, lczerner@...hat.com
Subject: Re: [PATCH 3/5] ext4_zero_range: fix incorect journal credits
 reservation

On Mon, Aug 25, 2014 at 11:19:39AM +0400, Dmitry Monakhov wrote:
> Yes, but ext4_index_trans_blocks is statically defined in inode.c,
> but since zero_range works only for extent based
> ext4_ext_index_trans_blocks is sufficient. Also we must reserve 2 block
> for data. So final calculation looks like follows:
> credits =  ext4_ext_index_trans_blocks(inode, 2) + 2

It turns out this wasn't enough.  This was causing test failures in
the data=journal case for tests generic/008, generic/091, generic/127,
and generic/263, due to not reserving enough credits.  After taking a
closer look at the code, and the requirements of ext4_zero_range, I
believe this is the correct fix.

       	       	   	   	   	   - Ted

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 0d531d1..0e9de23 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4831,8 +4831,13 @@ static long ext4_zero_range(struct file *file, loff_t offset,
 		if (ret)
 			goto out_dio;
 	}
-	/* In worst case we have to writeout two nonadjacent unwritten blocks */
-	credits = ext4_ext_index_trans_blocks(inode, 2) + 2;
+	/*
+	 * In worst case we have to writeout two nonadjacent unwritten
+	 * blocks and update the inode
+	 */
+	credits = (2 * ext4_ext_index_trans_blocks(inode, 2)) + 1;
+	if (ext4_should_journal_data(inode))
+		credits += 2;
 	handle = ext4_journal_start(inode, EXT4_HT_MISC, credits);
 	if (IS_ERR(handle)) {
 		ret = PTR_ERR(handle);
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ