Skip to contentSkip to conversation

SG_GET_VERSION_NUM and SG_IO issue

DISCUSSION Kantor Zsolt 2 participants 2 messages Jul 8, 2008 SCSI

lore
Share & tools
lore
#0 lore raw

Hi, I have a strange problem with the SG_GET_VERSION_NUM, and the SG_IO ioctl
I have blacklisted and renamed all my SCSI subsystem drivers, so the kernel can't load them. I have checked with lsmod, and yes the drivers are not loaded. All my SCSI subsystem is compiled as modules for my running kernel (CONFIG_SCSI=m, CONFIG_CHR_DEV_SG=m, CONFIG_BLK_DEV_SD=m . . .), I checked that in the running kernel config file in the /boot directory. In my initrd image the SCSI drivers are not present either.
Even so, if the SCSI susbsystem is not loaded at all I can execute successfully the SG_GET_VERSION_NUM ioctl and I can even send commands via the SG_IO ioctl. How is that possible if there are no SCSI drivers loaded ??
My kernel version is 2.6.18-6-k7 and I'm using Debian etch, if this information is helpful

Thanks,
Kantor

#1 lore raw
Quoted 4 lines · Kantor Zsolt

Hi, I have a strange problem with the SG_GET_VERSION_NUM, and the SG_IO ioctl
I have blacklisted and renamed all my SCSI subsystem drivers, so the kernel can't load them. I have checked with lsmod, and yes the drivers are not loaded. All my SCSI subsystem is compiled as modules for my running kernel (CONFIG_SCSI=m, CONFIG_CHR_DEV_SG=m, CONFIG_BLK_DEV_SD=m . . .), I checked that in the running kernel config file in the /boot directory.
In my initrd image the SCSI drivers are not present either. Even so, if the SCSI susbsystem is not loaded at all I can execute successfully the SG_GET_VERSION_NUM ioctl and I can even send commands via the SG_IO ioctl. How is that possible if there are no SCSI drivers loaded ??
My kernel version is 2.6.18-6-k7 and I'm using Debian etch, if this information is helpful

That is because the SG_IO ioctl is implemented in the block layer in block/scsi_ioctl.c (and earlier in drivers/block/scsi_ioctl.c) which is outside the SCSI subsystem. That code also "fakes" some of the sg driver's other ioctls such as SG_GET_VERSION_NUM . [It only fakes the ones needed to fool cdrecord, so try some other sg ioctls ...].

Interesting that there seems to be no way to turn off the SCSI pass-through (or restrict it to CAP_SYS_RAWIO or root user) with this design.

Doug Gilbert