From: Vu Nguyen Anh Khoa <khoavna.tin.2225@gmail.com>
To: Alexander Graf <graf@amazon.com>, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: The AWS Nitro Enclaves Team <aws-nitro-enclaves-devel@amazon.com>,
linux-kernel@vger.kernel.org,
Vu Nguyen Anh Khoa <khoavna.tin.2225@gmail.com>
Subject: [PATCH 2/2] misc: nsm: do not unlock mutex before locking it
Date: Sun, 21 Jun 2026 15:57:43 +0700 [thread overview]
Message-ID: <20260621085743.76329-2-khoavna.tin.2225@gmail.com> (raw)
In-Reply-To: <20260621085743.76329-1-khoavna.tin.2225@gmail.com>
nsm_dev_ioctl() jumps to the common out label when the initial
copy_from_user() fails. That failure path runs before
mutex_lock(&nsm->lock), but the out label unconditionally calls
mutex_unlock(&nsm->lock).
Return -EFAULT directly for the pre-lock copy_from_user() failure so
only paths that acquired the mutex release it.
Signed-off-by: Vu Nguyen Anh Khoa <khoavna.tin.2225@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 52790df7d..8153edff3 100644
--- a/drivers/misc/nsm.c
+++ b/drivers/misc/nsm.c
@@ -369,9 +369,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.43.0
next prev parent reply other threads:[~2026-06-21 9:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-21 8:57 [PATCH 1/2] misc: nsm: require CAP_SYS_ADMIN for raw ioctl Vu Nguyen Anh Khoa
2026-06-21 8:57 ` Vu Nguyen Anh Khoa [this message]
2026-06-21 9:33 ` [PATCH 2/2] misc: nsm: do not unlock mutex before locking it Graf (AWS), Alexander
2026-06-21 9:33 ` [PATCH 1/2] misc: nsm: require CAP_SYS_ADMIN for raw ioctl Graf (AWS), Alexander
2026-06-25 22:23 ` Graf (AWS), Alexander
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=20260621085743.76329-2-khoavna.tin.2225@gmail.com \
--to=khoavna.tin.2225@gmail.com \
--cc=arnd@arndb.de \
--cc=aws-nitro-enclaves-devel@amazon.com \
--cc=graf@amazon.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.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®