Eric Biggers 47a846536e block/keyslot-manager: prevent crash when num_slots=1
If there is only one keyslot, then blk_ksm_init() computes
slot_hashtable_size=1 and log_slot_ht_size=0.  This causes
blk_ksm_find_keyslot() to crash later because it uses
hash_ptr(key, log_slot_ht_size) to find the hash bucket containing the
key, and hash_ptr() doesn't support the bits == 0 case.

Fix this by making the hash table always have at least 2 buckets.

Tested by running:

    kvm-xfstests -c ext4 -g encrypt -m inlinecrypt \
                 -o blk-crypto-fallback.num_keyslots=1

Fixes: 1b2628397058 ("block: Keyslot Manager for Inline Encryption")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-11-20 11:52:52 -07:00
..
2020-10-13 12:12:44 -07:00
2020-08-18 07:48:08 -07:00
2020-10-13 12:12:44 -07:00
2020-08-18 07:48:08 -07:00
2020-08-18 07:48:08 -07:00
2020-10-13 12:12:44 -07:00
2020-09-03 15:20:47 -06:00
2020-03-17 20:55:21 +01:00
2020-10-24 12:46:42 -07:00
2020-10-13 12:12:44 -07:00
2020-05-29 16:30:39 -06:00
2020-09-23 09:18:13 -06:00
2020-01-03 09:33:21 +01:00
2020-09-25 08:18:57 -06:00
2020-10-13 13:04:41 -07:00
2020-01-06 20:59:04 -07:00