Commit 3d3c0c33 authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://bk.arm.linux.org.uk/linux-2.6-rmk

into ppc970.osdl.org:/home/torvalds/v2.6/linux
parents 85021953 8328bd49
......@@ -1467,9 +1467,6 @@ request_queue_t *blk_init_queue(request_fn_proc *rfn, spinlock_t *lock)
printk("Using %s io scheduler\n", chosen_elevator->elevator_name);
}
if (elevator_init(q, chosen_elevator))
goto out_elv;
q->request_fn = rfn;
q->back_merge_fn = ll_back_merge_fn;
q->front_merge_fn = ll_front_merge_fn;
......@@ -1487,8 +1484,12 @@ request_queue_t *blk_init_queue(request_fn_proc *rfn, spinlock_t *lock)
blk_queue_max_hw_segments(q, MAX_HW_SEGMENTS);
blk_queue_max_phys_segments(q, MAX_PHYS_SEGMENTS);
return q;
out_elv:
/*
* all done
*/
if (!elevator_init(q, chosen_elevator))
return q;
blk_cleanup_queue(q);
out_init:
kmem_cache_free(requestq_cachep, q);
......
......@@ -259,7 +259,7 @@ static int pcd_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data;
return cdrom_ioctl(&cd->info, inode, cmd, arg);
return cdrom_ioctl(file, &cd->info, inode, cmd, arg);
}
static int pcd_block_media_changed(struct gendisk *disk)
......
......@@ -105,8 +105,80 @@ static int sg_emulated_host(request_queue_t *q, int __user *p)
return put_user(1, p);
}
static int sg_io(request_queue_t *q, struct gendisk *bd_disk,
struct sg_io_hdr *hdr)
#define CMD_READ_SAFE 0x01
#define CMD_WRITE_SAFE 0x02
#define safe_for_read(cmd) [cmd] = CMD_READ_SAFE
#define safe_for_write(cmd) [cmd] = CMD_WRITE_SAFE
static int verify_command(struct file *file, unsigned char *cmd)
{
static const unsigned char cmd_type[256] = {
/* Basic read-only commands */
safe_for_read(TEST_UNIT_READY),
safe_for_read(REQUEST_SENSE),
safe_for_read(READ_6),
safe_for_read(READ_10),
safe_for_read(READ_12),
safe_for_read(READ_16),
safe_for_read(READ_BUFFER),
safe_for_read(READ_LONG),
safe_for_read(INQUIRY),
safe_for_read(MODE_SENSE),
safe_for_read(MODE_SENSE_10),
safe_for_read(START_STOP),
/* Audio CD commands */
safe_for_read(GPCMD_PLAY_CD),
safe_for_read(GPCMD_PLAY_AUDIO_10),
safe_for_read(GPCMD_PLAY_AUDIO_MSF),
safe_for_read(GPCMD_PLAY_AUDIO_TI),
/* CD/DVD data reading */
safe_for_read(GPCMD_READ_CD),
safe_for_read(GPCMD_READ_CD_MSF),
safe_for_read(GPCMD_READ_DISC_INFO),
safe_for_read(GPCMD_READ_CDVD_CAPACITY),
safe_for_read(GPCMD_READ_DVD_STRUCTURE),
safe_for_read(GPCMD_READ_HEADER),
safe_for_read(GPCMD_READ_TRACK_RZONE_INFO),
safe_for_read(GPCMD_READ_SUBCHANNEL),
safe_for_read(GPCMD_READ_TOC_PMA_ATIP),
safe_for_read(GPCMD_REPORT_KEY),
safe_for_read(GPCMD_SCAN),
/* Basic writing commands */
safe_for_write(WRITE_6),
safe_for_write(WRITE_10),
safe_for_write(WRITE_VERIFY),
safe_for_write(WRITE_12),
safe_for_write(WRITE_VERIFY_12),
safe_for_write(WRITE_16),
safe_for_write(WRITE_BUFFER),
safe_for_write(WRITE_LONG),
};
unsigned char type = cmd_type[cmd[0]];
/* Anybody who can open the device can do a read-safe command */
if (type & CMD_READ_SAFE)
return 0;
/* Write-safe commands just require a writable open.. */
if (type & CMD_WRITE_SAFE) {
if (file->f_mode & FMODE_WRITE)
return 0;
}
/* And root can do any command.. */
if (capable(CAP_SYS_RAWIO))
return 0;
/* Otherwise fail it with an "Operation not permitted" */
return -EPERM;
}
static int sg_io(struct file *file, request_queue_t *q,
struct gendisk *bd_disk, struct sg_io_hdr *hdr)
{
unsigned long start_time;
int reading, writing;
......@@ -121,6 +193,8 @@ static int sg_io(request_queue_t *q, struct gendisk *bd_disk,
return -EINVAL;
if (copy_from_user(cmd, hdr->cmdp, hdr->cmd_len))
return -EFAULT;
if (verify_command(file, cmd))
return -EPERM;
/*
* we'll do that later
......@@ -226,8 +300,8 @@ static int sg_io(request_queue_t *q, struct gendisk *bd_disk,
#define READ_DEFECT_DATA_TIMEOUT (60 * HZ )
#define OMAX_SB_LEN 16 /* For backward compatibility */
static int sg_scsi_ioctl(request_queue_t *q, struct gendisk *bd_disk,
Scsi_Ioctl_Command __user *sic)
static int sg_scsi_ioctl(struct file *file, request_queue_t *q,
struct gendisk *bd_disk, Scsi_Ioctl_Command __user *sic)
{
struct request *rq;
int err, in_len, out_len, bytes, opcode, cmdlen;
......@@ -269,6 +343,10 @@ static int sg_scsi_ioctl(request_queue_t *q, struct gendisk *bd_disk,
if (copy_from_user(buffer, sic->data + cmdlen, in_len))
goto error;
err = verify_command(file, rq->cmd);
if (err)
goto error;
switch (opcode) {
case SEND_DIAGNOSTIC:
case FORMAT_UNIT:
......@@ -319,7 +397,7 @@ static int sg_scsi_ioctl(request_queue_t *q, struct gendisk *bd_disk,
return err;
}
int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, void __user *arg)
int scsi_cmd_ioctl(struct file *file, struct gendisk *bd_disk, unsigned int cmd, void __user *arg)
{
request_queue_t *q;
struct request *rq;
......@@ -366,7 +444,7 @@ int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, void __user *arg)
err = -EFAULT;
if (copy_from_user(&hdr, arg, sizeof(hdr)))
break;
err = sg_io(q, bd_disk, &hdr);
err = sg_io(file, q, bd_disk, &hdr);
if (err == -EFAULT)
break;
......@@ -414,7 +492,7 @@ int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, void __user *arg)
hdr.cmdp = ((struct cdrom_generic_command __user*) arg)->cmd;
hdr.cmd_len = sizeof(cgc.cmd);
err = sg_io(q, bd_disk, &hdr);
err = sg_io(file, q, bd_disk, &hdr);
if (err == -EFAULT)
break;
......@@ -437,7 +515,7 @@ int scsi_cmd_ioctl(struct gendisk *bd_disk, unsigned int cmd, void __user *arg)
if (!arg)
break;
err = sg_scsi_ioctl(q, bd_disk, arg);
err = sg_scsi_ioctl(file, q, bd_disk, arg);
break;
case CDROMCLOSETRAY:
close = 1;
......
......@@ -2072,14 +2072,14 @@ static int cdrom_read_cdda(struct cdrom_device_info *cdi, __u8 __user *ubuf,
* these days. ATAPI / SCSI specific code now mainly resides in
* mmc_ioct().
*/
int cdrom_ioctl(struct cdrom_device_info *cdi, struct inode *ip,
unsigned int cmd, unsigned long arg)
int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi,
struct inode *ip, unsigned int cmd, unsigned long arg)
{
struct cdrom_device_ops *cdo = cdi->ops;
int ret;
/* Try the generic SCSI command ioctl's first.. */
ret = scsi_cmd_ioctl(ip->i_bdev->bd_disk, cmd, (void __user *)arg);
ret = scsi_cmd_ioctl(file, ip->i_bdev->bd_disk, cmd, (void __user *)arg);
if (ret != -ENOTTY)
return ret;
......
......@@ -3179,7 +3179,7 @@ static int scd_block_release(struct inode *inode, struct file *file)
static int scd_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
return cdrom_ioctl(&scd_info, inode, cmd, arg);
return cdrom_ioctl(file, &scd_info, inode, cmd, arg);
}
static int scd_block_media_changed(struct gendisk *disk)
......
......@@ -1363,7 +1363,7 @@ static int cm206_block_release(struct inode *inode, struct file *file)
static int cm206_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
return cdrom_ioctl(&cm206_info, inode, cmd, arg);
return cdrom_ioctl(file, &cm206_info, inode, cmd, arg);
}
static int cm206_block_media_changed(struct gendisk *disk)
......
......@@ -227,7 +227,7 @@ static int mcd_block_release(struct inode *inode, struct file *file)
static int mcd_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
return cdrom_ioctl(&mcd_info, inode, cmd, arg);
return cdrom_ioctl(file, &mcd_info, inode, cmd, arg);
}
static int mcd_block_media_changed(struct gendisk *disk)
......
......@@ -233,7 +233,7 @@ static int mcdx_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
struct s_drive_stuff *p = inode->i_bdev->bd_disk->private_data;
return cdrom_ioctl(&p->info, inode, cmd, arg);
return cdrom_ioctl(file, &p->info, inode, cmd, arg);
}
static int mcdx_block_media_changed(struct gendisk *disk)
......
......@@ -5372,7 +5372,7 @@ static int sbpcd_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data;
return cdrom_ioctl(p->sbpcd_infop, inode, cmd, arg);
return cdrom_ioctl(file, p->sbpcd_infop, inode, cmd, arg);
}
static int sbpcd_block_media_changed(struct gendisk *disk)
......
......@@ -199,7 +199,7 @@ static int viocd_blk_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
struct disk_info *di = inode->i_bdev->bd_disk->private_data;
return cdrom_ioctl(&di->viocd_info, inode, cmd, arg);
return cdrom_ioctl(file, &di->viocd_info, inode, cmd, arg);
}
static int viocd_blk_media_changed(struct gendisk *disk)
......
......@@ -3395,10 +3395,10 @@ static int idecd_ioctl (struct inode *inode, struct file *file,
{
struct block_device *bdev = inode->i_bdev;
ide_drive_t *drive = bdev->bd_disk->private_data;
int err = generic_ide_ioctl(bdev, cmd, arg);
int err = generic_ide_ioctl(file, bdev, cmd, arg);
if (err == -EINVAL) {
struct cdrom_info *info = drive->driver_data;
err = cdrom_ioctl(&info->devinfo, inode, cmd, arg);
err = cdrom_ioctl(file, &info->devinfo, inode, cmd, arg);
}
return err;
}
......
......@@ -1668,7 +1668,7 @@ static int idedisk_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct block_device *bdev = inode->i_bdev;
return generic_ide_ioctl(bdev, cmd, arg);
return generic_ide_ioctl(file, bdev, cmd, arg);
}
static int idedisk_media_changed(struct gendisk *disk)
......
......@@ -1946,7 +1946,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,
ide_drive_t *drive = bdev->bd_disk->private_data;
idefloppy_floppy_t *floppy = drive->driver_data;
void __user *argp = (void __user *)arg;
int err = generic_ide_ioctl(bdev, cmd, arg);
int err = generic_ide_ioctl(file, bdev, cmd, arg);
int prevent = (arg) ? 1 : 0;
idefloppy_pc_t pc;
if (err != -EINVAL)
......
......@@ -4807,7 +4807,7 @@ static int idetape_ioctl(struct inode *inode, struct file *file,
{
struct block_device *bdev = inode->i_bdev;
ide_drive_t *drive = bdev->bd_disk->private_data;
int err = generic_ide_ioctl(bdev, cmd, arg);
int err = generic_ide_ioctl(file, bdev, cmd, arg);
if (err == -EINVAL)
err = idetape_blkdev_ioctl(drive, cmd, arg);
return err;
......
......@@ -1453,8 +1453,8 @@ static int generic_ide_resume(struct device *dev)
return ide_do_drive_cmd(drive, &rq, ide_head_wait);
}
int generic_ide_ioctl(struct block_device *bdev, unsigned int cmd,
unsigned long arg)
int generic_ide_ioctl(struct file *file, struct block_device *bdev,
unsigned int cmd, unsigned long arg)
{
ide_drive_t *drive = bdev->bd_disk->private_data;
ide_settings_t *setting;
......@@ -1605,7 +1605,7 @@ int generic_ide_ioctl(struct block_device *bdev, unsigned int cmd,
case CDROMEJECT:
case CDROMCLOSETRAY:
return scsi_cmd_ioctl(bdev->bd_disk, cmd, p);
return scsi_cmd_ioctl(file, bdev->bd_disk, cmd, p);
case HDIO_GET_BUSSTATE:
if (!capable(CAP_SYS_ADMIN))
......
......@@ -735,7 +735,7 @@ static int idescsi_ide_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct block_device *bdev = inode->i_bdev;
return generic_ide_ioctl(bdev, cmd, arg);
return generic_ide_ioctl(file, bdev, cmd, arg);
}
static struct block_device_operations idescsi_ops = {
......
......@@ -594,7 +594,7 @@ static int sd_ioctl(struct inode * inode, struct file * filp,
case SCSI_IOCTL_GET_BUS_NUMBER:
return scsi_ioctl(sdp, cmd, p);
default:
error = scsi_cmd_ioctl(disk, cmd, p);
error = scsi_cmd_ioctl(filp, disk, cmd, p);
if (error != -ENOTTY)
return error;
}
......
......@@ -504,7 +504,7 @@ static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd,
case SCSI_IOCTL_GET_BUS_NUMBER:
return scsi_ioctl(sdev, cmd, (void __user *)arg);
}
return cdrom_ioctl(&cd->cdi, inode, cmd, arg);
return cdrom_ioctl(file, &cd->cdi, inode, cmd, arg);
}
static int sr_block_media_changed(struct gendisk *disk)
......
......@@ -3408,7 +3408,7 @@ static int st_ioctl(struct inode *inode, struct file *file,
case SCSI_IOCTL_GET_BUS_NUMBER:
break;
default:
i = scsi_cmd_ioctl(STp->disk, cmd_in, p);
i = scsi_cmd_ioctl(file, STp->disk, cmd_in, p);
if (i != -ENOTTY)
return i;
break;
......
......@@ -73,7 +73,7 @@ static inline void tlb_flush_mmu(struct mmu_gather *mp)
extern void smp_flush_tlb_mm(struct mm_struct *mm);
#define do_flush_tlb_mm(mm) smp_flush_tlb_mm(mm)
#else
#define do_flush_tlb_mm(mm) __flush_tlb_mm(CTX_HWBITS(mm), SECONDARY_CONTEXT)
#define do_flush_tlb_mm(mm) __flush_tlb_mm(CTX_HWBITS(mm->context), SECONDARY_CONTEXT)
#endif
static inline void tlb_finish_mmu(struct mmu_gather *mp, unsigned long start, unsigned long end)
......
......@@ -517,7 +517,7 @@ extern int blk_remove_plug(request_queue_t *);
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_hw_contig_segment(request_queue_t *q, struct bio *, struct bio *);
extern int scsi_cmd_ioctl(struct gendisk *, unsigned int, void __user *);
extern int scsi_cmd_ioctl(struct file *, struct gendisk *, unsigned int, void __user *);
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);
......
......@@ -984,8 +984,8 @@ struct cdrom_device_ops {
extern int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip,
struct file *fp);
extern int cdrom_release(struct cdrom_device_info *cdi, struct file *fp);
extern int cdrom_ioctl(struct cdrom_device_info *cdi, struct inode *ip,
unsigned int cmd, unsigned long arg);
extern int cdrom_ioctl(struct file *file, struct cdrom_device_info *cdi,
struct inode *ip, unsigned int cmd, unsigned long arg);
extern int cdrom_media_changed(struct cdrom_device_info *);
extern int register_cdrom(struct cdrom_device_info *cdi);
......
......@@ -1194,7 +1194,7 @@ typedef struct ide_driver_s {
#define DRIVER(drive) ((drive)->driver)
extern int generic_ide_ioctl(struct block_device *, unsigned, unsigned long);
extern int generic_ide_ioctl(struct file *, struct block_device *, unsigned, unsigned long);
/*
* ide_hwifs[] is the master data structure used to keep track
......
......@@ -113,7 +113,7 @@ extern int sysctl_hz_timer;
#if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
extern unsigned long powersave_nap;
int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp);
void __user *buffer, size_t *lenp, loff_t *ppos);
#endif
#ifdef CONFIG_BSD_PROCESS_ACCT
......
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