* [PATCH] dm-inlinecrypt: Fix signedness bug
@ 2026-05-08 2:37 Ethan Tidmore
2026-05-11 11:15 ` Mikulas Patocka
0 siblings, 1 reply; 2+ messages in thread
From: Ethan Tidmore @ 2026-05-08 2:37 UTC (permalink / raw)
To: Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
Benjamin Marzinski
Cc: Eric Biggers, Linlin Zhang, dm-devel, linux-kernel, Ethan Tidmore
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dm-inlinecrypt: Fix signedness bug
2026-05-08 2:37 [PATCH] dm-inlinecrypt: Fix signedness bug Ethan Tidmore
@ 2026-05-11 11:15 ` Mikulas Patocka
0 siblings, 0 replies; 2+ messages in thread
From: Mikulas Patocka @ 2026-05-11 11:15 UTC (permalink / raw)
To: Ethan Tidmore
Cc: Alasdair Kergon, Mike Snitzer, Benjamin Marzinski, Eric Biggers,
Linlin Zhang, dm-devel, linux-kernel
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-11 11:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08 2:37 [PATCH] dm-inlinecrypt: Fix signedness bug Ethan Tidmore
2026-05-11 11:15 ` Mikulas Patocka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox