scsi: wrap remaining problem users of ->ioctl
Subsystems (3)
PATCH 1/1 scsi: wrap remaining problem users of ->ioctl
These appear to need the lock so we wrap the method
Signed-off-by Alan Cox <[email protected]>
drivers/scsi/dpt_i2o.c +18 -16
@@ -118,7 +118,7 @@ static long compat_adpt_ioctl(struct file *, unsigned int, unsigned long);#endif static const struct file_operations adpt_fops = { - .ioctl = adpt_ioctl, + .unlocked_ioctl = adpt_ioctl, .open = adpt_open, .release = adpt_close, #ifdef CONFIG_COMPAT
@@ -2057,19 +2057,19 @@ static int adpt_system_info(void __user *buffer)return 0 ; } -static int adpt_ioctl (struct inode *inode,struct file *file,uint cmd, -ulong arg) +static long adpt_ioctl (struct file *file,uint cmd,ulong arg) { -int minor; -int error =0 ; +unsigned int minor =iminor (file->f_path.dentry->d_inode); +long ret =0 ;adpt_hba * pHba;ulong flags =0 ;void __user *argp = (void __user *)arg; - minor =iminor (inode);if (minor >=DPTI_MAX_HBA ){return -ENXIO ; } + +lock_kernel ();mutex_lock (&adpt_configuration_lock);for (pHba = hba_chain; pHba; pHba = pHba->next) {if (pHba->unit == minor) {
@@ -2078,6 +2078,7 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, }mutex_unlock (&adpt_configuration_lock);if (pHba ==NULL ){ +unlock_kernel ();return -ENXIO ; }
@@ -2087,12 +2088,12 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,switch (cmd) {// TODO: handle 3 cases case DPT_SIGNATURE : -if (copy_to_user (argp, &DPTI_sig,sizeof (DPTI_sig))) { -return -EFAULT ; - } +if (copy_to_user (argp, &DPTI_sig,sizeof (DPTI_sig))) + ret = -EFAULT ;break ;case I2OUSRCMD : -return adpt_i2o_passthru (pHba, argp); + ret =adpt_i2o_passthru (pHba, argp); +break ;case DPT_CTRLINFO :{drvrHBAinfo_S HbaInfo;
@@ -2110,17 +2111,18 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, HbaInfo.hbaFlags =FLG_OSD_PCI_VALID |FLG_OSD_DMA |FLG_OSD_I2O ;if (copy_to_user (argp, &HbaInfo,sizeof (HbaInfo))){printk (KERN_WARNING "%s: Could not copy HbaInfo TO user\n" ,pHba->name); -return -EFAULT ; + ret = -EFAULT ; }break ; }case DPT_SYSINFO : -return adpt_system_info (argp); + ret =adpt_system_info (argp); +break ;case DPT_BLINKLED :{u32 value; value = (u32 )adpt_read_blink_led (pHba);if (copy_to_user (argp, &value,sizeof (value))) { -return -EFAULT ; + ret = -EFAULT ; }break ; }
@@ -2135,10 +2137,10 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,adpt_rescan (pHba);break ;default : -return -EINVAL ; + ret = -ENOTTY ; } - -return error; +unlock_kernel (); +return ret; }#ifdef CONFIG_COMPAT
drivers/scsi/dpti.h +1 -1
@@ -307,7 +307,7 @@ static int adpt_i2o_online_hba(adpt_hba* pHba);static void adpt_i2o_post_wait_complete (u32 ,int );static int adpt_i2o_systab_send (adpt_hba * pHba); -static int adpt_ioctl (struct inode *inode,struct file *file,uint cmd,ulong arg); +static long adpt_ioctl (struct file *file,uint cmd,ulong arg);static int adpt_open (struct inode *inode,struct file *file);static int adpt_close (struct inode *inode,struct file *file);
drivers/scsi/gdth.c +43 -26
169 lines not on this page · raw message
drivers/scsi/megaraid.c +15 -7
@@ -94,7 +94,7 @@ static struct mega_hbas mega_hbas[MAX_CONTROLLERS];*/ static const struct file_operations megadev_fops = { .owner =THIS_MODULE , - .ioctl = megadev_ioctl, + .unlocked_ioctl = megadev_ioctl, .open = megadev_open, };
@@ -3288,8 +3288,7 @@ megadev_open (struct inode *inode, struct file *filep)/** -* megadev_ioctl() -* @inode - Our device inode +* megadev_do_ioctl() * @filep - unused * @cmd - ioctl command * @arg - user buffer
@@ -3299,14 +3298,13 @@ megadev_open (struct inode *inode, struct file *filep)* ioctl to new ioctl command), and issue a synchronous command to the * controller. */ -static int -megadev_ioctl (struct inode *inode,struct file *filep,unsigned int cmd, -unsigned long arg) +static long +megadev_do_ioctl (struct file *filep,unsigned int cmd,unsigned long arg) {adapter_t *adapter;nitioctl_t uioc;int adapno; -int rval; +long rval;mega_passthru __user *upthru;/* user address for passthru */ mega_passthru *pthru;/* copy user passthru here */ dma_addr_t pthru_dma_hndl;
@@ -3692,6 +3690,16 @@ freemem_and_return:return 0 ; } +static long +megadev_ioctl (struct file *filep,unsigned int cmd,unsigned long arg) +{ +long ret; +lock_kernel (); + ret =megadev_do_ioctl (filep, cmd, arg); +unlock_kernel (); +return ret; +} +/** * mega_m_to_n() * @arg - user address
drivers/scsi/megaraid.h +1 -2
@@ -1013,8 +1013,7 @@ static void mega_8_to_40ld (mraid_inquiry *inquiry, mega_inquiry3 *enquiry3, mega_product_info *);static int megadev_open (struct inode *,struct file *); -static int megadev_ioctl (struct inode *,struct file *,unsigned int , -unsigned long ); +static long megadev_ioctl (struct file *,unsigned int ,unsigned long );static int mega_m_to_n (void __user *,nitioctl_t *);static int mega_n_to_m (void __user *,megacmd_t *);
drivers/scsi/osst.c +11 -6
@@ -4843,8 +4843,8 @@ static int os_scsi_tape_close(struct inode * inode, struct file * filp)/* The ioctl command */ -static int osst_ioctl (struct inode * inode,struct file * file, -unsigned int cmd_in,unsigned long arg) +static long osst_ioctl (struct file * file,unsigned int cmd_in, +unsigned long arg) {int i, cmd_nr, cmd_type, blk, retval =0 ;struct st_modedef * STm;
@@ -4854,8 +4854,11 @@ static int osst_ioctl(struct inode * inode,struct file * file,char * name =tape_name (STp);void __user * p = (void __user *)arg; -if (mutex_lock_interruptible (&STp->lock)) +lock_kernel (); +if (mutex_lock_interruptible (&STp->lock)) { +unlock_kernel ();return -ERESTARTSYS ; + }#if DEBUG if (debugging && !STp->in_use) {
@@ -5166,13 +5169,15 @@ static int osst_ioctl(struct inode * inode,struct file * file,if (SRpnt)osst_release_request (SRpnt);mutex_unlock (&STp->lock); - -return scsi_ioctl (STp->device, cmd_in, p); + retval =scsi_ioctl (STp->device, cmd_in, p); +unlock_kernel (); +return retval; out:if (SRpnt)osst_release_request (SRpnt);mutex_unlock (&STp->lock); +unlock_kernel ();return retval; }
@@ -5529,7 +5534,7 @@ static const struct file_operations osst_fops = { .owner = THIS_MODULE, .read = osst_read, .write = osst_write, - .ioctl = osst_ioctl, + .unlocked_ioctl = osst_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = osst_compat_ioctl,#endif
drivers/scsi/sg.c +13 -4
@@ -769,9 +769,8 @@ sg_srp_done(Sg_request *srp, Sg_fd *sfp)return done; } -static int -sg_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd_in,unsigned long arg) +static long +do_sg_ioctl (struct file *filp,unsigned int cmd_in,unsigned long arg) {void __user *p = (void __user *)arg;int __user *ip = p;
@@ -1086,6 +1085,16 @@ sg_ioctl(struct inode *inode, struct file *filp, } } +static long sg_ioctl (struct file *filp,unsigned int cmd_in, +unsigned long arg) +{ +long ret; +lock_kernel (); + ret =do_sg_ioctl (filp, cmd_in, arg); +unlock_kernel (); +return ret; +} +#ifdef CONFIG_COMPAT static long sg_compat_ioctl (struct file *filp,unsigned int cmd_in,unsigned long arg) {
@@ -1329,7 +1338,7 @@ static struct file_operations sg_fops = { .read = sg_read, .write = sg_write, .poll = sg_poll, - .ioctl = sg_ioctl, + .unlocked_ioctl = sg_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = sg_compat_ioctl,#endif