All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio: nsm: fix raw ioctl copy error path
@ 2026-06-24 17:35 Yousef Alhouseen
  2026-06-25  5:40 ` Arnd Bergmann
  2026-07-17 11:14 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 3+ messages in thread
From: Yousef Alhouseen @ 2026-06-24 17:35 UTC (permalink / raw)
  To: Alexander Graf
  Cc: The AWS Nitro Enclaves Team, Arnd Bergmann, Greg Kroah-Hartman,
	linux-kernel, Yousef Alhouseen

nsm_dev_ioctl() uses a common exit path which unlocks nsm->lock.

A failed copy_from_user() reaches that path before the mutex is locked.

Return -EFAULT directly for that pre-lock failure.

Signed-off-by: Yousef Alhouseen <alhouseenyousef@gmail.com>
---
 drivers/misc/nsm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/misc/nsm.c b/drivers/misc/nsm.c
index ef7b32742..e39ff0071 100644
--- a/drivers/misc/nsm.c
+++ b/drivers/misc/nsm.c
@@ -365,9 +365,8 @@ static long nsm_dev_ioctl(struct file *file, unsigned int cmd,
 		return -EINVAL;
 
 	/* Copy user argument struct to kernel argument struct */
-	r = -EFAULT;
 	if (copy_from_user(&raw, argp, _IOC_SIZE(cmd)))
-		goto out;
+		return -EFAULT;
 
 	mutex_lock(&nsm->lock);
 
-- 
2.54.0


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

* Re: [PATCH] virtio: nsm: fix raw ioctl copy error path
  2026-06-24 17:35 [PATCH] virtio: nsm: fix raw ioctl copy error path Yousef Alhouseen
@ 2026-06-25  5:40 ` Arnd Bergmann
  2026-07-17 11:14 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2026-06-25  5:40 UTC (permalink / raw)
  To: Yousef Alhouseen, Alexander Graf
  Cc: The AWS Nitro Enclaves Team, Greg Kroah-Hartman, linux-kernel

On Wed, Jun 24, 2026, at 19:35, Yousef Alhouseen wrote:
> nsm_dev_ioctl() uses a common exit path which unlocks nsm->lock.
>
> A failed copy_from_user() reaches that path before the mutex is locked.
>
> Return -EFAULT directly for that pre-lock failure.
>
> Signed-off-by: Yousef Alhouseen <alhouseenyousef@gmail.com>
> ---

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

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

* Re: [PATCH] virtio: nsm: fix raw ioctl copy error path
  2026-06-24 17:35 [PATCH] virtio: nsm: fix raw ioctl copy error path Yousef Alhouseen
  2026-06-25  5:40 ` Arnd Bergmann
@ 2026-07-17 11:14 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2026-07-17 11:14 UTC (permalink / raw)
  To: Yousef Alhouseen
  Cc: Alexander Graf, The AWS Nitro Enclaves Team, Arnd Bergmann,
	linux-kernel

On Wed, Jun 24, 2026 at 07:35:01PM +0200, Yousef Alhouseen wrote:
> nsm_dev_ioctl() uses a common exit path which unlocks nsm->lock.
> 
> A failed copy_from_user() reaches that path before the mutex is locked.
> 
> Return -EFAULT directly for that pre-lock failure.
> 
> Signed-off-by: Yousef Alhouseen <alhouseenyousef@gmail.com>
> ---
>  drivers/misc/nsm.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

The subject says "virtio" yet that is not what this driver is :(

Can you fix that up and resend?

thanks,

greg k-h

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

end of thread, other threads:[~2026-07-17 11:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24 17:35 [PATCH] virtio: nsm: fix raw ioctl copy error path Yousef Alhouseen
2026-06-25  5:40 ` Arnd Bergmann
2026-07-17 11:14 ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.