From: Mikulas Patocka <mpatocka@redhat.com>
To: Ethan Tidmore <ethantidmore06@gmail.com>
Cc: Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
Benjamin Marzinski <bmarzins@redhat.com>,
Eric Biggers <ebiggers@google.com>,
Linlin Zhang <linlin.zhang@oss.qualcomm.com>,
dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dm-inlinecrypt: Fix signedness bug
Date: Mon, 11 May 2026 13:15:28 +0200 (CEST) [thread overview]
Message-ID: <9d4298c5-24a6-452e-7345-4d49ae61141e@redhat.com> (raw)
In-Reply-To: <20260508023716.668783-1-ethantidmore06@gmail.com>
Hi
Thanks. I merged this into the existing commit.
Mikulas
On Thu, 7 May 2026, Ethan Tidmore wrote:
> The function get_key_size() returns negative error codes and
> ctx->key_size is an unsigned integer, so the check (ctx->key_size < 0)
> is always impossible
>
> Assign get_key_size() return value to err, check for error code, then
> assign ctx->key_size to err.
>
> Detected by Smatch:
> drivers/md/dm-inlinecrypt.c:329 inlinecrypt_ctr()
> warn: unsigned 'ctx->key_size' is never less than zero.
>
> Fixes: 753450f716417 ("dm-inlinecrypt: add target for inline block device encryption")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---
> drivers/md/dm-inlinecrypt.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/dm-inlinecrypt.c b/drivers/md/dm-inlinecrypt.c
> index 6f804f5a4be6..40d48ba73e23 100644
> --- a/drivers/md/dm-inlinecrypt.c
> +++ b/drivers/md/dm-inlinecrypt.c
> @@ -325,11 +325,13 @@ static int inlinecrypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
> }
>
> /* <key> */
> - ctx->key_size = get_key_size(&argv[1]);
> - if (ctx->key_size < 0) {
> + err = get_key_size(&argv[1]);
> + if (err < 0) {
> ti->error = "Cannot parse key size";
> return -EINVAL;
> }
> + ctx->key_size = err;
> +
> err = inlinecrypt_get_key(argv[1], raw_key, ctx->key_size);
> if (err) {
> ti->error = "Malformed key string";
> --
> 2.54.0
>
prev parent reply other threads:[~2026-05-11 11:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 2:37 Ethan Tidmore
2026-05-11 11:15 ` Mikulas Patocka [this message]
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=9d4298c5-24a6-452e-7345-4d49ae61141e@redhat.com \
--to=mpatocka@redhat.com \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=ebiggers@google.com \
--cc=ethantidmore06@gmail.com \
--cc=linlin.zhang@oss.qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
--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®