[PATCH] dm crypt: reject an integrity option without a profile delimiter
From: Wesley Atwell via B4 Relay
Date: Sat Nov 28 2026 - 00:54:26 EST
From: Wesley Atwell <atwellwea@xxxxxxxxx>
An administrator creating an authenticated encrypted mapping with
dmsetup can omit the second colon from integrity:<bytes>:<type>. The
existing sscanf() conversion still reports one successful assignment
for integrity:16. The following strchr() then returns NULL; advancing
that pointer and passing it to strcasecmp() causes a kernel Oops and
kills dmsetup instead of rejecting the table.
Check for the required delimiter before advancing to the profile. Return
-EINVAL with the existing invalid-integrity error when it is absent.
Valid aead and none profiles continue to load normally.
OpenAI Codex identified the unchecked parser path during source review,
helped prepare the dmsetup/KVM reproducer, and proposed the guard.
Fedora dmsetup reproduced the Oops on the unmodified dm-7.4 tree. After
the change, a fully initialized dm-integrity and dm-crypt stack
completed read/write I/O, while integrity:16 returned -EINVAL without
an Oops.
Fixes: ef43aa38063a ("dm crypt: add cryptographic data integrity protection (authenticated encryption)")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wesley Atwell <atwellwea@xxxxxxxxx>
---
drivers/md/dm-crypt.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 02038a9cd..8deba9d43 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -3145,8 +3145,13 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar
ti->error = "Invalid integrity arguments";
return -EINVAL;
}
+ sval = strchr(opt_string + strlen("integrity:"), ':');
+ if (!sval) {
+ ti->error = "Invalid integrity arguments";
+ return -EINVAL;
+ }
+ sval++;
cc->used_tag_size = val;
- sval = strchr(opt_string + strlen("integrity:"), ':') + 1;
if (!strcasecmp(sval, "aead")) {
set_bit(CRYPT_MODE_INTEGRITY_AEAD, &cc->cipher_flags);
} else if (strcasecmp(sval, "none")) {
---
base-commit: e92cd41e8e5ee5616c6c7cd4378661d942f0a7c0
change-id: 20261127-dmcrypt-integrity-option-6921e907b81f
Best regards,
--
Wesley Atwell <atwellwea@xxxxxxxxx>