Skip to contentSkip to conversation

Allow ATA_ passthrough command through sg.

PATCH In review Gwendal Grignou 4 participants 5 messages Jun 29, 2009 – Jun 30, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow ATA_ passthrough command through sg.

We can already send ATA specific commands using /dev/sd device files. This patch allow to use /dev/sg device files as well.

---
 block/scsi_ioctl.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
block/scsi_ioctl.c +6 -0
index 82a0ca2..93fa53e 100644
@@ -186,6 +186,12 @@ void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter)
 	__set_bit(GPCMD_LOAD_UNLOAD, filter->write_ok);
 	__set_bit(GPCMD_SET_STREAMING, filter->write_ok);
 	__set_bit(GPCMD_SET_READ_AHEAD, filter->write_ok);
+
+	/* ATA Passthrough */
+	__set_bit(ATA_12, filter->read_ok);
+	__set_bit(ATA_12, filter->write_ok);
+	__set_bit(ATA_16, filter->read_ok);
+	__set_bit(ATA_16, filter->write_ok);
 }
 EXPORT_SYMBOL_GPL(blk_set_cmd_filter_defaults);
 
Signature · 1 line
1.5.4.3
#1 lore raw
Quoted 2 lines · On Mon, 29 Jun 2009 14:24:25 -0700 Gwendal Grignou <[email protected]> wrote:

We can already send ATA specific commands using /dev/sd device files. This patch allow to use /dev/sg device files as well.

That seems a very very bad idea. The point of the filters is only to allow through commands that are safe for all users with read or write permission to use.

Backdooring it with arbitary passthrough ATA12/ATA16 commands doesn't seem very wise.

#2 lore raw
Quoted 6 lines · Alan Cox
Quoted 2 lines · On Mon, 29 Jun 2009 14:24:25 -0700 Gwendal Grignou <[email protected]> wrote:

We can already send ATA specific commands using /dev/sd device files. This patch allow to use /dev/sg device files as well.

Quoted 6 lines

That seems a very very bad idea. The point of the filters is only to allow through commands that are safe for all users with read or write permission to use.

Backdooring it with arbitary passthrough ATA12/ATA16 commands doesn't seem very wise.

Indeed. This pretty much defeats the filter for all ATA commands, including ones that can brick your drive.

Jeff

#3 lore raw

Sorry for the noise: I thought I needed that change to send ATA passthrough commands as root. The change is indeed useless and dangerous.

Gwendal.

Quoted 12 lines · Jeff Garzik
Quoted 11 lines · Alan Cox
Quoted 2 lines · On Mon, 29 Jun 2009 14:24:25 -0700 Gwendal Grignou <[email protected]> wrote:

We can already send ATA specific commands using /dev/sd device files. This patch allow to use /dev/sg device files as well.

That seems a very very bad idea. The point of the filters is only to allow through commands that are safe for all users with read or write permission to use.

Quoted 11 lines
Quoted 2 lines

Backdooring it with arbitary passthrough ATA12/ATA16 commands doesn't seem very wise.

Indeed.  This pretty much defeats the filter for all ATA commands, including ones that can brick your drive.

       Jeff

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to Gwendal Grignou

Strange, my utilities and packages like smartmontools have been sending them through for at least three years.

I presume this patch allows non-root users to send these commands. Might there be security implications if ATA WRITE commands are sent through? Non-root users would still need permissions on the sg device node (e.g. /dev/sg1).

Doug Gilbert

Quoted 25 lines · Gwendal Grignou

We can already send ATA specific commands using /dev/sd device files. This patch allow to use /dev/sg device files as well.

---
 block/scsi_ioctl.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
block/scsi_ioctl.c +6 -0
index 82a0ca2..93fa53e 100644
@@ -186,6 +186,12 @@ void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter)
 	__set_bit(GPCMD_LOAD_UNLOAD, filter->write_ok);
 	__set_bit(GPCMD_SET_STREAMING, filter->write_ok);
 	__set_bit(GPCMD_SET_READ_AHEAD, filter->write_ok);
+
+	/* ATA Passthrough */
+	__set_bit(ATA_12, filter->read_ok);
+	__set_bit(ATA_12, filter->write_ok);
+	__set_bit(ATA_16, filter->read_ok);
+	__set_bit(ATA_16, filter->write_ok);
 }
 EXPORT_SYMBOL_GPL(blk_set_cmd_filter_defaults);