Commit 7e9671c0 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: scsi_cmd_ioctl __user annotation

scsi_cmd_ioctl() switched to __user *, block/scsi_ioctl.c annotated.
parent d094cdb2
...@@ -44,18 +44,18 @@ EXPORT_SYMBOL(scsi_command_size); ...@@ -44,18 +44,18 @@ EXPORT_SYMBOL(scsi_command_size);
#include <scsi/sg.h> #include <scsi/sg.h>
static int sg_get_version(int *p) static int sg_get_version(int __user *p)
{ {
static int sg_version_num = 30527; static int sg_version_num = 30527;
return put_user(sg_version_num, p); return put_user(sg_version_num, p);
} }
static int scsi_get_idlun(request_queue_t *q, int *p) static int scsi_get_idlun(request_queue_t *q, int __user *p)
{ {
return put_user(0, p); return put_user(0, p);
} }
static int scsi_get_bus(request_queue_t *q, int *p) static int scsi_get_bus(request_queue_t *q, int __user *p)
{ {
return put_user(0, p); return put_user(0, p);
} }
...@@ -65,7 +65,7 @@ static int sg_get_timeout(request_queue_t *q) ...@@ -65,7 +65,7 @@ static int sg_get_timeout(request_queue_t *q)
return q->sg_timeout / (HZ / USER_HZ); return q->sg_timeout / (HZ / USER_HZ);
} }
static int sg_set_timeout(request_queue_t *q, int *p) static int sg_set_timeout(request_queue_t *q, int __user *p)
{ {
int timeout, err = get_user(timeout, p); int timeout, err = get_user(timeout, p);
...@@ -75,12 +75,12 @@ static int sg_set_timeout(request_queue_t *q, int *p) ...@@ -75,12 +75,12 @@ static int sg_set_timeout(request_queue_t *q, int *p)
return err; return err;
} }
static int sg_get_reserved_size(request_queue_t *q, int *p) static int sg_get_reserved_size(request_queue_t *q, int __user *p)
{ {
return put_user(q->sg_reserved_size, p); return put_user(q->sg_reserved_size, p);
} }
static int sg_set_reserved_size(request_queue_t *q, int *p) static int sg_set_reserved_size(request_queue_t *q, int __user *p)
{ {
int size, err = get_user(size, p); int size, err = get_user(size, p);
...@@ -100,7 +100,7 @@ static int sg_set_reserved_size(request_queue_t *q, int *p) ...@@ -100,7 +100,7 @@ static int sg_set_reserved_size(request_queue_t *q, int *p)
* will always return that we are ATAPI even for a real SCSI drive, I'm not * will always return that we are ATAPI even for a real SCSI drive, I'm not
* so sure this is worth doing anything about (why would you care??) * so sure this is worth doing anything about (why would you care??)
*/ */
static int sg_emulated_host(request_queue_t *q, int *p) static int sg_emulated_host(request_queue_t *q, int __user *p)
{ {
return put_user(1, p); return put_user(1, p);
} }
...@@ -220,7 +220,7 @@ static int sg_io(request_queue_t *q, struct gendisk *bd_disk, ...@@ -220,7 +220,7 @@ static int sg_io(request_queue_t *q, struct gendisk *bd_disk,
#define OMAX_SB_LEN 16 /* For backward compatibility */ #define OMAX_SB_LEN 16 /* For backward compatibility */
static int sg_scsi_ioctl(request_queue_t *q, struct gendisk *bd_disk, static int sg_scsi_ioctl(request_queue_t *q, struct gendisk *bd_disk,
Scsi_Ioctl_Command *sic) Scsi_Ioctl_Command __user *sic)
{ {
struct request *rq; struct request *rq;
int err, in_len, out_len, bytes, opcode, cmdlen; int err, in_len, out_len, bytes, opcode, cmdlen;
...@@ -312,7 +312,7 @@ static int sg_scsi_ioctl(request_queue_t *q, struct gendisk *bd_disk, ...@@ -312,7 +312,7 @@ static int sg_scsi_ioctl(request_queue_t *q, struct gendisk *bd_disk,
return err; return err;
} }
int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, unsigned long arg) int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, void __user *arg)
{ {
request_queue_t *q; request_queue_t *q;
struct request *rq; struct request *rq;
...@@ -330,40 +330,40 @@ int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, unsigned long arg) ...@@ -330,40 +330,40 @@ int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, unsigned long arg)
* new sgv3 interface * new sgv3 interface
*/ */
case SG_GET_VERSION_NUM: case SG_GET_VERSION_NUM:
err = sg_get_version((int *) arg); err = sg_get_version(arg);
break; break;
case SCSI_IOCTL_GET_IDLUN: case SCSI_IOCTL_GET_IDLUN:
err = scsi_get_idlun(q, (int *) arg); err = scsi_get_idlun(q, arg);
break; break;
case SCSI_IOCTL_GET_BUS_NUMBER: case SCSI_IOCTL_GET_BUS_NUMBER:
err = scsi_get_bus(q, (int *) arg); err = scsi_get_bus(q, arg);
break; break;
case SG_SET_TIMEOUT: case SG_SET_TIMEOUT:
err = sg_set_timeout(q, (int *) arg); err = sg_set_timeout(q, arg);
break; break;
case SG_GET_TIMEOUT: case SG_GET_TIMEOUT:
err = sg_get_timeout(q); err = sg_get_timeout(q);
break; break;
case SG_GET_RESERVED_SIZE: case SG_GET_RESERVED_SIZE:
err = sg_get_reserved_size(q, (int *) arg); err = sg_get_reserved_size(q, arg);
break; break;
case SG_SET_RESERVED_SIZE: case SG_SET_RESERVED_SIZE:
err = sg_set_reserved_size(q, (int *) arg); err = sg_set_reserved_size(q, arg);
break; break;
case SG_EMULATED_HOST: case SG_EMULATED_HOST:
err = sg_emulated_host(q, (int *) arg); err = sg_emulated_host(q, arg);
break; break;
case SG_IO: { case SG_IO: {
struct sg_io_hdr hdr; struct sg_io_hdr hdr;
err = -EFAULT; err = -EFAULT;
if (copy_from_user(&hdr, (struct sg_io_hdr __user *) arg, sizeof(hdr))) if (copy_from_user(&hdr, arg, sizeof(hdr)))
break; break;
err = sg_io(q, bd_disk, &hdr); err = sg_io(q, bd_disk, &hdr);
if (err == -EFAULT) if (err == -EFAULT)
break; break;
if (copy_to_user((struct sg_io_hdr __user *) arg, &hdr, sizeof(hdr))) if (copy_to_user(arg, &hdr, sizeof(hdr)))
err = -EFAULT; err = -EFAULT;
break; break;
} }
...@@ -372,7 +372,7 @@ int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, unsigned long arg) ...@@ -372,7 +372,7 @@ int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, unsigned long arg)
struct sg_io_hdr hdr; struct sg_io_hdr hdr;
err = -EFAULT; err = -EFAULT;
if (copy_from_user(&cgc, (struct cdrom_generic_command __user *) arg, sizeof(cgc))) if (copy_from_user(&cgc, arg, sizeof(cgc)))
break; break;
cgc.timeout = clock_t_to_jiffies(cgc.timeout); cgc.timeout = clock_t_to_jiffies(cgc.timeout);
memset(&hdr, 0, sizeof(hdr)); memset(&hdr, 0, sizeof(hdr));
...@@ -416,7 +416,7 @@ int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, unsigned long arg) ...@@ -416,7 +416,7 @@ int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, unsigned long arg)
cgc.stat = err; cgc.stat = err;
cgc.buflen = hdr.resid; cgc.buflen = hdr.resid;
if (copy_to_user((struct cdrom_generic_command __user *) arg, &cgc, sizeof(cgc))) if (copy_to_user(arg, &cgc, sizeof(cgc)))
err = -EFAULT; err = -EFAULT;
break; break;
...@@ -430,8 +430,7 @@ int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, unsigned long arg) ...@@ -430,8 +430,7 @@ int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, unsigned long arg)
if (!arg) if (!arg)
break; break;
err = sg_scsi_ioctl(q, bd_disk, err = sg_scsi_ioctl(q, bd_disk, arg);
(Scsi_Ioctl_Command *)arg);
break; break;
case CDROMCLOSETRAY: case CDROMCLOSETRAY:
close = 1; close = 1;
......
...@@ -2052,7 +2052,7 @@ int cdrom_ioctl(struct cdrom_device_info *cdi, struct inode *ip, ...@@ -2052,7 +2052,7 @@ int cdrom_ioctl(struct cdrom_device_info *cdi, struct inode *ip,
int ret; int ret;
/* Try the generic SCSI command ioctl's first.. */ /* Try the generic SCSI command ioctl's first.. */
ret = scsi_cmd_ioctl(ip->i_bdev->bd_disk, cmd, arg); ret = scsi_cmd_ioctl(ip->i_bdev->bd_disk, cmd, (void __user *)arg);
if (ret != -ENOTTY) if (ret != -ENOTTY)
return ret; return ret;
......
...@@ -1639,7 +1639,7 @@ int generic_ide_ioctl(struct block_device *bdev, unsigned int cmd, ...@@ -1639,7 +1639,7 @@ int generic_ide_ioctl(struct block_device *bdev, unsigned int cmd,
case CDROMEJECT: case CDROMEJECT:
case CDROMCLOSETRAY: case CDROMCLOSETRAY:
return scsi_cmd_ioctl(bdev->bd_disk, cmd, arg); return scsi_cmd_ioctl(bdev->bd_disk, cmd, p);
case HDIO_GET_BUSSTATE: case HDIO_GET_BUSSTATE:
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
......
...@@ -592,7 +592,7 @@ static int sd_ioctl(struct inode * inode, struct file * filp, ...@@ -592,7 +592,7 @@ static int sd_ioctl(struct inode * inode, struct file * filp,
case SCSI_IOCTL_GET_BUS_NUMBER: case SCSI_IOCTL_GET_BUS_NUMBER:
return scsi_ioctl(sdp, cmd, (void *)arg); return scsi_ioctl(sdp, cmd, (void *)arg);
default: default:
error = scsi_cmd_ioctl(disk, cmd, arg); error = scsi_cmd_ioctl(disk, cmd, p);
if (error != -ENOTTY) if (error != -ENOTTY)
return error; return error;
} }
......
...@@ -3413,7 +3413,7 @@ static int st_ioctl(struct inode *inode, struct file *file, ...@@ -3413,7 +3413,7 @@ static int st_ioctl(struct inode *inode, struct file *file,
case SCSI_IOCTL_GET_BUS_NUMBER: case SCSI_IOCTL_GET_BUS_NUMBER:
break; break;
default: default:
i = scsi_cmd_ioctl(STp->disk, cmd_in, arg); i = scsi_cmd_ioctl(STp->disk, cmd_in, p);
if (i != -ENOTTY) if (i != -ENOTTY)
return i; return i;
break; break;
......
...@@ -517,7 +517,7 @@ extern int blk_remove_plug(request_queue_t *); ...@@ -517,7 +517,7 @@ extern int blk_remove_plug(request_queue_t *);
extern void blk_recount_segments(request_queue_t *, struct bio *); extern void blk_recount_segments(request_queue_t *, struct bio *);
extern int blk_phys_contig_segment(request_queue_t *q, struct bio *, struct bio *); extern int blk_phys_contig_segment(request_queue_t *q, struct bio *, struct bio *);
extern int blk_hw_contig_segment(request_queue_t *q, struct bio *, struct bio *); extern int blk_hw_contig_segment(request_queue_t *q, struct bio *, struct bio *);
extern int scsi_cmd_ioctl(struct gendisk *, unsigned int, unsigned long); extern int scsi_cmd_ioctl(struct gendisk *, unsigned int, void __user *);
extern void blk_start_queue(request_queue_t *q); extern void blk_start_queue(request_queue_t *q);
extern void blk_stop_queue(request_queue_t *q); extern void blk_stop_queue(request_queue_t *q);
extern void __blk_stop_queue(request_queue_t *q); extern void __blk_stop_queue(request_queue_t *q);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment