[PATCH linux-4.7-rc7] blk_stack_limits() setting discard_granularity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



blk_stack_limits() can set discard_granularity bigger than
max_discard_sectors (in bytes).
This makes blk_bio_discard_split() non-functional and can lead to data
corruption.

-- 

Florian-Ewald Mueller

Architecture Board


ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin


Tel:       +49 30 577 008 331
Fax:      +49 30 577 008 598
Email:   florian-ewald.mueller@xxxxxxxxxxxxxxxx
URL:     http://www.profitbricks.de

Sitz der Gesellschaft: Berlin.
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B.
Geschäftsführer: Andreas Gauger, Achim Weiss.

Please consider the environment before printing this email.
From: Florian-Ewald Mueller <florian-ewald.mueller@xxxxxxxxxxxxxxxx>
Subject: [PATCH] blk_stack_limits()
blk_stack_limits() can set discard_granularity bigger than max_discard_sectors (in bytes).
This makes blk_bio_discard_split() non-functional and can lead to data corruption.

Signed-off-by: Florian-Ewald Mueller <florian-ewald.mueller@xxxxxxxxxxxxxxxx>

--- linux-4.7-rc7/block/blk-settings.c.orig	2016-07-21 19:39:44.831351396 +0200
+++ linux-4.7-rc7/block/blk-settings.c	2016-07-21 19:40:04.582968496 +0200
@@ -626,8 +626,10 @@ int blk_stack_limits(struct queue_limits
 							 b->max_hw_discard_sectors);
 		t->discard_granularity = max(t->discard_granularity,
 					     b->discard_granularity);
+		if (t->discard_granularity > (t->max_discard_sectors << 9))
+			t->discard_granularity = t->max_discard_sectors << 9;
 		t->discard_alignment = lcm_not_zero(t->discard_alignment, alignment) %
-			t->discard_granularity;
+			(t->discard_granularity ? : 1);
 	}
 
 	return ret;

[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux