mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dm crypt: reject an integrity option without a profile delimiter
@ 2026-11-28  5:54 Wesley Atwell via B4 Relay
  0 siblings, 0 replies; only message in thread
From: Wesley Atwell via B4 Relay @ 2026-11-28  5:54 UTC (permalink / raw)
  To: Mike Snitzer, Mikulas Patocka
  Cc: linux-kernel, Benjamin Marzinski, Alasdair Kergon, dm-devel

From: Wesley Atwell <atwellwea@gmail.com>

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@vger.kernel.org
Signed-off-by: Wesley Atwell <atwellwea@gmail.com>
---
 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@gmail.com>



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-28  5:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-28  5:54 [PATCH] dm crypt: reject an integrity option without a profile delimiter Wesley Atwell via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®