mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] misc: nsm: require CAP_SYS_ADMIN for raw ioctl
@ 2026-06-21  8:57 Vu Nguyen Anh Khoa
  2026-06-21  8:57 ` [PATCH 2/2] misc: nsm: do not unlock mutex before locking it Vu Nguyen Anh Khoa
  2026-06-21  9:33 ` [PATCH 1/2] misc: nsm: require CAP_SYS_ADMIN for raw ioctl Graf (AWS), Alexander
  0 siblings, 2 replies; 5+ messages in thread
From: Vu Nguyen Anh Khoa @ 2026-06-21  8:57 UTC (permalink / raw)
  To: Alexander Graf, Arnd Bergmann, Greg Kroah-Hartman
  Cc: The AWS Nitro Enclaves Team, linux-kernel, Vu Nguyen Anh Khoa

NSM_IOCTL_RAW lets userspace submit raw NSM messages. The UAPI
documents this ioctl as available only with CAP_SYS_ADMIN, but /dev/nsm
is registered with mode 0666 and nsm_dev_ioctl() does not enforce that
restriction.

Reject unprivileged raw ioctl requests before accepting user-controlled
NSM messages.

Signed-off-by: Vu Nguyen Anh Khoa <khoavna.tin.2225@gmail.com>
---
 drivers/misc/nsm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/misc/nsm.c b/drivers/misc/nsm.c
index ef7b32742..52790df7d 100644
--- a/drivers/misc/nsm.c
+++ b/drivers/misc/nsm.c
@@ -9,6 +9,7 @@
  * space can use to issue these commands.
  */
 
+#include <linux/capability.h>
 #include <linux/file.h>
 #include <linux/fs.h>
 #include <linux/interrupt.h>
@@ -361,6 +362,9 @@ static long nsm_dev_ioctl(struct file *file, unsigned int cmd,
 	if (cmd != NSM_IOCTL_RAW)
 		return -EINVAL;
 
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+
 	if (_IOC_SIZE(cmd) != sizeof(raw))
 		return -EINVAL;
 
-- 
2.43.0


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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/2] misc: nsm: do not unlock mutex before locking it Vu Nguyen Anh Khoa
2026-06-21  9:33   ` 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

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®