Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87e52a46 authored by Milan Broz's avatar Milan Broz Committed by Eric Biggers
Browse files

BACKPORT: dm crypt: reject sector_size feature if device length is not aligned to it



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.

Fixes: 8f0009a225 ("dm crypt: optionally support larger encryption sector size")
Cc: stable@vger.kernel.org # 4.12+
Signed-off-by: default avatarMilan Broz <gmazyland@gmail.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>

(cherry picked from commit 783874b050768d361239e444ba0fa396bb6d463f)

Conflicts:
	drivers/md/dm-crypt.c

Change-Id: I46721db938c43c7d1480eaaed170b5683a7f6d14
Bug: 112008522
Test: As series, see Ie247fd41b11adcf8520de0b1554568a1b7155860
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
parent 52ad0c48
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1892,6 +1892,10 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
					ti->error = "Invalid feature value for sector_size";
					goto bad;
				}
				if (ti->len & ((cc->sector_size >> SECTOR_SHIFT) - 1)) {
					ti->error = "Device size is not multiple of sector_size feature";
					goto bad;
				}
				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);