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>] [day] [month] [year] [list]
Date:   Tue, 22 May 2018 09:59:07 +0300
From:   Artem Blagodarenko <artem.blagodarenko@...il.com>
To:     linux-ext4@...r.kernel.org
Cc:     adilger.kernel@...ger.ca, alexey.lyashkov@...il.com,
        Andrew Perepechko <c17827@...y.com>,
        Vitaly Fertman <c17818@...y.com>,
        Vitaly Fertman <vitaly_fertman@...atex.com>
Subject: [PATCH] mmp race

From: Vitaly Fertman <vitaly_fertman@...atex.com>

make sleep between reads twice in ext4_multi_mount_protect twice
longer than between write and read, make the later one equal to the
system check_interval

Xyratex-Bug-Id: MRP-390

Reviewed-by: Andrew Perepechko <Andrew_Perepechko@...atex.com>
---
 lib/ext2fs/mmp.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
index 9a771de7..cb968adf 100644
--- a/lib/ext2fs/mmp.c
+++ b/lib/ext2fs/mmp.c
@@ -296,6 +296,13 @@ errcode_t ext2fs_mmp_start(ext2_filsys fs)
 	if (mmp_check_interval < EXT4_MMP_MIN_CHECK_INTERVAL)
 		mmp_check_interval = EXT4_MMP_MIN_CHECK_INTERVAL;
 
+	/*
+	 * If check_interval in MMP block is larger, use that instead of
+	 * check_interval from the superblock.
+	 */
+	if (mmp_s->mmp_check_interval > mmp_check_interval)
+		mmp_check_interval = mmp_s->mmp_check_interval;
+
 	seq = mmp_s->mmp_seq;
 	if (seq == EXT4_MMP_SEQ_CLEAN)
 		goto clean_seq;
@@ -309,13 +316,6 @@ errcode_t ext2fs_mmp_start(ext2_filsys fs)
 		goto mmp_error;
 	}
 
-	/*
-	 * If check_interval in MMP block is larger, use that instead of
-	 * check_interval from the superblock.
-	 */
-	if (mmp_s->mmp_check_interval > mmp_check_interval)
-		mmp_check_interval = mmp_s->mmp_check_interval;
-
 	sleep(2 * mmp_check_interval + 1);
 
 	retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
@@ -344,7 +344,10 @@ clean_seq:
 	if (retval)
 		goto mmp_error;
 
-	sleep(2 * mmp_check_interval + 1);
+	/* This sleep between write & read must be shorter than the previous
+	 * sleep between 2 reads, so that the check above of a racing thread
+	 * would never succeed between this write & read. */
+	sleep(mmp_check_interval + 1);
 
 	retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
 	if (retval)
-- 
2.14.3 (Apple Git-98)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ