dm crypt: reject an integrity option without a profile delimiter
PATCH 1/1 dm crypt: reject an integrity option without a profile delimiter
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.
--- drivers/md/dm-crypt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/md/dm-crypt.c +6 -1
@@ -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,
Signature · 1 line
Wesley Atwell <[email protected]>