virtio: nsm: require CAP_SYS_ADMIN for raw messages
Subsystems (2)
PATCH 1/1 virtio: nsm: require CAP_SYS_ADMIN for raw messages
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.
--- drivers/misc/nsm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/misc/nsm.c +4 -0
@@ -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 ;
Signature · 1 line
2.54.0
Quoted 7 lines · Yousef Alhouseen
NSM_IOCTL_RAWis documented as CAP_SYS_ADMIN-only.
/dev/nsmis 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 <[email protected]>
This looks like a direct duplicate of
https://lore.kernel.org/lkml/[email protected]/?
Alex
Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
Thanks for catching that. You are right; this duplicates the earlier patch.
Please drop this one. Sorry for the noise.
Yousef
Quoted 21 lines · Alexander
Quoted 7 lines · Yousef Alhouseen
NSM_IOCTL_RAWis documented as CAP_SYS_ADMIN-only.
/dev/nsmis 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 <[email protected]>This looks like a direct duplicate of
https://lore.kernel.org/lkml/[email protected]/?Alex
Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597