SG_IO and security

Alan Cox
2004-08-12T13:19:33Z

Since the entire thread seems to have died again unresolved I'd suggest
the following patch should get into 2.6.8 so that anyone with read
access to any block device cannot issue arbitary scsi commands to it
(like writes or firmware erase)

--- drivers/block/scsi_ioctl.c~ 2004-08-12 14:14:38.078821640 +0100
+++ drivers/block/scsi_ioctl.c 2004-08-12 14:14:38.079821488 +0100
@@ -115,6 +115,8 @@
char sense[SCSI_SENSE_BUFFERSIZE];
unsigned char cmd[BLK_MAX_CDB];

+ if (!capable(CAP_SYS_RAWIO))
+ return -EPERM;
if (hdr->interface_id != 'S')
return -EINVAL;
if (hdr->cmd_len > BLK_MAX_CDB)