Skip to content

Commit 1217e1d

Browse files
NeilBrownshligit
authored andcommitted
md: be careful not lot leak internal curr_resync value into metadata. -- (all)
mddev->curr_resync usually records where the current resync is up to, but during the starting phase it has some "magic" values. 1 - means that the array is trying to start a resync, but has yielded to another array which shares physical devices, and also needs to start a resync 2 - means the array is trying to start resync, but has found another array which shares physical devices and has already started resync. 3 - means that resync has commensed, but it is possible that nothing has actually been resynced yet. It is important that this value not be visible to user-space and particularly that it doesn't get written to the metadata, as the resync or recovery checkpoint. In part, this is because it may be slightly higher than the correct value, though this is very rare. In part, because it is not a multiple of 4K, and some devices only support 4K aligned accesses. There are two places where this value is propagates into either ->curr_resync_completed or ->recovery_cp or ->recovery_offset. These currently avoid the propagation of values 1 and 3, but will allow 3 to leak through. Change them to only propagate the value if it is > 3. As this can cause an array to fail, the patch is suitable for -stable. Cc: stable@vger.kernel.org (v3.7+) Reported-by: Viswesh <viswesh.vichu@gmail.com> Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Shaohua Li <shli@fb.com>
1 parent 7449f69 commit 1217e1d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/md/md.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8144,14 +8144,14 @@ void md_do_sync(struct md_thread *thread)
81448144

81458145
if (!test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
81468146
!test_bit(MD_RECOVERY_INTR, &mddev->recovery) &&
8147-
mddev->curr_resync > 2) {
8147+
mddev->curr_resync > 3) {
81488148
mddev->curr_resync_completed = mddev->curr_resync;
81498149
sysfs_notify(&mddev->kobj, NULL, "sync_completed");
81508150
}
81518151
mddev->pers->sync_request(mddev, max_sectors, &skipped);
81528152

81538153
if (!test_bit(MD_RECOVERY_CHECK, &mddev->recovery) &&
8154-
mddev->curr_resync > 2) {
8154+
mddev->curr_resync > 3) {
81558155
if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) {
81568156
if (test_bit(MD_RECOVERY_INTR, &mddev->recovery)) {
81578157
if (mddev->curr_resync >= mddev->recovery_cp) {

0 commit comments

Comments
 (0)