Information Disclosure
Description
The commit fixes an information disclosure risk where the caller's thread keyring could be kept alive longer than the caller's lifetime when opening a table device via the block dm subsystem. Prior to the patch, the backing device could be opened with the caller's credentials, potentially pinning the caller's thread keyring in memory and allowing leakage of sensitive key material (e.g., the LUKS volume key) during operations like luksSuspend. The fix ensures the backing device is opened with kernel credentials (scoped_with_kernel_creds), preventing the caller's credentials from being pinned in the file object, thereby avoiding leaking the thread keyring and making the key material discardable as intended. This mitigates an information disclosure vulnerability related to cryptographic keys in memory.
Commit Details
Author: Ingo Blechschmidt
Date: 2026-06-17 14:33 UTC
Message:
dm: avoid leaking the caller's thread keyring via the table device file
The refactoring in commit a28d893eb327 ("md: port block device access to file")
accidentally causes the caller's thread keyring to be kept alive long
beyond the caller's lifetime.
As a result, "cryptsetup luksSuspend" silently fails to wipe the
LUKS volume key from memory.
In detail: "cryptsetup luksOpen" uses its supposedly ephemeral thread
keyring to pass the volume key to the kernel. dm-crypt's
crypt_set_keyring_key() copies the key material into its own
crypt_config structure and then drops its own reference to the key in
the keyring with key_put().
With this fix, restoring pre-v6.9 behavior, the copy in the thread
keyring is then promptly garbage collected, such that exactly one copy
of the volume key remains. This single copy is correctly wiped from
memory on "cryptsetup luksSuspend".
Without this fix, the thread keyring and the volume key in it remains.
This second copy is only freed on "luksClose". "luksSuspend" neither
knows about this copy nor has any way to remove it, so the key remains
recoverable from RAM after a suspend that is documented to have wiped it.
This fix should not introduce new security problems, as the code is
anyway gated by CAP_SYS_ADMIN. The device-mapper core, not the calling
task, is the legitimate owner of this long-lived file.
Fixes: a28d893eb327 ("md: port block device access to file")
Closes: https://gitlab.com/cryptsetup/cryptsetup/-/work_items/993
Link: https://www.speicherleck.de/iblech/cryptsetup-luksSuspend-issue-reproduction/
Signed-off-by: Ingo Blechschmidt <iblech@speicherleck.de>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
Tested-by: Ondrej Kozina <okozina@redhat.com>
Triage Assessment
Vulnerability Type: Information Disclosure
Confidence: HIGH
Reasoning:
The change prevents leaking the caller's thread keyring (and thus sensitive key material) by opening the backing device with kernel credentials, avoiding the keyring being kept alive and readable from user space. This directly mitigates a potential information disclosure vulnerability related to cryptographic keys being exposed in memory after operations like luksSuspend.
Verification Assessment
Vulnerability Type: Information Disclosure
Confidence: HIGH
Affected Versions: v7.0-rc6 and earlier (before commit 981ccd97f7153d310dfa92a534525bbaf46752c2)
Code Diff
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 7287bed6eb6421..d413bfaf352782 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -735,7 +735,16 @@ static struct table_device *open_table_device(struct mapped_device *md,
return ERR_PTR(-ENOMEM);
refcount_set(&td->count, 1);
- bdev_file = bdev_file_open_by_dev(dev, mode, _dm_claim_ptr, NULL);
+ /*
+ * Open the backing device with kernel rather than caller
+ * credentials. Otherwise the caller's credentials would be
+ * pinned in bdev_file->f_cred until the table device is closed.
+ * That would keep the caller's thread keyring alive long beyond the
+ * lifetime of the caller, breaking userspace expectation (e.g.
+ * cryptsetup(8) leaking the LUKS volume key).
+ */
+ scoped_with_kernel_creds()
+ bdev_file = bdev_file_open_by_dev(dev, mode, _dm_claim_ptr, NULL);
if (IS_ERR(bdev_file)) {
r = PTR_ERR(bdev_file);
goto out_free_td;