diff options
author | Jeff Garzik <jeff@garzik.org> | 2009-01-16 10:17:09 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2009-01-16 10:17:09 -0500 |
commit | 94be9a58d7e683ac3c1df1858a17f09ebade8da0 (patch) | |
tree | 2f346bb4d179caf1cf0f61012f35c8277504c55a /drivers | |
parent | 5393f780277165f282a37ed82dd878159ec9dad5 (diff) |
[libata] get-identity ioctl: Fix use of invalid memory pointer
for SAS drivers.
Caught by Ke Wei (and team?) at Marvell.
Also, move the ata_scsi_ioctl export to libata-scsi.c, as that seems to be the
general trend.
Acked-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ata/libata-core.c | 1 | ||||
-rw-r--r-- | drivers/ata/libata-scsi.c | 17 | ||||
-rw-r--r-- | drivers/scsi/ipr.c | 2 | ||||
-rw-r--r-- | drivers/scsi/libsas/sas_scsi_host.c | 2 |
4 files changed, 15 insertions, 7 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 71218d76d75e..552ecae13434 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -6638,7 +6638,6 @@ EXPORT_SYMBOL_GPL(ata_dev_pair); | |||
6638 | EXPORT_SYMBOL_GPL(ata_port_disable); | 6638 | EXPORT_SYMBOL_GPL(ata_port_disable); |
6639 | EXPORT_SYMBOL_GPL(ata_ratelimit); | 6639 | EXPORT_SYMBOL_GPL(ata_ratelimit); |
6640 | EXPORT_SYMBOL_GPL(ata_wait_register); | 6640 | EXPORT_SYMBOL_GPL(ata_wait_register); |
6641 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); | ||
6642 | EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); | 6641 | EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); |
6643 | EXPORT_SYMBOL_GPL(ata_scsi_slave_config); | 6642 | EXPORT_SYMBOL_GPL(ata_scsi_slave_config); |
6644 | EXPORT_SYMBOL_GPL(ata_scsi_slave_destroy); | 6643 | EXPORT_SYMBOL_GPL(ata_scsi_slave_destroy); |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 9e92107691f2..a1a6e6298c33 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -423,9 +423,9 @@ int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev, | |||
423 | * RETURNS: | 423 | * RETURNS: |
424 | * Zero on success, negative errno on error. | 424 | * Zero on success, negative errno on error. |
425 | */ | 425 | */ |
426 | static int ata_get_identity(struct scsi_device *sdev, void __user *arg) | 426 | static int ata_get_identity(struct ata_port *ap, struct scsi_device *sdev, |
427 | void __user *arg) | ||
427 | { | 428 | { |
428 | struct ata_port *ap = ata_shost_to_port(sdev->host); | ||
429 | struct ata_device *dev = ata_scsi_find_dev(ap, sdev); | 429 | struct ata_device *dev = ata_scsi_find_dev(ap, sdev); |
430 | u16 __user *dst = arg; | 430 | u16 __user *dst = arg; |
431 | char buf[40]; | 431 | char buf[40]; |
@@ -645,7 +645,8 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
645 | return rc; | 645 | return rc; |
646 | } | 646 | } |
647 | 647 | ||
648 | int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) | 648 | int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *scsidev, |
649 | int cmd, void __user *arg) | ||
649 | { | 650 | { |
650 | int val = -EINVAL, rc = -EINVAL; | 651 | int val = -EINVAL, rc = -EINVAL; |
651 | 652 | ||
@@ -663,7 +664,7 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) | |||
663 | return 0; | 664 | return 0; |
664 | 665 | ||
665 | case HDIO_GET_IDENTITY: | 666 | case HDIO_GET_IDENTITY: |
666 | return ata_get_identity(scsidev, arg); | 667 | return ata_get_identity(ap, scsidev, arg); |
667 | 668 | ||
668 | case HDIO_DRIVE_CMD: | 669 | case HDIO_DRIVE_CMD: |
669 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | 670 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) |
@@ -682,6 +683,14 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) | |||
682 | 683 | ||
683 | return rc; | 684 | return rc; |
684 | } | 685 | } |
686 | EXPORT_SYMBOL_GPL(ata_sas_scsi_ioctl); | ||
687 | |||
688 | int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) | ||
689 | { | ||
690 | return ata_sas_scsi_ioctl(ata_shost_to_port(scsidev->host), | ||
691 | scsidev, cmd, arg); | ||
692 | } | ||
693 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); | ||
685 | 694 | ||
686 | /** | 695 | /** |
687 | * ata_scsi_qc_new - acquire new ata_queued_cmd reference | 696 | * ata_scsi_qc_new - acquire new ata_queued_cmd reference |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 841f460edbc4..07829009a8be 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -4912,7 +4912,7 @@ static int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) | |||
4912 | if (res && ipr_is_gata(res)) { | 4912 | if (res && ipr_is_gata(res)) { |
4913 | if (cmd == HDIO_GET_IDENTITY) | 4913 | if (cmd == HDIO_GET_IDENTITY) |
4914 | return -ENOTTY; | 4914 | return -ENOTTY; |
4915 | return ata_scsi_ioctl(sdev, cmd, arg); | 4915 | return ata_sas_scsi_ioctl(res->sata_port->ap, sdev, cmd, arg); |
4916 | } | 4916 | } |
4917 | 4917 | ||
4918 | return -EINVAL; | 4918 | return -EINVAL; |
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 744838780ada..1c558d3bce18 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c | |||
@@ -717,7 +717,7 @@ int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) | |||
717 | struct domain_device *dev = sdev_to_domain_dev(sdev); | 717 | struct domain_device *dev = sdev_to_domain_dev(sdev); |
718 | 718 | ||
719 | if (dev_is_sata(dev)) | 719 | if (dev_is_sata(dev)) |
720 | return ata_scsi_ioctl(sdev, cmd, arg); | 720 | return ata_sas_scsi_ioctl(dev->sata_dev.ap, sdev, cmd, arg); |
721 | 721 | ||
722 | return -EINVAL; | 722 | return -EINVAL; |
723 | } | 723 | } |