The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] dm-inlinecrypt: Fix an error handling path in inlinecrypt_ctr()
@ 2026-06-20 19:33 Christophe JAILLET
  2026-06-20 21:23 ` Eric Biggers
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2026-06-20 19:33 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
	Benjamin Marzinski, Linlin Zhang, Eric Biggers
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, dm-devel

All error handling paths, except but this one, branch to the 'bad' label in
the error handling path.

If not done, there is a memory leak and some sensitive data may be kept
around.

So, fix this error path and also do the needed clean-up.

Fixes: e7f57d2c47e2 ("dm-inlinecrypt: add target for inline block device encryption")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only
---
 drivers/md/dm-inlinecrypt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-inlinecrypt.c b/drivers/md/dm-inlinecrypt.c
index be1b4aa8f28b..bb4ded4757d1 100644
--- a/drivers/md/dm-inlinecrypt.c
+++ b/drivers/md/dm-inlinecrypt.c
@@ -347,7 +347,8 @@ static int inlinecrypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 	err = get_key_size(&argv[1]);
 	if (err < 0) {
 		ti->error = "Cannot parse key size";
-		return -EINVAL;
+		err = -EINVAL;
+		goto bad;
 	}
 	ctx->key_size = err;
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dm-inlinecrypt: Fix an error handling path in inlinecrypt_ctr()
  2026-06-20 19:33 [PATCH] dm-inlinecrypt: Fix an error handling path in inlinecrypt_ctr() Christophe JAILLET
@ 2026-06-20 21:23 ` Eric Biggers
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2026-06-20 21:23 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
	Benjamin Marzinski, Linlin Zhang, linux-kernel, kernel-janitors,
	dm-devel

On Sat, Jun 20, 2026 at 09:33:03PM +0200, Christophe JAILLET wrote:
> All error handling paths, except but this one, branch to the 'bad' label in
> the error handling path.
> 
> If not done, there is a memory leak and some sensitive data may be kept
> around.
> 
> So, fix this error path and also do the needed clean-up.
> 
> Fixes: e7f57d2c47e2 ("dm-inlinecrypt: add target for inline block device encryption")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only
> ---
>  drivers/md/dm-inlinecrypt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/md/dm-inlinecrypt.c b/drivers/md/dm-inlinecrypt.c
> index be1b4aa8f28b..bb4ded4757d1 100644
> --- a/drivers/md/dm-inlinecrypt.c
> +++ b/drivers/md/dm-inlinecrypt.c
> @@ -347,7 +347,8 @@ static int inlinecrypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
>  	err = get_key_size(&argv[1]);
>  	if (err < 0) {
>  		ti->error = "Cannot parse key size";
> -		return -EINVAL;
> +		err = -EINVAL;
> +		goto bad;
>  	}
>  	ctx->key_size = err;

Reviewed-by: Eric Biggers <ebiggers@kernel.org>

The missing 'goto' below could use a patch too:

	if (ctx->iv_offset & ((ctx->sector_size >> SECTOR_SHIFT) - 1)) {
		ti->error = "Wrong alignment of iv_offset sector";
		err = -EINVAL;
	}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-20 21:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-20 19:33 [PATCH] dm-inlinecrypt: Fix an error handling path in inlinecrypt_ctr() Christophe JAILLET
2026-06-20 21:23 ` Eric Biggers

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