]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:21:11 +0000 (07:21 -0500)
commit97330e31ea1646a9fae568c2a5bbf2f0d41d10bf
tree6bcb4a16318ccf5d463ac6eccb98881fa9779719
parentf122f2b3ce9dbde60bf7ab0b180fe4a01f9d9bc4
dm: fix excessive blk-crypto operations for invalid keys

[ Upstream commit d6d0e6b9d54532264761405a1ba8ea5bd293acb1 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/dm-table.c