mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] virtio: nsm: require CAP_SYS_ADMIN for raw messages
@ 2026-06-24 17:36 Yousef Alhouseen
  2026-06-25 22:19 ` Graf (AWS), Alexander
  0 siblings, 1 reply; 3+ messages in thread
From: Yousef Alhouseen @ 2026-06-24 17:36 UTC (permalink / raw)
  To: Alexander Graf
  Cc: The AWS Nitro Enclaves Team, Arnd Bergmann, Greg Kroah-Hartman,
	linux-kernel, Yousef Alhouseen

NSM_IOCTL_RAW is documented as CAP_SYS_ADMIN-only.

/dev/nsm is mode 0666, but the ioctl handler did not check that capability.

Reject unprivileged raw messages before sending them to the device.

Signed-off-by: Yousef Alhouseen <alhouseenyousef@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 e39ff0071..8153edff3 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.54.0


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

end of thread, other threads:[~2026-06-26 22:38 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:36 [PATCH] virtio: nsm: require CAP_SYS_ADMIN for raw messages Yousef Alhouseen
2026-06-25 22:19 ` Graf (AWS), Alexander
2026-06-26 22:38   ` Yousef Alhouseen

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®