]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
dm: fix excessive blk-crypto operations for invalid keys
authorEric Biggers <ebiggers@kernel.org>
Sat, 17 Jan 2026 03:02:36 +0000 (19:02 -0800)
committerMikulas Patocka <mpatocka@redhat.com>
Wed, 21 Jan 2026 16:55:28 +0000 (17:55 +0100)
commitd6d0e6b9d54532264761405a1ba8ea5bd293acb1
treea2a0efccf9543ab016ffdb3cba13dca42f91b903
parent0f1e16b3a8634d540fb0c7a11ca13412d2902974
dm: fix excessive blk-crypto operations for invalid keys

dm_exec_wrappedkey_op() passes through the derive_sw_secret, import_key,
generate_key, and prepare_key blk-crypto operations to an underlying
device.

Currently, it calls the operation on every underlying device until one
returns success.

This logic is flawed when the operation is expected to fail, such as an
invalid key being passed to derive_sw_secret.  That can happen if
userspace passes an invalid key to the FS_IOC_ADD_ENCRYPTION_KEY ioctl.

When that happens on a device-mapper device that consists of many
dm-linear targets, a lot of unnecessary key unwrapping requests get sent
to the underlying key wrapping hardware.

Fix this by considering the first device only.  As already documented in
the comment, it was already checked that all underlying devices support
wrapped keys, so this should be fine.

Fixes: e93912786e50 ("dm: pass through operations on wrapped inline crypto keys")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-table.c