mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wesley Atwell via B4 Relay <devnull+atwellwea.gmail.com@kernel.org>
To: Mike Snitzer <snitzer@kernel.org>,
	 Mikulas Patocka <mpatocka@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	Benjamin Marzinski <bmarzins@redhat.com>,
	 Alasdair Kergon <agk@redhat.com>,
	dm-devel@lists.linux.dev
Subject: [PATCH] dm crypt: reject an integrity option without a profile delimiter
Date: Fri, 27 Nov 2026 22:54:01 -0700	[thread overview]
Message-ID: <20261127-dmcrypt-integrity-option-v1-1-1dc42a7be52a@gmail.com> (raw)

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>



                 reply	other threads:[~2026-11-28  5:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127-dmcrypt-integrity-option-v1-1-1dc42a7be52a@gmail.com \
    --to=devnull+atwellwea.gmail.com@kernel.org \
    --cc=agk@redhat.com \
    --cc=atwellwea@gmail.com \
    --cc=bmarzins@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®