All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm-crypt: Reject sector_size feature if device length is not aligned to it
@ 2017-09-13 13:45 Milan Broz
  2017-09-30 18:31 ` Milan Broz
  0 siblings, 1 reply; 12+ messages in thread
From: Milan Broz @ 2017-09-13 13:45 UTC (permalink / raw)
  To: dm-devel; +Cc: mpatocka, Milan Broz

If a crypt mapping uses optional sector_size feature, additional
restrictions to mapped device segment size must be applied in constructor,
otherwise the device activation will fail later.

Signed-off-by: Milan Broz <gmazyland@gmail.com>
---
 drivers/md/dm-crypt.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 54aef8ed97db..488ecd0b1bd0 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -2584,6 +2584,10 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar
 				ti->error = "Invalid feature value for sector_size";
 				return -EINVAL;
 			}
+			if (ti->len & ((cc->sector_size >> SECTOR_SHIFT) - 1)) {
+				ti->error = "Device size is not multiple of sector_size feature";
+				return -EINVAL;
+			}
 			cc->sector_shift = __ffs(cc->sector_size) - SECTOR_SHIFT;
 		} else if (!strcasecmp(opt_string, "iv_large_sectors"))
 			set_bit(CRYPT_IV_LARGE_SECTORS, &cc->cipher_flags);
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-10-04 15:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-13 13:45 [PATCH] dm-crypt: Reject sector_size feature if device length is not aligned to it Milan Broz
2017-09-30 18:31 ` Milan Broz
2017-10-02 14:43   ` Mikulas Patocka
2017-10-03  6:27     ` Milan Broz
2017-10-03 12:05     ` Alasdair G Kergon
2017-10-03 18:08       ` Mike Snitzer
2017-10-03 19:09         ` Alasdair G Kergon
2017-10-03 20:08           ` Mikulas Patocka
2017-10-03 20:33             ` Milan Broz
2017-10-03 21:18               ` Mike Snitzer
2017-10-04  6:45                 ` Milan Broz
2017-10-04 15:05                   ` Mike Snitzer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.