diff options
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/3w-9xxx.c | 3 | ||||
-rw-r--r-- | drivers/scsi/3w-xxxx.c | 3 | ||||
-rw-r--r-- | drivers/scsi/aacraid/linit.c | 3 | ||||
-rw-r--r-- | drivers/scsi/ch.c | 4 | ||||
-rw-r--r-- | drivers/scsi/dpt_i2o.c | 5 | ||||
-rw-r--r-- | drivers/scsi/gdth.c | 3 | ||||
-rw-r--r-- | drivers/scsi/ipr.c | 6 | ||||
-rw-r--r-- | drivers/scsi/megaraid.c | 5 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_mm.c | 2 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas.c | 2 | ||||
-rw-r--r-- | drivers/scsi/osst.c | 15 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 9 | ||||
-rw-r--r-- | drivers/scsi/scsi_tgt_if.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sg.c | 60 | ||||
-rw-r--r-- | drivers/scsi/sr.c | 20 | ||||
-rw-r--r-- | drivers/scsi/st.c | 11 |
16 files changed, 95 insertions, 58 deletions
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 867f6fd5c2c0..7045511f9ad2 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c | |||
@@ -84,6 +84,7 @@ | |||
84 | #include <linux/pci.h> | 84 | #include <linux/pci.h> |
85 | #include <linux/time.h> | 85 | #include <linux/time.h> |
86 | #include <linux/mutex.h> | 86 | #include <linux/mutex.h> |
87 | #include <linux/smp_lock.h> | ||
87 | #include <asm/io.h> | 88 | #include <asm/io.h> |
88 | #include <asm/irq.h> | 89 | #include <asm/irq.h> |
89 | #include <asm/uaccess.h> | 90 | #include <asm/uaccess.h> |
@@ -862,11 +863,13 @@ out: | |||
862 | } /* End twa_chrdev_ioctl() */ | 863 | } /* End twa_chrdev_ioctl() */ |
863 | 864 | ||
864 | /* This function handles open for the character device */ | 865 | /* This function handles open for the character device */ |
866 | /* NOTE that this function will race with remove. */ | ||
865 | static int twa_chrdev_open(struct inode *inode, struct file *file) | 867 | static int twa_chrdev_open(struct inode *inode, struct file *file) |
866 | { | 868 | { |
867 | unsigned int minor_number; | 869 | unsigned int minor_number; |
868 | int retval = TW_IOCTL_ERROR_OS_ENODEV; | 870 | int retval = TW_IOCTL_ERROR_OS_ENODEV; |
869 | 871 | ||
872 | cycle_kernel_lock(); | ||
870 | minor_number = iminor(inode); | 873 | minor_number = iminor(inode); |
871 | if (minor_number >= twa_device_extension_count) | 874 | if (minor_number >= twa_device_extension_count) |
872 | goto out; | 875 | goto out; |
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index 8c22329aa85e..a0537f09aa21 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c | |||
@@ -198,6 +198,7 @@ | |||
198 | 198 | ||
199 | #include <linux/module.h> | 199 | #include <linux/module.h> |
200 | #include <linux/reboot.h> | 200 | #include <linux/reboot.h> |
201 | #include <linux/smp_lock.h> | ||
201 | #include <linux/spinlock.h> | 202 | #include <linux/spinlock.h> |
202 | #include <linux/interrupt.h> | 203 | #include <linux/interrupt.h> |
203 | #include <linux/moduleparam.h> | 204 | #include <linux/moduleparam.h> |
@@ -1027,10 +1028,12 @@ out: | |||
1027 | } /* End tw_chrdev_ioctl() */ | 1028 | } /* End tw_chrdev_ioctl() */ |
1028 | 1029 | ||
1029 | /* This function handles open for the character device */ | 1030 | /* This function handles open for the character device */ |
1031 | /* NOTE that this function races with remove. */ | ||
1030 | static int tw_chrdev_open(struct inode *inode, struct file *file) | 1032 | static int tw_chrdev_open(struct inode *inode, struct file *file) |
1031 | { | 1033 | { |
1032 | unsigned int minor_number; | 1034 | unsigned int minor_number; |
1033 | 1035 | ||
1036 | cycle_kernel_lock(); | ||
1034 | dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n"); | 1037 | dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n"); |
1035 | 1038 | ||
1036 | minor_number = iminor(inode); | 1039 | minor_number = iminor(inode); |
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 1f7c83607f84..68c140e82673 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/moduleparam.h> | 38 | #include <linux/moduleparam.h> |
39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/smp_lock.h> | ||
41 | #include <linux/spinlock.h> | 42 | #include <linux/spinlock.h> |
42 | #include <linux/syscalls.h> | 43 | #include <linux/syscalls.h> |
43 | #include <linux/delay.h> | 44 | #include <linux/delay.h> |
@@ -667,6 +668,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file) | |||
667 | unsigned minor_number = iminor(inode); | 668 | unsigned minor_number = iminor(inode); |
668 | int err = -ENODEV; | 669 | int err = -ENODEV; |
669 | 670 | ||
671 | lock_kernel(); /* BKL pushdown: nothing else protects this list */ | ||
670 | list_for_each_entry(aac, &aac_devices, entry) { | 672 | list_for_each_entry(aac, &aac_devices, entry) { |
671 | if (aac->id == minor_number) { | 673 | if (aac->id == minor_number) { |
672 | file->private_data = aac; | 674 | file->private_data = aac; |
@@ -674,6 +676,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file) | |||
674 | break; | 676 | break; |
675 | } | 677 | } |
676 | } | 678 | } |
679 | unlock_kernel(); | ||
677 | 680 | ||
678 | return err; | 681 | return err; |
679 | } | 682 | } |
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index c4b938bc30d3..aa2011b64683 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/chio.h> /* here are all the ioctls */ | 22 | #include <linux/chio.h> /* here are all the ioctls */ |
23 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/idr.h> | 24 | #include <linux/idr.h> |
25 | #include <linux/smp_lock.h> | ||
25 | 26 | ||
26 | #include <scsi/scsi.h> | 27 | #include <scsi/scsi.h> |
27 | #include <scsi/scsi_cmnd.h> | 28 | #include <scsi/scsi_cmnd.h> |
@@ -571,16 +572,19 @@ ch_open(struct inode *inode, struct file *file) | |||
571 | scsi_changer *ch; | 572 | scsi_changer *ch; |
572 | int minor = iminor(inode); | 573 | int minor = iminor(inode); |
573 | 574 | ||
575 | lock_kernel(); | ||
574 | spin_lock(&ch_index_lock); | 576 | spin_lock(&ch_index_lock); |
575 | ch = idr_find(&ch_index_idr, minor); | 577 | ch = idr_find(&ch_index_idr, minor); |
576 | 578 | ||
577 | if (NULL == ch || scsi_device_get(ch->device)) { | 579 | if (NULL == ch || scsi_device_get(ch->device)) { |
578 | spin_unlock(&ch_index_lock); | 580 | spin_unlock(&ch_index_lock); |
581 | unlock_kernel(); | ||
579 | return -ENXIO; | 582 | return -ENXIO; |
580 | } | 583 | } |
581 | spin_unlock(&ch_index_lock); | 584 | spin_unlock(&ch_index_lock); |
582 | 585 | ||
583 | file->private_data = ch; | 586 | file->private_data = ch; |
587 | unlock_kernel(); | ||
584 | return 0; | 588 | return 0; |
585 | } | 589 | } |
586 | 590 | ||
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 8508816f303d..2bc30e32b67a 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c | |||
@@ -49,6 +49,7 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver"); | |||
49 | #include <linux/kernel.h> /* for printk */ | 49 | #include <linux/kernel.h> /* for printk */ |
50 | #include <linux/sched.h> | 50 | #include <linux/sched.h> |
51 | #include <linux/reboot.h> | 51 | #include <linux/reboot.h> |
52 | #include <linux/smp_lock.h> | ||
52 | #include <linux/spinlock.h> | 53 | #include <linux/spinlock.h> |
53 | #include <linux/dma-mapping.h> | 54 | #include <linux/dma-mapping.h> |
54 | 55 | ||
@@ -1727,10 +1728,12 @@ static int adpt_open(struct inode *inode, struct file *file) | |||
1727 | int minor; | 1728 | int minor; |
1728 | adpt_hba* pHba; | 1729 | adpt_hba* pHba; |
1729 | 1730 | ||
1731 | lock_kernel(); | ||
1730 | //TODO check for root access | 1732 | //TODO check for root access |
1731 | // | 1733 | // |
1732 | minor = iminor(inode); | 1734 | minor = iminor(inode); |
1733 | if (minor >= hba_count) { | 1735 | if (minor >= hba_count) { |
1736 | unlock_kernel(); | ||
1734 | return -ENXIO; | 1737 | return -ENXIO; |
1735 | } | 1738 | } |
1736 | mutex_lock(&adpt_configuration_lock); | 1739 | mutex_lock(&adpt_configuration_lock); |
@@ -1741,6 +1744,7 @@ static int adpt_open(struct inode *inode, struct file *file) | |||
1741 | } | 1744 | } |
1742 | if (pHba == NULL) { | 1745 | if (pHba == NULL) { |
1743 | mutex_unlock(&adpt_configuration_lock); | 1746 | mutex_unlock(&adpt_configuration_lock); |
1747 | unlock_kernel(); | ||
1744 | return -ENXIO; | 1748 | return -ENXIO; |
1745 | } | 1749 | } |
1746 | 1750 | ||
@@ -1751,6 +1755,7 @@ static int adpt_open(struct inode *inode, struct file *file) | |||
1751 | 1755 | ||
1752 | pHba->in_use = 1; | 1756 | pHba->in_use = 1; |
1753 | mutex_unlock(&adpt_configuration_lock); | 1757 | mutex_unlock(&adpt_configuration_lock); |
1758 | unlock_kernel(); | ||
1754 | 1759 | ||
1755 | return 0; | 1760 | return 0; |
1756 | } | 1761 | } |
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index 46771d4c81bd..822d5214692b 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c | |||
@@ -120,6 +120,7 @@ | |||
120 | #include <linux/timer.h> | 120 | #include <linux/timer.h> |
121 | #include <linux/dma-mapping.h> | 121 | #include <linux/dma-mapping.h> |
122 | #include <linux/list.h> | 122 | #include <linux/list.h> |
123 | #include <linux/smp_lock.h> | ||
123 | 124 | ||
124 | #ifdef GDTH_RTC | 125 | #ifdef GDTH_RTC |
125 | #include <linux/mc146818rtc.h> | 126 | #include <linux/mc146818rtc.h> |
@@ -4019,10 +4020,12 @@ static int gdth_open(struct inode *inode, struct file *filep) | |||
4019 | { | 4020 | { |
4020 | gdth_ha_str *ha; | 4021 | gdth_ha_str *ha; |
4021 | 4022 | ||
4023 | lock_kernel(); | ||
4022 | list_for_each_entry(ha, &gdth_instances, list) { | 4024 | list_for_each_entry(ha, &gdth_instances, list) { |
4023 | if (!ha->sdev) | 4025 | if (!ha->sdev) |
4024 | ha->sdev = scsi_get_host_dev(ha->shost); | 4026 | ha->sdev = scsi_get_host_dev(ha->shost); |
4025 | } | 4027 | } |
4028 | unlock_kernel(); | ||
4026 | 4029 | ||
4027 | TRACE(("gdth_open()\n")); | 4030 | TRACE(("gdth_open()\n")); |
4028 | return 0; | 4031 | return 0; |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 999e91ea7451..e7a3a6554425 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -71,6 +71,7 @@ | |||
71 | #include <linux/module.h> | 71 | #include <linux/module.h> |
72 | #include <linux/moduleparam.h> | 72 | #include <linux/moduleparam.h> |
73 | #include <linux/libata.h> | 73 | #include <linux/libata.h> |
74 | #include <linux/hdreg.h> | ||
74 | #include <asm/io.h> | 75 | #include <asm/io.h> |
75 | #include <asm/irq.h> | 76 | #include <asm/irq.h> |
76 | #include <asm/processor.h> | 77 | #include <asm/processor.h> |
@@ -4913,8 +4914,11 @@ static int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) | |||
4913 | struct ipr_resource_entry *res; | 4914 | struct ipr_resource_entry *res; |
4914 | 4915 | ||
4915 | res = (struct ipr_resource_entry *)sdev->hostdata; | 4916 | res = (struct ipr_resource_entry *)sdev->hostdata; |
4916 | if (res && ipr_is_gata(res)) | 4917 | if (res && ipr_is_gata(res)) { |
4918 | if (cmd == HDIO_GET_IDENTITY) | ||
4919 | return -ENOTTY; | ||
4917 | return ata_scsi_ioctl(sdev, cmd, arg); | 4920 | return ata_scsi_ioctl(sdev, cmd, arg); |
4921 | } | ||
4918 | 4922 | ||
4919 | return -EINVAL; | 4923 | return -EINVAL; |
4920 | } | 4924 | } |
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 18551aaf5e09..28c9da7d4a5c 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/pci.h> | 46 | #include <linux/pci.h> |
47 | #include <linux/init.h> | 47 | #include <linux/init.h> |
48 | #include <linux/dma-mapping.h> | 48 | #include <linux/dma-mapping.h> |
49 | #include <linux/smp_lock.h> | ||
49 | #include <scsi/scsicam.h> | 50 | #include <scsi/scsicam.h> |
50 | 51 | ||
51 | #include "scsi.h" | 52 | #include "scsi.h" |
@@ -3272,12 +3273,12 @@ mega_init_scb(adapter_t *adapter) | |||
3272 | * @filep - unused | 3273 | * @filep - unused |
3273 | * | 3274 | * |
3274 | * Routines for the character/ioctl interface to the driver. Find out if this | 3275 | * Routines for the character/ioctl interface to the driver. Find out if this |
3275 | * is a valid open. If yes, increment the module use count so that it cannot | 3276 | * is a valid open. |
3276 | * be unloaded. | ||
3277 | */ | 3277 | */ |
3278 | static int | 3278 | static int |
3279 | megadev_open (struct inode *inode, struct file *filep) | 3279 | megadev_open (struct inode *inode, struct file *filep) |
3280 | { | 3280 | { |
3281 | cycle_kernel_lock(); | ||
3281 | /* | 3282 | /* |
3282 | * Only allow superuser to access private ioctl interface | 3283 | * Only allow superuser to access private ioctl interface |
3283 | */ | 3284 | */ |
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c index 0ad215e27b83..ac3b280c2a72 100644 --- a/drivers/scsi/megaraid/megaraid_mm.c +++ b/drivers/scsi/megaraid/megaraid_mm.c | |||
@@ -15,6 +15,7 @@ | |||
15 | * Common management module | 15 | * Common management module |
16 | */ | 16 | */ |
17 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
18 | #include <linux/smp_lock.h> | ||
18 | #include "megaraid_mm.h" | 19 | #include "megaraid_mm.h" |
19 | 20 | ||
20 | 21 | ||
@@ -96,6 +97,7 @@ mraid_mm_open(struct inode *inode, struct file *filep) | |||
96 | */ | 97 | */ |
97 | if (!capable(CAP_SYS_ADMIN)) return (-EACCES); | 98 | if (!capable(CAP_SYS_ADMIN)) return (-EACCES); |
98 | 99 | ||
100 | cycle_kernel_lock(); | ||
99 | return 0; | 101 | return 0; |
100 | } | 102 | } |
101 | 103 | ||
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c index 7d84c8bbcf3f..fc7ac158476c 100644 --- a/drivers/scsi/megaraid/megaraid_sas.c +++ b/drivers/scsi/megaraid/megaraid_sas.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/spinlock.h> | 33 | #include <linux/spinlock.h> |
34 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/smp_lock.h> | ||
36 | #include <linux/uio.h> | 37 | #include <linux/uio.h> |
37 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
38 | #include <linux/fs.h> | 39 | #include <linux/fs.h> |
@@ -2863,6 +2864,7 @@ static void megasas_shutdown(struct pci_dev *pdev) | |||
2863 | */ | 2864 | */ |
2864 | static int megasas_mgmt_open(struct inode *inode, struct file *filep) | 2865 | static int megasas_mgmt_open(struct inode *inode, struct file *filep) |
2865 | { | 2866 | { |
2867 | cycle_kernel_lock(); | ||
2866 | /* | 2868 | /* |
2867 | * Allow only those users with admin rights | 2869 | * Allow only those users with admin rights |
2868 | */ | 2870 | */ |
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 243d8becd30f..1c79f9794f4e 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
@@ -50,6 +50,7 @@ static const char * osst_version = "0.99.4"; | |||
50 | #include <linux/moduleparam.h> | 50 | #include <linux/moduleparam.h> |
51 | #include <linux/delay.h> | 51 | #include <linux/delay.h> |
52 | #include <linux/jiffies.h> | 52 | #include <linux/jiffies.h> |
53 | #include <linux/smp_lock.h> | ||
53 | #include <asm/uaccess.h> | 54 | #include <asm/uaccess.h> |
54 | #include <asm/dma.h> | 55 | #include <asm/dma.h> |
55 | #include <asm/system.h> | 56 | #include <asm/system.h> |
@@ -4359,7 +4360,7 @@ os_bypass: | |||
4359 | 4360 | ||
4360 | 4361 | ||
4361 | /* Open the device */ | 4362 | /* Open the device */ |
4362 | static int os_scsi_tape_open(struct inode * inode, struct file * filp) | 4363 | static int __os_scsi_tape_open(struct inode * inode, struct file * filp) |
4363 | { | 4364 | { |
4364 | unsigned short flags; | 4365 | unsigned short flags; |
4365 | int i, b_size, new_session = 0, retval = 0; | 4366 | int i, b_size, new_session = 0, retval = 0; |
@@ -4725,6 +4726,18 @@ err_out: | |||
4725 | return retval; | 4726 | return retval; |
4726 | } | 4727 | } |
4727 | 4728 | ||
4729 | /* BKL pushdown: spaghetti avoidance wrapper */ | ||
4730 | static int os_scsi_tape_open(struct inode * inode, struct file * filp) | ||
4731 | { | ||
4732 | int ret; | ||
4733 | |||
4734 | lock_kernel(); | ||
4735 | ret = __os_scsi_tape_open(inode, filp); | ||
4736 | unlock_kernel(); | ||
4737 | return ret; | ||
4738 | } | ||
4739 | |||
4740 | |||
4728 | 4741 | ||
4729 | /* Flush the tape buffer before close */ | 4742 | /* Flush the tape buffer before close */ |
4730 | static int os_scsi_tape_flush(struct file * filp, fl_owner_t id) | 4743 | static int os_scsi_tape_flush(struct file * filp, fl_owner_t id) |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index a82d2fe80fb5..cbf55d59a54c 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -207,6 +207,15 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, | |||
207 | */ | 207 | */ |
208 | blk_execute_rq(req->q, NULL, req, 1); | 208 | blk_execute_rq(req->q, NULL, req, 1); |
209 | 209 | ||
210 | /* | ||
211 | * Some devices (USB mass-storage in particular) may transfer | ||
212 | * garbage data together with a residue indicating that the data | ||
213 | * is invalid. Prevent the garbage from being misinterpreted | ||
214 | * and prevent security leaks by zeroing out the excess data. | ||
215 | */ | ||
216 | if (unlikely(req->data_len > 0 && req->data_len <= bufflen)) | ||
217 | memset(buffer + (bufflen - req->data_len), 0, req->data_len); | ||
218 | |||
210 | ret = req->errors; | 219 | ret = req->errors; |
211 | out: | 220 | out: |
212 | blk_put_request(req); | 221 | blk_put_request(req); |
diff --git a/drivers/scsi/scsi_tgt_if.c b/drivers/scsi/scsi_tgt_if.c index d2557dbc2dc1..0e9533f7aabc 100644 --- a/drivers/scsi/scsi_tgt_if.c +++ b/drivers/scsi/scsi_tgt_if.c | |||
@@ -21,6 +21,7 @@ | |||
21 | */ | 21 | */ |
22 | #include <linux/miscdevice.h> | 22 | #include <linux/miscdevice.h> |
23 | #include <linux/file.h> | 23 | #include <linux/file.h> |
24 | #include <linux/smp_lock.h> | ||
24 | #include <net/tcp.h> | 25 | #include <net/tcp.h> |
25 | #include <scsi/scsi.h> | 26 | #include <scsi/scsi.h> |
26 | #include <scsi/scsi_cmnd.h> | 27 | #include <scsi/scsi_cmnd.h> |
@@ -321,6 +322,7 @@ static int tgt_open(struct inode *inode, struct file *file) | |||
321 | { | 322 | { |
322 | tx_ring.tr_idx = rx_ring.tr_idx = 0; | 323 | tx_ring.tr_idx = rx_ring.tr_idx = 0; |
323 | 324 | ||
325 | cycle_kernel_lock(); | ||
324 | return 0; | 326 | return 0; |
325 | } | 327 | } |
326 | 328 | ||
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index ea0edd1b2e76..fccd2e88d600 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -49,6 +49,7 @@ static int sg_version_num = 30534; /* 2 digits for each component */ | |||
49 | #include <linux/delay.h> | 49 | #include <linux/delay.h> |
50 | #include <linux/scatterlist.h> | 50 | #include <linux/scatterlist.h> |
51 | #include <linux/blktrace_api.h> | 51 | #include <linux/blktrace_api.h> |
52 | #include <linux/smp_lock.h> | ||
52 | 53 | ||
53 | #include "scsi.h" | 54 | #include "scsi.h" |
54 | #include <scsi/scsi_dbg.h> | 55 | #include <scsi/scsi_dbg.h> |
@@ -182,8 +183,9 @@ static int sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, | |||
182 | int tablesize); | 183 | int tablesize); |
183 | static ssize_t sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, | 184 | static ssize_t sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, |
184 | Sg_request * srp); | 185 | Sg_request * srp); |
185 | static ssize_t sg_new_write(Sg_fd * sfp, const char __user *buf, size_t count, | 186 | static ssize_t sg_new_write(Sg_fd *sfp, struct file *file, |
186 | int blocking, int read_only, Sg_request ** o_srp); | 187 | const char __user *buf, size_t count, int blocking, |
188 | int read_only, Sg_request **o_srp); | ||
187 | static int sg_common_write(Sg_fd * sfp, Sg_request * srp, | 189 | static int sg_common_write(Sg_fd * sfp, Sg_request * srp, |
188 | unsigned char *cmnd, int timeout, int blocking); | 190 | unsigned char *cmnd, int timeout, int blocking); |
189 | static int sg_u_iovec(sg_io_hdr_t * hp, int sg_num, int ind, | 191 | static int sg_u_iovec(sg_io_hdr_t * hp, int sg_num, int ind, |
@@ -204,7 +206,6 @@ static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id); | |||
204 | static Sg_request *sg_add_request(Sg_fd * sfp); | 206 | static Sg_request *sg_add_request(Sg_fd * sfp); |
205 | static int sg_remove_request(Sg_fd * sfp, Sg_request * srp); | 207 | static int sg_remove_request(Sg_fd * sfp, Sg_request * srp); |
206 | static int sg_res_in_use(Sg_fd * sfp); | 208 | static int sg_res_in_use(Sg_fd * sfp); |
207 | static int sg_allow_access(unsigned char opcode, char dev_type); | ||
208 | static int sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len); | 209 | static int sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len); |
209 | static Sg_device *sg_get_dev(int dev); | 210 | static Sg_device *sg_get_dev(int dev); |
210 | #ifdef CONFIG_SCSI_PROC_FS | 211 | #ifdef CONFIG_SCSI_PROC_FS |
@@ -227,19 +228,26 @@ sg_open(struct inode *inode, struct file *filp) | |||
227 | int res; | 228 | int res; |
228 | int retval; | 229 | int retval; |
229 | 230 | ||
231 | lock_kernel(); | ||
230 | nonseekable_open(inode, filp); | 232 | nonseekable_open(inode, filp); |
231 | SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags)); | 233 | SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags)); |
232 | sdp = sg_get_dev(dev); | 234 | sdp = sg_get_dev(dev); |
233 | if ((!sdp) || (!sdp->device)) | 235 | if ((!sdp) || (!sdp->device)) { |
236 | unlock_kernel(); | ||
234 | return -ENXIO; | 237 | return -ENXIO; |
235 | if (sdp->detached) | 238 | } |
239 | if (sdp->detached) { | ||
240 | unlock_kernel(); | ||
236 | return -ENODEV; | 241 | return -ENODEV; |
242 | } | ||
237 | 243 | ||
238 | /* This driver's module count bumped by fops_get in <linux/fs.h> */ | 244 | /* This driver's module count bumped by fops_get in <linux/fs.h> */ |
239 | /* Prevent the device driver from vanishing while we sleep */ | 245 | /* Prevent the device driver from vanishing while we sleep */ |
240 | retval = scsi_device_get(sdp->device); | 246 | retval = scsi_device_get(sdp->device); |
241 | if (retval) | 247 | if (retval) { |
248 | unlock_kernel(); | ||
242 | return retval; | 249 | return retval; |
250 | } | ||
243 | 251 | ||
244 | if (!((flags & O_NONBLOCK) || | 252 | if (!((flags & O_NONBLOCK) || |
245 | scsi_block_when_processing_errors(sdp->device))) { | 253 | scsi_block_when_processing_errors(sdp->device))) { |
@@ -295,10 +303,12 @@ sg_open(struct inode *inode, struct file *filp) | |||
295 | retval = -ENOMEM; | 303 | retval = -ENOMEM; |
296 | goto error_out; | 304 | goto error_out; |
297 | } | 305 | } |
306 | unlock_kernel(); | ||
298 | return 0; | 307 | return 0; |
299 | 308 | ||
300 | error_out: | 309 | error_out: |
301 | scsi_device_put(sdp->device); | 310 | scsi_device_put(sdp->device); |
311 | unlock_kernel(); | ||
302 | return retval; | 312 | return retval; |
303 | } | 313 | } |
304 | 314 | ||
@@ -544,7 +554,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) | |||
544 | return -EFAULT; | 554 | return -EFAULT; |
545 | blocking = !(filp->f_flags & O_NONBLOCK); | 555 | blocking = !(filp->f_flags & O_NONBLOCK); |
546 | if (old_hdr.reply_len < 0) | 556 | if (old_hdr.reply_len < 0) |
547 | return sg_new_write(sfp, buf, count, blocking, 0, NULL); | 557 | return sg_new_write(sfp, filp, buf, count, blocking, 0, NULL); |
548 | if (count < (SZ_SG_HEADER + 6)) | 558 | if (count < (SZ_SG_HEADER + 6)) |
549 | return -EIO; /* The minimum scsi command length is 6 bytes. */ | 559 | return -EIO; /* The minimum scsi command length is 6 bytes. */ |
550 | 560 | ||
@@ -621,8 +631,9 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) | |||
621 | } | 631 | } |
622 | 632 | ||
623 | static ssize_t | 633 | static ssize_t |
624 | sg_new_write(Sg_fd * sfp, const char __user *buf, size_t count, | 634 | sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf, |
625 | int blocking, int read_only, Sg_request ** o_srp) | 635 | size_t count, int blocking, int read_only, |
636 | Sg_request **o_srp) | ||
626 | { | 637 | { |
627 | int k; | 638 | int k; |
628 | Sg_request *srp; | 639 | Sg_request *srp; |
@@ -678,8 +689,7 @@ sg_new_write(Sg_fd * sfp, const char __user *buf, size_t count, | |||
678 | sg_remove_request(sfp, srp); | 689 | sg_remove_request(sfp, srp); |
679 | return -EFAULT; | 690 | return -EFAULT; |
680 | } | 691 | } |
681 | if (read_only && | 692 | if (read_only && !blk_verify_command(file, cmnd)) { |
682 | (!sg_allow_access(cmnd[0], sfp->parentdp->device->type))) { | ||
683 | sg_remove_request(sfp, srp); | 693 | sg_remove_request(sfp, srp); |
684 | return -EPERM; | 694 | return -EPERM; |
685 | } | 695 | } |
@@ -799,7 +809,7 @@ sg_ioctl(struct inode *inode, struct file *filp, | |||
799 | if (!access_ok(VERIFY_WRITE, p, SZ_SG_IO_HDR)) | 809 | if (!access_ok(VERIFY_WRITE, p, SZ_SG_IO_HDR)) |
800 | return -EFAULT; | 810 | return -EFAULT; |
801 | result = | 811 | result = |
802 | sg_new_write(sfp, p, SZ_SG_IO_HDR, | 812 | sg_new_write(sfp, filp, p, SZ_SG_IO_HDR, |
803 | blocking, read_only, &srp); | 813 | blocking, read_only, &srp); |
804 | if (result < 0) | 814 | if (result < 0) |
805 | return result; | 815 | return result; |
@@ -1048,7 +1058,7 @@ sg_ioctl(struct inode *inode, struct file *filp, | |||
1048 | 1058 | ||
1049 | if (copy_from_user(&opcode, siocp->data, 1)) | 1059 | if (copy_from_user(&opcode, siocp->data, 1)) |
1050 | return -EFAULT; | 1060 | return -EFAULT; |
1051 | if (!sg_allow_access(opcode, sdp->device->type)) | 1061 | if (!blk_verify_command(filp, &opcode)) |
1052 | return -EPERM; | 1062 | return -EPERM; |
1053 | } | 1063 | } |
1054 | return sg_scsi_ioctl(filp, sdp->device->request_queue, NULL, p); | 1064 | return sg_scsi_ioctl(filp, sdp->device->request_queue, NULL, p); |
@@ -2502,30 +2512,6 @@ sg_page_free(struct page *page, int size) | |||
2502 | __free_pages(page, order); | 2512 | __free_pages(page, order); |
2503 | } | 2513 | } |
2504 | 2514 | ||
2505 | #ifndef MAINTENANCE_IN_CMD | ||
2506 | #define MAINTENANCE_IN_CMD 0xa3 | ||
2507 | #endif | ||
2508 | |||
2509 | static unsigned char allow_ops[] = { TEST_UNIT_READY, REQUEST_SENSE, | ||
2510 | INQUIRY, READ_CAPACITY, READ_BUFFER, READ_6, READ_10, READ_12, | ||
2511 | READ_16, MODE_SENSE, MODE_SENSE_10, LOG_SENSE, REPORT_LUNS, | ||
2512 | SERVICE_ACTION_IN, RECEIVE_DIAGNOSTIC, READ_LONG, MAINTENANCE_IN_CMD | ||
2513 | }; | ||
2514 | |||
2515 | static int | ||
2516 | sg_allow_access(unsigned char opcode, char dev_type) | ||
2517 | { | ||
2518 | int k; | ||
2519 | |||
2520 | if (TYPE_SCANNER == dev_type) /* TYPE_ROM maybe burner */ | ||
2521 | return 1; | ||
2522 | for (k = 0; k < sizeof (allow_ops); ++k) { | ||
2523 | if (opcode == allow_ops[k]) | ||
2524 | return 1; | ||
2525 | } | ||
2526 | return 0; | ||
2527 | } | ||
2528 | |||
2529 | #ifdef CONFIG_SCSI_PROC_FS | 2515 | #ifdef CONFIG_SCSI_PROC_FS |
2530 | static int | 2516 | static int |
2531 | sg_idr_max_id(int id, void *p, void *data) | 2517 | sg_idr_max_id(int id, void *p, void *data) |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index c82df8bd4d89..27f5bfd1def3 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -673,24 +673,20 @@ fail: | |||
673 | static void get_sectorsize(struct scsi_cd *cd) | 673 | static void get_sectorsize(struct scsi_cd *cd) |
674 | { | 674 | { |
675 | unsigned char cmd[10]; | 675 | unsigned char cmd[10]; |
676 | unsigned char *buffer; | 676 | unsigned char buffer[8]; |
677 | int the_result, retries = 3; | 677 | int the_result, retries = 3; |
678 | int sector_size; | 678 | int sector_size; |
679 | struct request_queue *queue; | 679 | struct request_queue *queue; |
680 | 680 | ||
681 | buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); | ||
682 | if (!buffer) | ||
683 | goto Enomem; | ||
684 | |||
685 | do { | 681 | do { |
686 | cmd[0] = READ_CAPACITY; | 682 | cmd[0] = READ_CAPACITY; |
687 | memset((void *) &cmd[1], 0, 9); | 683 | memset((void *) &cmd[1], 0, 9); |
688 | memset(buffer, 0, 8); | 684 | memset(buffer, 0, sizeof(buffer)); |
689 | 685 | ||
690 | /* Do the command and wait.. */ | 686 | /* Do the command and wait.. */ |
691 | the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE, | 687 | the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE, |
692 | buffer, 8, NULL, SR_TIMEOUT, | 688 | buffer, sizeof(buffer), NULL, |
693 | MAX_RETRIES); | 689 | SR_TIMEOUT, MAX_RETRIES); |
694 | 690 | ||
695 | retries--; | 691 | retries--; |
696 | 692 | ||
@@ -745,14 +741,8 @@ static void get_sectorsize(struct scsi_cd *cd) | |||
745 | 741 | ||
746 | queue = cd->device->request_queue; | 742 | queue = cd->device->request_queue; |
747 | blk_queue_hardsect_size(queue, sector_size); | 743 | blk_queue_hardsect_size(queue, sector_size); |
748 | out: | ||
749 | kfree(buffer); | ||
750 | return; | ||
751 | 744 | ||
752 | Enomem: | 745 | return; |
753 | cd->capacity = 0x1fffff; | ||
754 | cd->device->sector_size = 2048; /* A guess, just in case */ | ||
755 | goto out; | ||
756 | } | 746 | } |
757 | 747 | ||
758 | static void get_capabilities(struct scsi_cd *cd) | 748 | static void get_capabilities(struct scsi_cd *cd) |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 6e5a5bb31311..4684cc716aa4 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -38,6 +38,7 @@ static const char *verstr = "20080224"; | |||
38 | #include <linux/cdev.h> | 38 | #include <linux/cdev.h> |
39 | #include <linux/delay.h> | 39 | #include <linux/delay.h> |
40 | #include <linux/mutex.h> | 40 | #include <linux/mutex.h> |
41 | #include <linux/smp_lock.h> | ||
41 | 42 | ||
42 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
43 | #include <asm/dma.h> | 44 | #include <asm/dma.h> |
@@ -1113,7 +1114,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp) | |||
1113 | } | 1114 | } |
1114 | 1115 | ||
1115 | 1116 | ||
1116 | /* Open the device. Needs to be called with BKL only because of incrementing the SCSI host | 1117 | /* Open the device. Needs to take the BKL only because of incrementing the SCSI host |
1117 | module count. */ | 1118 | module count. */ |
1118 | static int st_open(struct inode *inode, struct file *filp) | 1119 | static int st_open(struct inode *inode, struct file *filp) |
1119 | { | 1120 | { |
@@ -1123,6 +1124,7 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1123 | int dev = TAPE_NR(inode); | 1124 | int dev = TAPE_NR(inode); |
1124 | char *name; | 1125 | char *name; |
1125 | 1126 | ||
1127 | lock_kernel(); | ||
1126 | /* | 1128 | /* |
1127 | * We really want to do nonseekable_open(inode, filp); here, but some | 1129 | * We really want to do nonseekable_open(inode, filp); here, but some |
1128 | * versions of tar incorrectly call lseek on tapes and bail out if that | 1130 | * versions of tar incorrectly call lseek on tapes and bail out if that |
@@ -1130,8 +1132,10 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1130 | */ | 1132 | */ |
1131 | filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); | 1133 | filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); |
1132 | 1134 | ||
1133 | if (!(STp = scsi_tape_get(dev))) | 1135 | if (!(STp = scsi_tape_get(dev))) { |
1136 | unlock_kernel(); | ||
1134 | return -ENXIO; | 1137 | return -ENXIO; |
1138 | } | ||
1135 | 1139 | ||
1136 | write_lock(&st_dev_arr_lock); | 1140 | write_lock(&st_dev_arr_lock); |
1137 | filp->private_data = STp; | 1141 | filp->private_data = STp; |
@@ -1140,6 +1144,7 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1140 | if (STp->in_use) { | 1144 | if (STp->in_use) { |
1141 | write_unlock(&st_dev_arr_lock); | 1145 | write_unlock(&st_dev_arr_lock); |
1142 | scsi_tape_put(STp); | 1146 | scsi_tape_put(STp); |
1147 | unlock_kernel(); | ||
1143 | DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) | 1148 | DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) |
1144 | return (-EBUSY); | 1149 | return (-EBUSY); |
1145 | } | 1150 | } |
@@ -1188,12 +1193,14 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1188 | retval = (-EIO); | 1193 | retval = (-EIO); |
1189 | goto err_out; | 1194 | goto err_out; |
1190 | } | 1195 | } |
1196 | unlock_kernel(); | ||
1191 | return 0; | 1197 | return 0; |
1192 | 1198 | ||
1193 | err_out: | 1199 | err_out: |
1194 | normalize_buffer(STp->buffer); | 1200 | normalize_buffer(STp->buffer); |
1195 | STp->in_use = 0; | 1201 | STp->in_use = 0; |
1196 | scsi_tape_put(STp); | 1202 | scsi_tape_put(STp); |
1203 | unlock_kernel(); | ||
1197 | return retval; | 1204 | return retval; |
1198 | 1205 | ||
1199 | } | 1206 | } |