move compat_ioctl handling into drivers
Subsystems (14)
Arnd Bergmann
maintainercover move compat_ioctl handling into drivers
This is the second series of patches on compat_ioctl handling, moving compat handlers into more drivers. Most of these patches consist on a part that adds a compat_ioctl method in one driver and another part removing the respective section from fs/compat_ioctl.c. The fs/compat_ioctl.c portion depends on other patches[1], but the driver code can be applied independently.
If some of you feel responsible for the code I patched, please look at my changes and if they are ok, either take them into your tree or give me an Acked-by for them.
I have tested the patches for sg, usbdevfs and autofs, which was easily done in qemu, but I'm lacking test cases for most of the other ones.
Arnd <><
Arnd Bergmann (12):
arch/um: handle compat_ioctl in tty line driver scsi/sg: move compat_ioctl handling into sg driver autofs/autofs4: move compat_ioctl handling into fs
raw: partly fix compat_ioctl handling on non-x86 nbd: add compat_ioctl method smbfs: do compat_ioctl handling in place i2cdev: move compat_ioctl handling into driver md: move compat_ioctl handling into md.c lp: move compat_ioctl handling into lp.c usbdevfs: move compat_ioctl handling to devio.c hamradio/mkiss: fix typo in compat_ioctl compat_ioctl: remove unused handlers
arch/um/drivers/line.c | 6 + arch/um/drivers/ssl.c | 1 + arch/um/drivers/stdio_console.c | 1 + arch/um/include/shared/line.h | 2 + drivers/block/nbd.c | 7 +- drivers/char/lp.c | 115 +++++++-- drivers/char/raw.c | 157 ++++++++++--- drivers/i2c/i2c-dev.c | 117 +++++++++ drivers/md/md.c | 23 ++ drivers/net/hamradio/mkiss.c | 2 +- drivers/scsi/sg.c | 182 ++++++++++++++- drivers/usb/core/devio.c | 110 ++++++++- fs/autofs/root.c | 67 +++++- fs/autofs4/root.c | 69 +++++- fs/compat_ioctl.c | 504 +-------------------------------------- fs/smbfs/dir.c | 5 +- fs/smbfs/file.c | 3 +- fs/smbfs/ioctl.c | 48 ++++- fs/smbfs/proto.h | 3 +- include/linux/auto_fs.h | 1 + include/linux/usbdevice_fs.h | 26 ++ kernel/trace/blktrace.c | 1 + 22 files changed, 856 insertions(+), 594 deletions(-)
[1] http://patchwork.kernel.org/bundle/arnd/compat-ioctl-cleanup/?state=*
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
Arnd Bergmann
maintainerPATCH 1/12 arch/um: handle compat_ioctl in tty line driver
This pushes the handling of VT specific ioctls down to the UML specific drivers so we can remove it from the common compat_ioctl.c file.
--- arch/um/drivers/line.c | 6 ++++++ arch/um/drivers/ssl.c | 1 + arch/um/drivers/stdio_console.c | 1 + arch/um/include/shared/line.h | 2 ++ 4 files changed, 10 insertions(+), 0 deletions(-)
arch/um/drivers/line.c +6 -0
@@ -315,6 +315,12 @@ int line_ioctl(struct tty_struct *tty, struct file * file,return ret; } +long line_compat_ioctl (struct tty_struct *tty,struct file * file, +unsigned int cmd,unsigned long arg) +{ +return line_ioctl (tty, file, cmd, arg); +} +void line_throttle (struct tty_struct *tty) {struct line *line = tty->driver_data;
arch/um/drivers/ssl.c +1 -0
@@ -137,6 +137,7 @@ static const struct tty_operations ssl_ops = { .flush_chars = line_flush_chars, .set_termios = line_set_termios, .ioctl = line_ioctl, + .compat_ioctl = line_compat_ioctl, .throttle = line_throttle, .unthrottle = line_unthrottle,#if 0
arch/um/drivers/stdio_console.c +1 -0
@@ -120,6 +120,7 @@ static const struct tty_operations console_ops = { .flush_chars = line_flush_chars, .set_termios = line_set_termios, .ioctl = line_ioctl, + .compat_ioctl = line_compat_ioctl, .throttle = line_throttle, .unthrottle = line_unthrottle, };
arch/um/include/shared/line.h +2 -0
@@ -79,6 +79,8 @@ extern void line_flush_chars(struct tty_struct *tty);extern int line_write_room (struct tty_struct *tty);extern int line_ioctl (struct tty_struct *tty,struct file * file,unsigned int cmd,unsigned long arg); +extern long line_compat_ioctl (struct tty_struct *tty,struct file * file, +unsigned int cmd,unsigned long arg);extern void line_throttle (struct tty_struct *tty);extern void line_unthrottle (struct tty_struct *tty);
Signature · 1 line
1.6.3.3
Arnd Bergmann
maintainerPATCH 2/12 scsi/sg: move compat_ioctl handling into sg driver
In reply to Arnd BergmannThis moves the handling of SG_GET_REQUEST_TABLE from fs/compat_ioctl.c into the sg driver, which is the only user.
There was no emulation for BLKTRACE so far in the sg driver, because it does not get accessed through the block layer. Fix that by adding emulation for BLKTRACESETUP and passthrough for the other ioctls as well.
Since we're already touching the ioctl function, make it use unlocked_ioctl now, to also push down the big kernel lock into the driver.
BLKTRACESETUP32 emulation and the straight calling of compatible ioctls apparently work fine now, but I could not find a test case for SG_GET_REQUEST_TABLE in sg3-utils or elsewhere.
--- drivers/scsi/sg.c | 182 +++++++++++++++++++++++++++++++++++++++++++++-- fs/compat_ioctl.c | 50 ------------- kernel/trace/blktrace.c | 1 + 3 files changed, 176 insertions(+), 57 deletions(-)
drivers/scsi/sg.c +175 -7
@@ -49,6 +49,7 @@ static int sg_version_num = 30534; /* 2 digits for each component */#include <linux/delay.h> #include <linux/blktrace_api.h> #include <linux/smp_lock.h> +#include <linux/compat.h> #include "scsi.h" #include <scsi/scsi_dbg.h>
@@ -757,9 +758,8 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,return 0 ; } -static int -sg_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd_in,unsigned long arg) +static long +sg_locked_ioctl (struct file *filp,unsigned int cmd_in,unsigned long arg) {void __user *p = (void __user *)arg;int __user *ip = p;
@@ -1078,27 +1078,195 @@ sg_ioctl(struct inode *inode, struct file *filp, } } +static long +sg_ioctl (struct file *filp,unsigned int cmd_in,unsigned long arg) +{ +int ret; +lock_kernel (); + ret =sg_locked_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) + +typedef struct sg_compat_req_info {/* used by SG_GET_REQUEST_TABLE ioctl() */ +char req_state;/* 0 -> not used, 1 -> written, 2 -> ready to read */ +char orphan;/* 0 -> normal request, 1 -> from interruped SG_IO */ +char sg_io_owned;/* 0 -> complete with read(), 1 -> owned by SG_IO */ +char problem;/* 0 -> no problem detected, 1 -> error to report */ +int pack_id;/* pack_id associated with request */ +compat_uptr_t usr_ptr;/* user provided pointer (in new interface) */ +unsigned int duration;/* millisecs elapsed since written (req_state==1) +or request duration (req_state==2) */ +int unused; +}sg_compat_req_info_t ;/* 20 bytes long on i386 */ +#define SZ_SG_COMPAT_REQ_INFO sizeof(sg_compat_req_info_t) + +struct compat_blk_user_trace_setup { +char name[32 ]; +u16 act_mask; +u32 buf_size; +u32 buf_nr; +compat_u64 start_lba; +compat_u64 end_lba; +u32 pid; +}; +#define BLKTRACESETUP32 _IOWR(0x12, 115, struct compat_blk_user_trace_setup) + +static long sg_compat_locked_ioctl (struct file *filp,unsigned int cmd_in,unsigned long arg) {Sg_device *sdp;Sg_fd *sfp;struct scsi_device *sdev; +void __user *p =compat_ptr (arg); +Sg_request *srp; +unsigned long iflags; +struct blk_user_trace_setup buts; +struct compat_blk_user_trace_setup cbuts; +int ret, val;if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))return -ENXIO ; +switch (cmd_in) { +/* SG_IO comes back after conversion on fs/compat_ioctl.c */ +case SG_IO : +return -ENOIOCTLCMD ; + +/* These are all compatible */ +case SG_SET_TIMEOUT : +case SG_GET_TIMEOUT : +case SG_SET_FORCE_LOW_DMA : +case SG_GET_LOW_DMA : +case SG_GET_SCSI_ID : +case SG_SET_FORCE_PACK_ID : +case SG_GET_PACK_ID : +case SG_GET_NUM_WAITING : +case SG_GET_SG_TABLESIZE : +case SG_SET_RESERVED_SIZE : +case SG_GET_RESERVED_SIZE : +case SG_SET_COMMAND_Q : +case SG_GET_COMMAND_Q : +case SG_SET_KEEP_ORPHAN : +case SG_GET_KEEP_ORPHAN : +case SG_NEXT_CMD_LEN : +case SG_GET_VERSION_NUM : +case SG_GET_ACCESS_COUNT : +case SG_EMULATED_HOST : +case SG_SCSI_RESET : +case SCSI_IOCTL_SEND_COMMAND : +case SG_SET_DEBUG : +case SCSI_IOCTL_GET_IDLUN : +case SCSI_IOCTL_GET_BUS_NUMBER : +case SCSI_IOCTL_PROBE_HOST : +case SG_GET_TRANSFORM : +case BLKSECTGET : +case BLKTRACESTART : +case BLKTRACESTOP : +case BLKTRACETEARDOWN : +return sg_locked_ioctl (filp, cmd_in, + (unsigned long )compat_ptr (arg)); + } + +SCSI_LOG_TIMEOUT (3 ,printk ("sg_compat_ioctl: %s, cmd=0x%x\n" , + sdp->disk->disk_name, (int ) cmd_in)); + +switch (cmd_in) { +case SG_GET_REQUEST_TABLE : +if (!access_ok (VERIFY_WRITE , p,SZ_SG_REQ_INFO *SG_MAX_QUEUE )) +return -EFAULT ; +else { +sg_compat_req_info_t *rinfo; +unsigned int ms; + + rinfo =kmalloc (SZ_SG_COMPAT_REQ_INFO *SG_MAX_QUEUE , +GFP_KERNEL ); +if (!rinfo) +return -ENOMEM ; +read_lock_irqsave (&sfp->rq_list_lock, iflags); +for (srp = sfp->headrp, val =0 ; val <SG_MAX_QUEUE ; + ++val, srp = srp ? srp->nextrp : srp) { +memset (&rinfo[val],0 ,SZ_SG_COMPAT_REQ_INFO ); +if (srp) { + rinfo[val].req_state = srp->done +1 ; + rinfo[val].problem = + srp->header.masked_status & + srp->header.host_status & + srp->header.driver_status; +if (srp->done) + rinfo[val].duration = + srp->header.duration; +else { + ms =jiffies_to_msecs (jiffies); + rinfo[val].duration = + (ms > srp->header.duration) ? + (ms - srp->header.duration) :0 ; + } + rinfo[val].orphan = srp->orphan; + rinfo[val].sg_io_owned = + srp->sg_io_owned; + rinfo[val].pack_id = + srp->header.pack_id; + rinfo[val].usr_ptr = (compat_uptr_t ) + (unsigned long ) srp->header.usr_ptr; + } + } +read_unlock_irqrestore (&sfp->rq_list_lock, iflags); + ret =__copy_to_user (p, rinfo, +SZ_SG_COMPAT_REQ_INFO *SG_MAX_QUEUE ); + ret = ret ? -EFAULT :0 ; +kfree (rinfo); +return ret; + } +case BLKTRACESETUP32 : +if (copy_from_user (&cbuts, p,sizeof (cbuts))) +return -EFAULT ; + + buts = (struct blk_user_trace_setup ) { + .act_mask = cbuts.act_mask, + .buf_size = cbuts.buf_size, + .buf_nr = cbuts.buf_nr, + .start_lba = cbuts.start_lba, + .end_lba = cbuts.end_lba, + .pid = cbuts.pid, + }; +memcpy (&buts.name, &cbuts.name,32 ); + + ret =do_blk_trace_setup (sdp->device->request_queue, + sdp->disk->disk_name, +MKDEV (SCSI_GENERIC_MAJOR , sdp->index), +NULL , + &buts); +if (ret) +return ret; + +if (copy_to_user (p, &buts.name,32 )) +return -EFAULT ; + +return 0 ; + } + sdev = sdp->device; -if (sdev->host->hostt->compat_ioctl) { +if (sdev->host->hostt->compat_ioctl) {int ret; ret = sdev->host->hostt->compat_ioctl (sdev, cmd_in, (void __user *)arg);return ret; } - +return -ENOIOCTLCMD ; } + +static long sg_compat_ioctl (struct file *filp,unsigned int cmd_in,unsigned long arg) +{ +int ret; +lock_kernel (); + ret =sg_compat_locked_ioctl (filp, cmd_in, arg); +unlock_kernel (); +return ret; +}#endif static unsigned int
@@ -1322,7 +1490,7 @@ static const 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
fs/compat_ioctl.c +0 -50
80 lines not on this page · raw message
kernel/trace/blktrace.c +1 -0
@@ -524,6 +524,7 @@ err:blk_trace_free (bt);return ret; } +EXPORT_SYMBOL_GPL (do_blk_trace_setup); int blk_trace_setup(struct request_queue *q, char *name, dev_t dev, struct block_device *bdev,
Signature · 1 line
1.6.3.3
Arnd Bergmann
maintainerPATCH 3/12 autofs/autofs4: move compat_ioctl handling into fs
In reply to Arnd BergmannHandling of autofs ioctl numbers does not need to be generic and can easily be done directly in autofs itself.
This also pushes the BKL into autofs and autofs4 ioctl methods.
--- fs/autofs/root.c | 67 +++++++++++++++++++++++++++++++++++++++++++-- fs/autofs4/root.c | 69 ++++++++++++++++++++++++++++++++++++++++++++-- fs/compat_ioctl.c | 36 ------------------------ include/linux/auto_fs.h | 1 + 4 files changed, 131 insertions(+), 42 deletions(-)
fs/autofs/root.c +64 -3
@@ -15,6 +15,7 @@#include <linux/stat.h> #include <linux/param.h> #include <linux/time.h> +#include <linux/compat.h> #include <linux/smp_lock.h> #include "autofs_i.h"
@@ -24,12 +25,16 @@ static int autofs_root_symlink(struct inode *,struct dentry *,const char *);static int autofs_root_unlink (struct inode *,struct dentry *);static int autofs_root_rmdir (struct inode *,struct dentry *);static int autofs_root_mkdir (struct inode *,struct dentry *,int ); -static int autofs_root_ioctl (struct inode *,struct file *,unsigned int ,unsigned long ); +static long autofs_root_ioctl (struct file *,unsigned int ,unsigned long ); +static long autofs_root_compat_ioctl (struct file *,unsigned int ,unsigned long );const struct file_operations autofs_root_operations = { .read = generic_read_dir, .readdir = autofs_root_readdir, - .ioctl = autofs_root_ioctl, + .unlocked_ioctl = autofs_root_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = autofs_root_compat_ioctl, +#endif };const struct inode_operations autofs_root_inode_operations = {
@@ -490,6 +495,25 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode) }/* Get/set timeout ioctl() operation */ +#ifdef CONFIG_COMPAT +static inline int autofs_compat_get_set_timeout (struct autofs_sb_info *sbi, +unsigned int __user *p) +{ +unsigned long ntimeout; + +if (get_user (ntimeout, p) || +put_user (sbi->exp_timeout /HZ , p)) +return -EFAULT ; + +if (ntimeout >UINT_MAX /HZ ) + sbi->exp_timeout =0 ; +else + sbi->exp_timeout = ntimeout *HZ ; + +return 0 ; +} +#endif +static inline int autofs_get_set_timeout (struct autofs_sb_info *sbi,unsigned long __user *p) {
@@ -544,7 +568,7 @@ static inline int autofs_expire_run(struct super_block *sb,* ioctl()'s on the root directory is the chief method for the daemon to * generate kernel reactions */ -static int autofs_root_ioctl (struct inode *inode,struct file *filp, +static int autofs_do_root_ioctl (struct inode *inode,struct file *filp,unsigned int cmd,unsigned long arg) {struct autofs_sb_info *sbi =autofs_sbi (inode->i_sb);
@@ -569,6 +593,10 @@ static int autofs_root_ioctl(struct inode *inode, struct file *filp,return 0 ;case AUTOFS_IOC_PROTOVER :/* Get protocol version */ return autofs_get_protover (argp); +#ifdef CONFIG_COMPAT +case AUTOFS_IOC_SETTIMEOUT32 : +return autofs_compat_get_set_timeout (sbi, argp); +#endif case AUTOFS_IOC_SETTIMEOUT :return autofs_get_set_timeout (sbi, argp);case AUTOFS_IOC_EXPIRE :
@@ -577,4 +605,37 @@ static int autofs_root_ioctl(struct inode *inode, struct file *filp,default :return -ENOSYS ; } + +} + +static long autofs_root_ioctl (struct file *filp, +unsigned int cmd,unsigned long arg) +{ +int ret; + +lock_kernel (); + ret =autofs_do_root_ioctl (filp->f_path.dentry->d_inode, + filp, cmd, arg); +unlock_kernel (); + +return ret; +} + +#ifdef CONFIG_COMPAT +static long autofs_root_compat_ioctl (struct file *filp, +unsigned int cmd,unsigned long arg) +{ +struct inode *inode = filp->f_path.dentry->d_inode; +int ret; + +lock_kernel (); +if (cmd ==AUTOFS_IOC_READY || cmd ==AUTOFS_IOC_FAIL ) + ret =autofs_do_root_ioctl (inode, filp, cmd, arg); +else + ret =autofs_do_root_ioctl (inode, filp, cmd, + (unsigned long )compat_ptr (arg)); +unlock_kernel (); + +return ret; } +#endif
fs/autofs4/root.c +66 -3
108 lines not on this page · raw message
fs/compat_ioctl.c +0 -36
@@ -132,23 +132,6 @@ static int w_long(unsigned int fd, unsigned int cmd,return err; } -static int rw_long (unsigned int fd,unsigned int cmd, -compat_ulong_t __user *argp) -{ -mm_segment_t old_fs =get_fs (); -int err; -unsigned long val; - -if (get_user (val, argp)) -return -EFAULT ; -set_fs (KERNEL_DS ); - err =sys_ioctl (fd, cmd, (unsigned long )&val); -set_fs (old_fs); -if (!err &&put_user (val, argp)) -return -EFAULT ; -return err; -} -struct compat_video_event {int32_t type;compat_time_t timestamp;
@@ -556,12 +539,6 @@ static int do_smb_getmountuid(unsigned int fd, unsigned int cmd,return err; } -static int ioc_settimeout (unsigned int fd,unsigned int cmd, -compat_ulong_t __user *argp) -{ -return rw_long (fd,AUTOFS_IOC_SETTIMEOUT , argp); -} -/* Bluetooth ioctls */ #define HCIUARTSETPROTO _IOW('U', 200, int)#define HCIUARTGETPROTO _IOR('U', 201, int)
@@ -1348,13 +1325,6 @@ COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5) COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS) COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS) COMPATIBLE_IOCTL(OSS_GETVERSION) -/* AUTOFS */ -COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC) -COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER) -COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE) -COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI) -COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOSUBVER) -COMPATIBLE_IOCTL(AUTOFS_IOC_ASKUMOUNT) /* Raw devices */ COMPATIBLE_IOCTL(RAW_SETBIND) COMPATIBLE_IOCTL(RAW_GETBIND)
@@ -1647,9 +1617,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,case RAW_GETBIND :return raw_ioctl (fd, cmd, argp);#endif -#define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int) -case AUTOFS_IOC_SETTIMEOUT32 : -return ioc_settimeout (fd, cmd, argp);/* One SMB ioctl needs translations. */ #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)case SMB_IOC_GETMOUNTUID_32 :
@@ -1715,9 +1682,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,case KDSKBMETA :case KDSKBLED :case KDSETLED : -/* AUTOFS */ -case AUTOFS_IOC_READY : -case AUTOFS_IOC_FAIL :/* NBD */ case NBD_SET_SOCK :case NBD_SET_BLKSIZE :
include/linux/auto_fs.h +1 -0
@@ -79,6 +79,7 @@ struct autofs_packet_expire {#define AUTOFS_IOC_FAIL _IO(0x93,0x61)#define AUTOFS_IOC_CATATONIC _IO(0x93,0x62)#define AUTOFS_IOC_PROTOVER _IOR(0x93,0x63,int) +#define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,compat_ulong_t)#define AUTOFS_IOC_SETTIMEOUT _IOWR(0x93,0x64,unsigned long)#define AUTOFS_IOC_EXPIRE _IOR(0x93,0x65,struct autofs_packet_expire)
Signature · 1 line
1.6.3.3
Arnd Bergmann
maintainerPATCH 4/12 raw: partly fix compat_ioctl handling on non-x86
In reply to Arnd BergmannThe (compat_ioctl handling for the) raw driver is broken in multiple ways. The RAW_SETBIND and RAW_GETBIND ioctls are compatible between 32 and 64 bit on most architectures but not on x86-64 and ia64 because of the different alignment on 64 bit variables.
Defining the data structure in terms of compat_u64 rather than using __attribute__((packed)) solves this.
Another problem is the handling of ioctl passthrough to block devices, which is not implemented for the compat_ioctl case and has been broken for ages. This patch does not fix the problem but prints a diagnostic message in case someone hits it.
Also move the conversion code into the raw driver itself to clean up the common fs/compat_ioctl implementation.
Finally, push the big kernel lock into the ioctl functions, since I'm touching them anyway.
--- drivers/char/raw.c | 157 +++++++++++++++++++++++++++++++++++++++++----------- fs/compat_ioctl.c | 68 ---------------------- 2 files changed, 125 insertions(+), 100 deletions(-)
drivers/char/raw.c +125 -32
@@ -20,6 +20,7 @@#include <linux/device.h> #include <linux/mutex.h> #include <linux/smp_lock.h> +#include <linux/compat.h> #include <asm/uaccess.h>
@@ -120,9 +121,8 @@ static int raw_release(struct inode *inode, struct file *filp)/* * Forward ioctls to the underlying block device. */ -static int -raw_ioctl (struct inode *inode,struct file *filp, -unsigned int command,unsigned long arg) +static long +raw_ioctl (struct file *filp,unsigned int command,unsigned long arg) {struct block_device *bdev = filp->private_data;
@@ -140,10 +140,9 @@ static void bind_device(struct raw_config_request *rq)* Deal with ioctls against the raw-device control interface, to bind * and unbind other raw devices. */ -static int raw_ctl_ioctl (struct inode *inode,struct file *filp, -unsigned int command,unsigned long arg) +static int do_raw_ctl_ioctl (struct file *filp, +unsigned int command,struct raw_config_request *rq) { -struct raw_config_request rq;struct raw_device_data *rawdev;int err =0 ;
@@ -152,17 +151,11 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,case RAW_GETBIND :/* First, find out which raw minor we want */ - -if (copy_from_user (&rq, (void __user *) arg,sizeof (rq))) { - err = -EFAULT ; - goto out; - } - -if (rq.raw_minor <=0 || rq.raw_minor >=MAX_RAW_MINORS ) { +if (rq->raw_minor <=0 || rq->raw_minor >=MAX_RAW_MINORS ) { err = -EINVAL ; goto out; } - rawdev = &raw_devices[rq.raw_minor]; + rawdev = &raw_devices[rq->raw_minor];if (command ==RAW_SETBIND ) {dev_t dev;
@@ -183,10 +176,10 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,* major/minor numbers make sense. */ - dev =MKDEV (rq.block_major, rq.block_minor); -if ((rq.block_major ==0 && rq.block_minor !=0 ) || -MAJOR (dev) != rq.block_major || -MINOR (dev) != rq.block_minor) { + dev =MKDEV (rq->block_major, rq->block_minor); +if ((rq->block_major ==0 && rq->block_minor !=0 ) || +MAJOR (dev) != rq->block_major || +MINOR (dev) != rq->block_minor) { err = -EINVAL ; goto out; }
@@ -201,18 +194,18 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,bdput (rawdev->binding);module_put (THIS_MODULE ); } -if (rq.block_major ==0 && rq.block_minor ==0 ) { +if (rq->block_major ==0 && rq->block_minor ==0 ) {/* unbind */ rawdev->binding =NULL ;device_destroy (raw_class, -MKDEV (RAW_MAJOR , rq.raw_minor)); +MKDEV (RAW_MAJOR , rq->raw_minor)); }else { rawdev->binding =bdget (dev);if (rawdev->binding ==NULL ) err = -ENOMEM ;else {__module_get (THIS_MODULE ); -bind_device (&rq); +bind_device (rq); } }mutex_unlock (&raw_mutex);
@@ -222,16 +215,12 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,mutex_lock (&raw_mutex); bdev = rawdev->binding;if (bdev) { - rq.block_major =MAJOR (bdev->bd_dev); - rq.block_minor =MINOR (bdev->bd_dev); + rq->block_major =MAJOR (bdev->bd_dev); + rq->block_minor =MINOR (bdev->bd_dev); }else { - rq.block_major = rq.block_minor =0 ; + rq->block_major = rq->block_minor =0 ; }mutex_unlock (&raw_mutex); -if (copy_to_user ((void __user *)arg, &rq,sizeof (rq))) { - err = -EFAULT ; - goto out; - } }break ;default :
@@ -242,6 +231,108 @@ out:return err; } + +static long raw_ctl_ioctl (struct file *file,unsigned int cmd,unsigned long arg) +{ +struct raw_config_request rq; +int err = -EINVAL ; + +switch (cmd) { +case RAW_SETBIND : +case RAW_GETBIND : +if (copy_from_user (&rq, (void __user *)arg,sizeof (rq))) { + err = -EFAULT ; +break ; + } + +lock_kernel (); + err =do_raw_ctl_ioctl (file, cmd, &rq); +unlock_kernel (); + +if (!err && cmd ==RAW_GETBIND ) { +if (copy_to_user ((void __user *)arg, &rq,sizeof (rq))) { + err = -EFAULT ; + } + } +break ; + } +return err; +} + +#ifdef CONFIG_COMPAT +struct compat_raw_config_request { +compat_int_t raw_minor; +compat_u64 block_major; +compat_u64 block_minor; +}; + +static int get_raw32_request (struct raw_config_request *req, +struct compat_raw_config_request __user * user_req) +{ +int err; + +if (!access_ok (VERIFY_READ , user_req, +sizeof (struct compat_raw_config_request ))) +return -EFAULT ; + + err =__get_user (req->raw_minor, &user_req->raw_minor); + err |=__get_user (req->block_major, &user_req->block_major); + err |=__get_user (req->block_minor, &user_req->block_minor); + +return err ? -EFAULT :0 ; +} + +static int set_raw32_request (struct raw_config_request *req, +struct compat_raw_config_request __user * user_req) +{ +int err; + +if (!access_ok (VERIFY_WRITE , user_req, +sizeof (struct compat_raw_config_request ))) +return -EFAULT ; + + err =__put_user (req->raw_minor, &user_req->raw_minor); + err |=__put_user (req->block_major, &user_req->block_major); + err |=__put_user (req->block_minor, &user_req->block_minor); + +return err ? -EFAULT :0 ; +} + +static long raw_ctl_compat_ioctl (struct file *file,unsigned cmd,unsigned long arg) +{ +struct raw_config_request req; +struct compat_raw_config_request __user *user_req; +int err = -EINVAL ; + + user_req =compat_ptr (arg); +switch (cmd) { +case RAW_SETBIND : +case RAW_GETBIND : +if ((err =get_raw32_request (&req, user_req))) +return err; + +lock_kernel (); + err =do_raw_ctl_ioctl (file, cmd, &req); +unlock_kernel (); + +if ((!err) && (cmd ==RAW_GETBIND )) { + err =set_raw32_request (&req, user_req); + } +break ; + } +return err; +} + +static long +raw_compat_ioctl (struct file *filp,unsigned int command,unsigned long arg) +{ +/* FIXME: should pass through ioctls */ +compat_printk ("%s: no support for block ioctls\n" , __func__); + +return -ENOIOCTLCMD ; +} +#endif /* CONFIG_COMPAT */ +static const struct file_operations raw_fops = { .read = do_sync_read, .aio_read = generic_file_aio_read,
@@ -249,14 +340,16 @@ static const struct file_operations raw_fops = { .aio_write = blkdev_aio_write, .open = raw_open, .release= raw_release, - .ioctl = raw_ioctl, + .unlocked_ioctl = raw_ioctl, + .compat_ioctl = raw_compat_ioctl, .owner = THIS_MODULE, };static const struct file_operations raw_ctl_fops = { - .ioctl = raw_ctl_ioctl, - .open = raw_open, - .owner =THIS_MODULE , + .unlocked_ioctl = raw_ctl_ioctl, + .compat_ioctl = raw_ctl_compat_ioctl, + .open = raw_open, + .owner =THIS_MODULE , };static struct cdev raw_cdev;
fs/compat_ioctl.c +0 -68
80 lines not on this page · raw message
Signature · 1 line
1.6.3.3
Arnd Bergmann
maintainerPATCH 5/12 nbd: add compat_ioctl method
In reply to Arnd BergmannThe nbd driver needs a special case for its compat_ioctl handling, because it treats the ioctl argument as an integer instead of a pointer.
Move that handling into the nbd driver itself from fs/compat_ioctl.c in order to keep it local.
Push down the BKL into the ioctl method at the same time.
--- drivers/block/nbd.c | 7 ++++++- fs/compat_ioctl.c | 11 ----------- 2 files changed, 6 insertions(+), 12 deletions(-)
drivers/block/nbd.c +6 -1
@@ -30,6 +30,8 @@#include <net/sock.h> #include <linux/net.h> #include <linux/kthread.h> +#include <linux/smp_lock.h> +#include <linux/compat.h> #include <asm/uaccess.h> #include <asm/system.h>
@@ -715,9 +717,11 @@ static int nbd_ioctl(struct block_device *bdev, fmode_t mode,dprintk (DBG_IOCTL ,"%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n" , lo->disk->disk_name,ioctl_cmd_to_ascii (cmd), cmd, arg); +lock_kernel ();mutex_lock (&lo->tx_lock); error =__nbd_ioctl (bdev, lo, cmd, arg);mutex_unlock (&lo->tx_lock); +unlock_kernel ();return error; }
@@ -725,7 +729,8 @@ static int nbd_ioctl(struct block_device *bdev, fmode_t mode,static const struct block_device_operations nbd_fops = { .owner =THIS_MODULE , - .locked_ioctl = nbd_ioctl, + .ioctl = nbd_ioctl, + .compat_ioctl = nbd_ioctl, };/*
fs/compat_ioctl.c +0 -11
@@ -1362,12 +1362,6 @@ COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32) COMPATIBLE_IOCTL(USBDEVFS_REAPURB32) COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32) COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT) -/* NBD */ -COMPATIBLE_IOCTL(NBD_DO_IT) -COMPATIBLE_IOCTL(NBD_CLEAR_SOCK) -COMPATIBLE_IOCTL(NBD_CLEAR_QUE) -COMPATIBLE_IOCTL(NBD_PRINT_DEBUG) -COMPATIBLE_IOCTL(NBD_DISCONNECT) /* i2c */ COMPATIBLE_IOCTL(I2C_SLAVE) COMPATIBLE_IOCTL(I2C_SLAVE_FORCE)
@@ -1614,11 +1608,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,case KDSKBMETA :case KDSKBLED :case KDSETLED : -/* NBD */ -case NBD_SET_SOCK : -case NBD_SET_BLKSIZE : -case NBD_SET_SIZE : -case NBD_SET_SIZE_BLOCKS :return do_vfs_ioctl (file, fd, cmd, arg); }
Signature · 1 line
1.6.3.3
Arnd Bergmann
maintainerPATCH 6/12 smbfs: do compat_ioctl handling in place
In reply to Arnd BergmannHandling SMB_IOC_GETMOUNTUID emulation directly in smbfs avoids extra code in fs/compat_ioctl.c and can be optimized away by the compiler in architectures where SMB_IOC_GETMOUNTUID and COMPAT_SMB_IOC_GETMOUNTUID are identical.
As a positive side-effect, this pushes the BKL into the ioctl method.
--- fs/compat_ioctl.c | 25 ------------------------- fs/smbfs/dir.c | 5 ++++- fs/smbfs/file.c | 3 ++- fs/smbfs/ioctl.c | 48 ++++++++++++++++++++++++++++++++++++++++++++---- fs/smbfs/proto.h | 3 ++- 5 files changed, 52 insertions(+), 32 deletions(-)
fs/compat_ioctl.c +0 -25
@@ -520,25 +520,6 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, void __user *argp)#endif /* CONFIG_BLOCK */ -static int do_smb_getmountuid (unsigned int fd,unsigned int cmd, -compat_uid_t __user *argp) -{ -mm_segment_t old_fs =get_fs (); -__kernel_uid_t kuid; -int err; - - cmd =SMB_IOC_GETMOUNTUID ; - -set_fs (KERNEL_DS ); - err =sys_ioctl (fd, cmd, (unsigned long )&kuid); -set_fs (old_fs); - -if (err >=0 ) - err =put_user (kuid, argp); - -return err; -} -/* Bluetooth ioctls */ #define HCIUARTSETPROTO _IOW('U', 200, int)#define HCIUARTGETPROTO _IOR('U', 201, int)
@@ -1264,8 +1245,6 @@ COMPATIBLE_IOCTL(OSS_GETVERSION)/* Raw devices */ COMPATIBLE_IOCTL(RAW_SETBIND) COMPATIBLE_IOCTL(RAW_GETBIND) -/* SMB ioctls which do not need any translations */ -COMPATIBLE_IOCTL(SMB_IOC_NEWCONN) /* Watchdog */ COMPATIBLE_IOCTL(WDIOC_GETSUPPORT) COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
@@ -1543,10 +1522,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,case MTIOCPOS32 :return mt_ioctl_trans (fd, cmd, argp);#endif -/* One SMB ioctl needs translations. */ -#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) -case SMB_IOC_GETMOUNTUID_32 : -return do_smb_getmountuid (fd, cmd, argp);/* Serial */ case TIOCGSERIAL :case TIOCSSERIAL :
fs/smbfs/dir.c +4 -1
@@ -39,7 +39,10 @@ const struct file_operations smb_dir_operations = { .read = generic_read_dir, .readdir = smb_readdir, - .ioctl = smb_ioctl, + .unlocked_ioctl = smb_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = smb_ioctl, +#endif .open = smb_dir_open, };
fs/smbfs/file.c +2 -1
@@ -438,7 +438,8 @@ const struct file_operations smb_file_operations = .aio_read = smb_file_aio_read, .write = do_sync_write, .aio_write = smb_file_aio_write, - .ioctl = smb_ioctl, + .unlocked_ioctl = smb_ioctl, + .compat_ioctl = smb_ioctl, .mmap = smb_file_mmap, .open = smb_file_open, .release = smb_file_release,
fs/smbfs/ioctl.c +44 -4
64 lines not on this page · raw message
fs/smbfs/proto.h +2 -1
@@ -67,7 +67,8 @@ extern const struct address_space_operations smb_file_aops;extern const struct file_operations smb_file_operations;extern const struct inode_operations smb_file_inode_operations;/* ioctl.c */ -extern int smb_ioctl (struct inode *inode,struct file *filp,unsigned int cmd,unsigned long arg); +extern long smb_ioctl (struct file *filp,unsigned int cmd,unsigned long arg); +extern long smb_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg);/* smbiod.c */ extern void smbiod_wake_up (void );extern int smbiod_register_server (struct smb_sb_info *server);
Signature · 1 line
1.6.3.3
Arnd Bergmann
maintainerPATCH 7/12 i2cdev: move compat_ioctl handling into driver
In reply to Arnd BergmannDoing all the compat_ioctl handling in the i2c driver itself removes special cases from fs/compat_ioctl.c and makes it possible to optimize this case better.
--- drivers/i2c/i2c-dev.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/compat_ioctl.c | 119 ------------------------------------------------- 2 files changed, 117 insertions(+), 119 deletions(-)
drivers/i2c/i2c-dev.c +117 -0
@@ -35,6 +35,7 @@#include <linux/i2c.h> #include <linux/i2c-dev.h> #include <linux/smp_lock.h> +#include <linux/compat.h> #include <linux/jiffies.h> #include <asm/uaccess.h>
@@ -439,6 +440,119 @@ static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)return 0 ; } +#ifdef CONFIG_COMPAT +struct i2c_msg32 { +u16 addr; +u16 flags; +u16 len; +compat_caddr_t buf; +}; + +struct i2c_rdwr_ioctl_data32 { +compat_caddr_t msgs;/* struct i2c_msg __user *msgs */ +u32 nmsgs; +}; + +struct i2c_smbus_ioctl_data32 { +u8 read_write; +u8 command; +u32 size; +compat_caddr_t data;/* union i2c_smbus_data *data */ +}; + +struct i2c_rdwr_aligned { +struct i2c_rdwr_ioctl_data cmd; +struct i2c_msg msgs[0 ]; +}; + +static int compat_i2c_rdwr_ioctl (struct file *filp,unsigned int cmd, +struct i2c_rdwr_ioctl_data32 __user *udata) +{ +struct i2c_rdwr_aligned __user *tdata; +struct i2c_msg __user *tmsgs; +struct i2c_msg32 __user *umsgs; +compat_caddr_t datap; +int nmsgs, i; + +if (get_user (nmsgs, &udata->nmsgs)) +return -EFAULT ; +if (nmsgs >I2C_RDRW_IOCTL_MAX_MSGS ) +return -EINVAL ; + +if (get_user (datap, &udata->msgs)) +return -EFAULT ; + umsgs =compat_ptr (datap); + + tdata =compat_alloc_user_space (sizeof (*tdata) + + nmsgs *sizeof (struct i2c_msg )); + tmsgs = &tdata->msgs[0 ]; + +if (put_user (nmsgs, &tdata->cmd.nmsgs) || +put_user (tmsgs, &tdata->cmd.msgs)) +return -EFAULT ; + +for (i =0 ; i < nmsgs; i++) { +if (copy_in_user (&tmsgs[i].addr, &umsgs[i].addr,3 *sizeof (u16))) +return -EFAULT ; +if (get_user (datap, &umsgs[i].buf) || +put_user (compat_ptr (datap), &tmsgs[i].buf)) +return -EFAULT ; + } +return i2cdev_ioctl (filp, cmd, (unsigned long )tdata); +} + +static int compat_i2c_smbus_ioctl (struct file *filp,unsigned int cmd, +struct i2c_smbus_ioctl_data32 __user *udata) +{ +struct i2c_smbus_ioctl_data __user *tdata; +compat_caddr_t datap; + + tdata =compat_alloc_user_space (sizeof (*tdata)); +if (tdata ==NULL ) +return -ENOMEM ; +if (!access_ok (VERIFY_WRITE , tdata,sizeof (*tdata))) +return -EFAULT ; + +if (!access_ok (VERIFY_READ , udata,sizeof (*udata))) +return -EFAULT ; + +if (__copy_in_user (&tdata->read_write, &udata->read_write,2 *sizeof (u8))) +return -EFAULT ; +if (__copy_in_user (&tdata->size, &udata->size,2 *sizeof (u32))) +return -EFAULT ; +if (__get_user (datap, &udata->data) || +__put_user (compat_ptr (datap), &tdata->data)) +return -EFAULT ; + +return i2cdev_ioctl (filp, cmd, (unsigned long )tdata); +} + +static int compat_i2c_funcs (struct file *filp,unsigned int cmd, +compat_ulong_t __user *argp) +{ +struct i2c_client *client = filp->private_data; +compat_ulong_t funcs; + funcs =i2c_get_functionality (client->adapter); +return put_user (funcs, argp); +} + +static long i2cdev_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) +{ +void __user *argp =compat_ptr (arg); + +switch (cmd) { +case I2C_FUNCS : +return compat_i2c_funcs (filp, cmd, argp); +case I2C_RDWR : +return compat_i2c_rdwr_ioctl (filp, cmd, argp); +case I2C_SMBUS : +return compat_i2c_smbus_ioctl (filp, cmd, argp); + } + +return i2cdev_ioctl (filp, cmd, arg); +} +#endif /* CONFIG_COMPAT */ +static int i2cdev_open (struct inode *inode,struct file *file) {unsigned int minor =iminor (inode);
@@ -501,6 +615,9 @@ static const struct file_operations i2cdev_fops = { .read = i2cdev_read, .write = i2cdev_write, .unlocked_ioctl = i2cdev_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = i2cdev_compat_ioctl, +#endif .open = i2cdev_open, .release = i2cdev_release, };
fs/compat_ioctl.c +0 -119
143 lines not on this page · raw message
Signature · 1 line
1.6.3.3
Re: [PATCH 07/12] i2cdev: move compat_ioctl handling into driver
Hi Arnd,
Quoted 9 lines · Arnd Bergmann
Doing all the
compat_ioctlhandling in the i2c driver itself removes special cases fromfs/compat_ioctl.cand makes it possible to optimize this case better.Signed-off-by Arnd Bergmann <[email protected]>Cc "Jean Delvare (PC drivers, core)" <[email protected]>Cc "Ben Dooks (embedded platforms)" <[email protected]>Cc Wolfram Sang <[email protected]>
Quoted 4 lines
--- drivers/i2c/i2c-dev.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/compat_ioctl.c | 119 ------------------------------------------------- 2 files changed, 117 insertions(+), 119 deletions(-)
This patch no longer applies so I can't test it. I do not have any objection about it though.
I'm also not sure what I am supposed to comment on. As far as I can see, most of this patch is merely moving code from one file to another, so there's little point in reviewing that code. Is there any part in particular which needs my attention?
If you want to test your patch yourself, it is fairly easy using the i2c-stub driver, which is a software-only i2c bus driver. Install the i2c-tools package on your system, and then:
# modprobe i2c-stub chip_addr=0x6d # modprobe i2c-dev # i2cdetect -l # i2cbus=$(i2cdetect -l | grep stub | cut -f1 | cut -d- -f2) # i2cdetect -F $i2cbus Functionalities implemented by /dev/i2c-x: I2C no SMBus Quick Command yes SMBus Send Byte yes SMBus Receive Byte yes SMBus Write Byte yes SMBus Read Byte yes SMBus Write Word yes SMBus Read Word yes SMBus Process Call no SMBus Block Write no SMBus Block Read no SMBus Block Process Call no SMBus PEC no I2C Block Write no I2C Block Read no # i2cset -y $i2cbus 0x6d 0x00 0x42 b Value 0x42 written, readback matched # i2cget -y $i2cbus 0x6d 0x00 b 0x42 #
The last 3 commands will generate i2c-dev ioctls.
Signature · 1 line
Jean Delvare
Arnd Bergmann
maintainerRe: [PATCH 07/12] i2cdev: move compat_ioctl handling into driver
Quoted 2 lines · Jean Delvare
This patch no longer applies so I can't test it. I do not have any objection about it though.
The patch is part of a longer series of patches moving code out of fs/compat_ioctl.c. If you want to test it, you can just apply the half adding it to i2c-dev.c and that version will be used.
That part has gained a trivial conflict against an #include cleanup.
Quoted 4 lines
I'm also not sure what I am supposed to comment on. As far as I can see, most of this patch is merely moving code from one file to another, so there's little point in reviewing that code. Is there any part in particular which needs my attention?
No, nothing particular. I was just running the whole series by the maintainers (or the closest approximation of that) in order to collect Acked-by and/or have people include the patches in their trees, especially the ones that I didn't have a test case for. The patches I got an Ack for were merged now, and I'll repost the rest after -rc1 to prepare them for the next merge window.
A good way to avoid conflicts would be if you take the i2c-dev.c parts into a tree of yours and let me follow up with removing the code from fs/compat_ioctl.c once your tree is merged.
If everyone does that, I can just remove half of fs/compat_ioctl.c at once.
Quoted 31 lines
If you want to test your patch yourself, it is fairly easy using the i2c-stub driver, which is a software-only i2c bus driver. Install the i2c-tools package on your system, and then:
# modprobe i2c-stub chip_addr=0x6d # modprobe i2c-dev # i2cdetect -l # i2cbus=$(i2cdetect -l | grep stub | cut -f1 | cut -d- -f2) # i2cdetect -F $i2cbus Functionalities implemented by /dev/i2c-x: I2C no SMBus Quick Command yes SMBus Send Byte yes SMBus Receive Byte yes SMBus Write Byte yes SMBus Read Byte yes SMBus Write Word yes SMBus Read Word yes SMBus Process Call no SMBus Block Write no SMBus Block Read no SMBus Block Process Call no SMBus PEC no I2C Block Write no I2C Block Read no # i2cset -y $i2cbus 0x6d 0x00 0x42 b Value 0x42 written, readback matched # i2cget -y $i2cbus 0x6d 0x00 b 0x42 #
Quoted 1 line
The last 3 commands will generate i2c-dev ioctls.
Ok, I'll try that, thanks!
Arnd <><
Re: [PATCH 07/12] i2cdev: move compat_ioctl handling into driver
Hi Arnd,
Quoted 9 lines · Arnd Bergmann
Quoted 2 lines · Jean Delvare
This patch no longer applies so I can't test it. I do not have any objection about it though.
The patch is part of a longer series of patches moving code out of
fs/compat_ioctl.c. If you want to test it, you can just apply the half adding it toi2c-dev.cand that version will be used.That part has gained a trivial conflict against an #include cleanup.
It was long ago, there are even more conflicts now.
Quoted 50 lines
Quoted 4 lines
I'm also not sure what I am supposed to comment on. As far as I can see, most of this patch is merely moving code from one file to another, so there's little point in reviewing that code. Is there any part in particular which needs my attention?
No, nothing particular. I was just running the whole series by the maintainers (or the closest approximation of that) in order to collect Acked-by and/or have people include the patches in their trees, especially the ones that I didn't have a test case for. The patches I got an Ack for were merged now, and I'll repost the rest after -rc1 to prepare them for the next merge window.
A good way to avoid conflicts would be if you take the
i2c-dev.cparts into a tree of yours and let me follow up with removing the code fromfs/compat_ioctl.conce your tree is merged.If everyone does that, I can just remove half of
fs/compat_ioctl.cat once.Quoted 31 lines
If you want to test your patch yourself, it is fairly easy using the i2c-stub driver, which is a software-only i2c bus driver. Install the i2c-tools package on your system, and then:
# modprobe i2c-stub chip_addr=0x6d # modprobe i2c-dev # i2cdetect -l # i2cbus=$(i2cdetect -l | grep stub | cut -f1 | cut -d- -f2) # i2cdetect -F $i2cbus Functionalities implemented by /dev/i2c-x: I2C no SMBus Quick Command yes SMBus Send Byte yes SMBus Receive Byte yes SMBus Write Byte yes SMBus Read Byte yes SMBus Write Word yes SMBus Read Word yes SMBus Process Call no SMBus Block Write no SMBus Block Read no SMBus Block Process Call no SMBus PEC no I2C Block Write no I2C Block Read no # i2cset -y $i2cbus 0x6d 0x00 0x42 b Value 0x42 written, readback matched # i2cget -y $i2cbus 0x6d 0x00 b 0x42 #
Quoted 3 lines
Quoted 1 line
The last 3 commands will generate i2c-dev ioctls.
Ok, I'll try that, thanks!
Were you able to perform your tests? What's the status of your patch? I can't do much without a patch which at least applies and builds.
Signature · 1 line
Jean Delvare
Arnd Bergmann
maintainerPATCH 8/12 md: move compat_ioctl handling into md.c
In reply to Arnd BergmannThe RAID ioctls are only implemented in md.c, so the handling for them should also be moved there from fs/compat_ioctl.c.
--- drivers/md/md.c | 23 +++++++++++++++++++++++ fs/compat_ioctl.c | 23 ----------------------- 2 files changed, 23 insertions(+), 23 deletions(-)
drivers/md/md.c +23 -0
@@ -44,6 +44,7 @@#include <linux/random.h> #include <linux/reboot.h> #include <linux/file.h> +#include <linux/compat.h> #include <linux/delay.h> #include <linux/raid/md_p.h> #include <linux/raid/md_u.h>
@@ -5503,6 +5504,25 @@ done: abort:return err; } +#ifdef CONFIG_COMPAT +static int md_compat_ioctl (struct block_device *bdev,fmode_t mode, +unsigned int cmd,unsigned long arg) +{ +switch (cmd) { +case HOT_REMOVE_DISK : +case HOT_ADD_DISK : +case SET_DISK_FAULTY : +case SET_BITMAP_FILE : +/* These take in integer arg, do not convert */ +break ; +default : + arg = (unsigned long )compat_ptr (arg); +break ; + } + +return md_ioctl (bdev, mode, cmd, arg); +} +#endif /* CONFIG_COMPAT */ static int md_open (struct block_device *bdev,fmode_t mode) {
@@ -5568,6 +5588,9 @@ static const struct block_device_operations md_fops = .open = md_open, .release = md_release, .ioctl = md_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = md_compat_ioctl, +#endif .getgeo = md_getgeo, .media_changed = md_media_changed, .revalidate_disk= md_revalidate,
fs/compat_ioctl.c +0 -23
@@ -837,24 +837,6 @@ COMPATIBLE_IOCTL(FIGETBSZ)/* 'X' - originally XFS but some now in the VFS */ COMPATIBLE_IOCTL(FIFREEZE) COMPATIBLE_IOCTL(FITHAW) -/* RAID */ -COMPATIBLE_IOCTL(RAID_VERSION) -COMPATIBLE_IOCTL(GET_ARRAY_INFO) -COMPATIBLE_IOCTL(GET_DISK_INFO) -COMPATIBLE_IOCTL(PRINT_RAID_DEBUG) -COMPATIBLE_IOCTL(RAID_AUTORUN) -COMPATIBLE_IOCTL(CLEAR_ARRAY) -COMPATIBLE_IOCTL(ADD_NEW_DISK) -COMPATIBLE_IOCTL(SET_ARRAY_INFO) -COMPATIBLE_IOCTL(SET_DISK_INFO) -COMPATIBLE_IOCTL(WRITE_RAID_INFO) -COMPATIBLE_IOCTL(UNPROTECT_ARRAY) -COMPATIBLE_IOCTL(PROTECT_ARRAY) -COMPATIBLE_IOCTL(RUN_ARRAY) -COMPATIBLE_IOCTL(STOP_ARRAY) -COMPATIBLE_IOCTL(STOP_ARRAY_RO) -COMPATIBLE_IOCTL(RESTART_ARRAY_RW) -COMPATIBLE_IOCTL(GET_BITMAP_FILE) COMPATIBLE_IOCTL(KDGETKEYCODE) COMPATIBLE_IOCTL(KDSETKEYCODE) COMPATIBLE_IOCTL(KDGKBTYPE)
@@ -1450,11 +1432,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,case TCSBRKP :case TIOCMIWAIT :case TIOCSCTTY : -/* RAID */ -case HOT_REMOVE_DISK : -case HOT_ADD_DISK : -case SET_DISK_FAULTY : -case SET_BITMAP_FILE :/* Big K */ case KDSIGACCEPT :case KIOCSOUND :
Signature · 1 line
1.6.3.3
Re: [PATCH 08/12] md: move compat_ioctl handling into md.c
Quoted 4 lines · Arnd Bergmann
The RAID ioctls are only implemented in
md.c, so the handling for them should also be moved there fromfs/compat_ioctl.c.
Quoted 8 lines
Signed-off-by Arnd Bergmann <[email protected]>Cc Neil Brown <[email protected]>Cc Andre Noll <[email protected]>--- drivers/md/md.c | 23 +++++++++++++++++++++++ fs/compat_ioctl.c | 23 ----------------------- 2 files changed, 23 insertions(+), 23 deletions(-)
Looks good to me.
Thanks
Andre
Signature · 1 line
The only person who always got his work done by Friday was Robinson Crusoe
Arnd Bergmann
maintainerPATCH 9/12 lp: move compat_ioctl handling into lp.c
In reply to Arnd BergmannHandling for LPSETTIMEOUT can easily be done in lp_ioctl, which is the only user. As a positive side-effect, push the BKL into the ioctl methods.
--- drivers/char/lp.c | 115 +++++++++++++++++++++++++++++++++++++++++------------ fs/compat_ioctl.c | 33 --------------- 2 files changed, 89 insertions(+), 59 deletions(-)
drivers/char/lp.c +89 -26
@@ -127,6 +127,7 @@#include <linux/wait.h> #include <linux/jiffies.h> #include <linux/smp_lock.h> +#include <linux/compat.h> #include <linux/parport.h> #undef LP_STATS
@@ -571,13 +572,11 @@ static int lp_release(struct inode * inode, struct file * file)return 0 ; } -static int lp_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static int lp_do_ioctl (unsigned int minor,unsigned int cmd, +unsigned long arg,void __user *argp) { -unsigned int minor =iminor (inode);int status;int retval =0 ; -void __user *argp = (void __user *)arg;#ifdef LP_DEBUG printk (KERN_DEBUG "lp%d ioctl, cmd: 0x%x, arg: 0x%lx\n" , minor, cmd, arg);
@@ -587,9 +586,6 @@ static int lp_ioctl(struct inode *inode, struct file *file,if ((LP_F (minor) &LP_EXIST ) ==0 )return -ENODEV ;switch ( cmd ) { -struct timeval par_timeout; -long to_jiffies; -case LPTIME :LP_TIME (minor) = arg *HZ /100 ;break ;
@@ -652,34 +648,101 @@ static int lp_ioctl(struct inode *inode, struct file *file,return -EFAULT ;break ; -case LPSETTIMEOUT : -if (copy_from_user (&par_timeout, argp, -sizeof (struct timeval ))) { -return -EFAULT ; - } -/* Convert to jiffies, place in lp_table */ -if ((par_timeout.tv_sec <0 ) || - (par_timeout.tv_usec <0 )) { -return -EINVAL ; - } - to_jiffies =DIV_ROUND_UP (par_timeout.tv_usec,1000000 /HZ ); - to_jiffies += par_timeout.tv_sec * (long )HZ ; -if (to_jiffies <=0 ) { -return -EINVAL ; - } - lp_table[minor].timeout = to_jiffies; -break ; -default : retval = -EINVAL ; }return retval; } +static int lp_set_timeout (unsigned int minor,struct timeval *par_timeout) +{ +long to_jiffies; + +/* Convert to jiffies, place in lp_table */ +if ((par_timeout->tv_sec <0 ) || + (par_timeout->tv_usec <0 )) { +return -EINVAL ; + } + to_jiffies =DIV_ROUND_UP (par_timeout->tv_usec,1000000 /HZ ); + to_jiffies += par_timeout->tv_sec * (long )HZ ; +if (to_jiffies <=0 ) { +return -EINVAL ; + } + lp_table[minor].timeout = to_jiffies; +return 0 ; +} + +static long lp_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +unsigned int minor; +struct timeval par_timeout; +int ret; + + minor =iminor (file->f_path.dentry->d_inode); +lock_kernel (); +switch (cmd) { +case LPSETTIMEOUT : +if (copy_from_user (&par_timeout, (void __user *)arg, +sizeof (struct timeval ))) { + ret = -EFAULT ; +break ; + } + ret =lp_set_timeout (minor, &par_timeout); +break ; +default : + ret =lp_do_ioctl (minor, cmd, arg, (void __user *)arg); +break ; + } +unlock_kernel (); + +return ret; +} + +#ifdef CONFIG_COMPAT +static long lp_compat_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +unsigned int minor; +struct timeval par_timeout; +struct compat_timeval __user *tc; +int ret; + + minor =iminor (file->f_path.dentry->d_inode); +lock_kernel (); +switch (cmd) { +case LPSETTIMEOUT : + tc =compat_ptr (arg); +if (get_user (par_timeout.tv_sec, &tc->tv_sec) || +get_user (par_timeout.tv_usec, &tc->tv_usec)) { + ret = -EFAULT ; +break ; + } + ret =lp_set_timeout (minor, &par_timeout); +break ; +#ifdef LP_STATS +case LPGETSTATS : +/* FIXME: add an implementation if you set LP_STATS */ + ret = -EINVAL ; +break ; +#endif +default : + ret =lp_do_ioctl (minor, cmd, arg,compat_ptr (arg)); +break ; + } +unlock_kernel (); + +return ret; +} +#endif +static const struct file_operations lp_fops = { .owner =THIS_MODULE , .write = lp_write, - .ioctl = lp_ioctl, + .unlocked_ioctl = lp_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = lp_compat_ioctl, +#endif .open = lp_open, .release = lp_release, #ifdef CONFIG_PARPORT_1284
fs/compat_ioctl.c +0 -33
@@ -709,20 +709,6 @@ static int rtc_ioctl(unsigned fd, unsigned cmd, void __user *argp)return -ENOIOCTLCMD ; } -static int -lp_timeout_trans (unsigned int fd,unsigned int cmd, -struct compat_timeval __user *tc) -{ -struct timeval __user *tn =compat_alloc_user_space (sizeof (struct timeval )); -struct timeval ts; -if (get_user (ts.tv_sec, &tc->tv_sec) || -get_user (ts.tv_usec, &tc->tv_usec) || -put_user (ts.tv_sec, &tn->tv_sec) || -put_user (ts.tv_usec, &tn->tv_usec)) -return -EFAULT ; -return sys_ioctl (fd, cmd, (unsigned long )tn); -} -/* on ia32 l_start is on a 32-bit boundary */ #if defined(CONFIG_IA64 ) || defined(CONFIG_X86_64 ) struct space_resv_32 {
@@ -937,8 +923,6 @@ COMPATIBLE_IOCTL(PPPIOCGCHAN)/* PPPOX */ COMPATIBLE_IOCTL(PPPOEIOCSFWD) COMPATIBLE_IOCTL(PPPOEIOCDFWD) -/* LP */ -COMPATIBLE_IOCTL(LPGETSTATUS) /* ppdev */ COMPATIBLE_IOCTL(PPSETMODE) COMPATIBLE_IOCTL(PPRSTATUS)
@@ -1326,19 +1310,6 @@ COMPATIBLE_IOCTL(TIOCSTOP)/* Usbdevfs */ COMPATIBLE_IOCTL (USBDEVFS_IOCTL32 ) -/* parport */ -COMPATIBLE_IOCTL(LPTIME) -COMPATIBLE_IOCTL(LPCHAR) -COMPATIBLE_IOCTL(LPABORTOPEN) -COMPATIBLE_IOCTL(LPCAREFUL) -COMPATIBLE_IOCTL(LPWAIT) -COMPATIBLE_IOCTL(LPSETIRQ) -COMPATIBLE_IOCTL(LPGETSTATUS) -COMPATIBLE_IOCTL(LPGETSTATUS) -COMPATIBLE_IOCTL(LPRESET) -/*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/ -COMPATIBLE_IOCTL(LPGETFLAGS) -/* fat 'r' ioctls. These are handled by fat with ->compat_ioctl, but we don't want warnings on other file systems. So declare them as compatible here. */
@@ -1417,10 +1388,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,return do_video_stillpicture (fd, cmd, argp);case VIDEO_SET_SPU_PALETTE :return do_video_set_spu_palette (fd, cmd, argp); - -/* lp */ -case LPSETTIMEOUT : -return lp_timeout_trans (fd, cmd, argp); }/*
Signature · 1 line
1.6.3.3
Re: [PATCH 09/12] lp: move compat_ioctl handling into lp.c
Quoted 6 lines · Arnd Bergmann
Handling for LPSETTIMEOUT can easily be done in
lp_ioctl, which is the only user. As a positive side-effect, push the BKL into the ioctl methods.Signed-off-by Arnd Bergmann <[email protected]>Cc Greg Kroah-Hartman <[email protected]>
Arnd Bergmann
maintainerPATCH 10/12 usbdevfs: move compat_ioctl handling to devio.c
In reply to Arnd BergmannHalf the compat_ioctl handling is in devio.c, the other half is in fs/compat_ioctl.c. This moves everything into one place for consistency.
As a positive side-effect, push down the BKL into the ioctl methods.
--- drivers/usb/core/devio.c | 110 ++++++++++++++++++++++++++++++++++++---- fs/compat_ioctl.c | 113 +----------------------------------------- include/linux/usbdevice_fs.h | 26 ++++++++++ 3 files changed, 126 insertions(+), 123 deletions(-)
drivers/usb/core/devio.c +99 -11
@@ -1388,6 +1388,46 @@ static int proc_reapurbnonblock(struct dev_state *ps, void __user *arg) }#ifdef CONFIG_COMPAT +static int proc_control_compat (struct dev_state *ps, +struct usbdevfs_ctrltransfer32 __user *p32) +{ +struct usbdevfs_ctrltransfer __user *p; +__u32 udata; + p =compat_alloc_user_space (sizeof (*p)); +if (copy_in_user (p, p32, (sizeof (*p32) -sizeof (compat_caddr_t))) || +get_user (udata, &p32->data) || +put_user (compat_ptr (udata), &p->data)) +return -EFAULT ; +return proc_control (ps, p); +} + +static int proc_bulk_compat (struct dev_state *ps, +struct usbdevfs_bulktransfer32 __user *p32) +{ +struct usbdevfs_bulktransfer __user *p; +compat_uint_t n; +compat_caddr_t addr; + + p =compat_alloc_user_space (sizeof (*p)); + +if (get_user (n, &p32->ep) ||put_user (n, &p->ep) || +get_user (n, &p32->len) ||put_user (n, &p->len) || +get_user (n, &p32->timeout) ||put_user (n, &p->timeout) || +get_user (addr, &p32->data) ||put_user (compat_ptr (addr), &p->data)) +return -EFAULT ; + +return proc_bulk (ps, p); +} +static int proc_disconnectsignal_compat (struct dev_state *ps,void __user *arg) +{ +struct usbdevfs_disconnectsignal32 ds; + +if (copy_from_user (&ds, arg,sizeof (ds))) +return -EFAULT ; + ps->discsignr = ds.signr; + ps->disccontext =compat_ptr (ds.context); +return 0 ; +}static int get_urb32 (struct usbdevfs_urb *kurb,struct usbdevfs_urb32 __user *uurb)
@@ -1482,6 +1522,7 @@ static int proc_reapurbnonblock_compat(struct dev_state *ps, void __user *arg) return processcompl_compat(as, (void __user * __user *)arg); } +#endif static int proc_disconnectsignal (struct dev_state *ps,void __user *arg)
@@ -1648,12 +1689,12 @@ static int proc_release_port(struct dev_state *ps, void __user *arg)* are assuming that somehow the configuration has been prevented from * changing. But there's no mechanism to ensure that... */ -static int usbdev_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long usbdev_do_ioctl (struct file *file,unsigned int cmd, +void __user *p) {struct dev_state *ps = file->private_data; +struct inode *inode = file->f_path.dentry->d_inode;struct usb_device *dev = ps->dev; -void __user *p = (void __user *)arg;int ret = -ENOTTY ;if (!(file->f_mode &FMODE_WRITE ))
@@ -1726,6 +1767,24 @@ static int usbdev_ioctl(struct inode *inode, struct file *file,break ;#ifdef CONFIG_COMPAT +case USBDEVFS_CONTROL32 : +snoop (&dev->dev,"%s: CONTROL32\n" , __func__); + ret =proc_control_compat (ps, p); +if (ret >=0 ) + inode->i_mtime =CURRENT_TIME ; +break ; + +case USBDEVFS_BULK32 : +snoop (&dev->dev,"%s: BULK32\n" , __func__); + ret =proc_bulk_compat (ps, p); +if (ret >=0 ) + inode->i_mtime =CURRENT_TIME ; +break ; + +case USBDEVFS_DISCSIGNAL32 : +snoop (&dev->dev,"%s: DISCSIGNAL32\n" , __func__); + ret =proc_disconnectsignal_compat (ps, p); +break ;case USBDEVFS_SUBMITURB32 :snoop (&dev->dev,"%s: SUBMITURB32\n" , __func__);
@@ -1745,7 +1804,7 @@ static int usbdev_ioctl(struct inode *inode, struct file *file,break ;case USBDEVFS_IOCTL32 : -snoop (&dev->dev,"%s: IOCTL\n" , __func__); +snoop (&dev->dev,"%s: IOCTL32\n" , __func__); ret =proc_ioctl_compat (ps,ptr_to_compat (p));break ;#endif
@@ -1801,6 +1860,32 @@ static int usbdev_ioctl(struct inode *inode, struct file *file,return ret; } +static long usbdev_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +int ret; + +lock_kernel (); + ret =usbdev_do_ioctl (file, cmd, (void __user *)arg); +unlock_kernel (); + +return ret; +} + +#ifdef CONFIG_COMPAT +static long usbdev_compat_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +int ret; + +lock_kernel (); + ret =usbdev_do_ioctl (file, cmd,compat_ptr (arg)); +unlock_kernel (); + +return ret; +} +#endif +/* No kernel lock - fine */ static unsigned int usbdev_poll (struct file *file,struct poll_table_struct *wait)
@@ -1817,13 +1902,16 @@ static unsigned int usbdev_poll(struct file *file, }const struct file_operations usbdev_file_operations = { - .owner =THIS_MODULE , - .llseek = usbdev_lseek, - .read = usbdev_read, - .poll = usbdev_poll, - .ioctl = usbdev_ioctl, - .open = usbdev_open, - .release = usbdev_release, + .owner =THIS_MODULE , + .llseek = usbdev_lseek, + .read = usbdev_read, + .poll = usbdev_poll, + .unlocked_ioctl = usbdev_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = usbdev_compat_ioctl, +#endif + .open = usbdev_open, + .release = usbdev_release, };static void usbdev_remove (struct usb_device *udev)
fs/compat_ioctl.c +1 -112
137 lines not on this page · raw message
include/linux/usbdevice_fs.h +26 -0
@@ -128,6 +128,29 @@ struct usbdevfs_hub_portinfo { #ifdef __KERNEL__ #ifdef CONFIG_COMPAT #include <linux/compat.h> + +struct usbdevfs_ctrltransfer32 { + u8 bRequestType; + u8 bRequest; + u16 wValue; + u16 wIndex; + u16 wLength; + u32 timeout; /* in milliseconds */ + compat_caddr_t data; +}; + +struct usbdevfs_bulktransfer32 { + compat_uint_t ep; + compat_uint_t len; + compat_uint_t timeout; /* in milliseconds */ + compat_caddr_t data; +}; + +struct usbdevfs_disconnectsignal32 { + compat_int_t signr; + compat_caddr_t context; +}; + struct usbdevfs_urb32 { unsigned char type; unsigned char endpoint;
@@ -153,7 +176,9 @@ struct usbdevfs_ioctl32 {#endif /* __KERNEL__ */ #define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer) +#define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)#define USBDEVFS_BULK _IOWR('U', 2, struct usbdevfs_bulktransfer) +#define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)#define USBDEVFS_RESETEP _IOR('U', 3, unsigned int)#define USBDEVFS_SETINTERFACE _IOR('U', 4, struct usbdevfs_setinterface)#define USBDEVFS_SETCONFIGURATION _IOR('U', 5, unsigned int)
@@ -166,6 +191,7 @@ struct usbdevfs_ioctl32 {#define USBDEVFS_REAPURBNDELAY _IOW('U', 13, void *)#define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, __u32)#define USBDEVFS_DISCSIGNAL _IOR('U', 14, struct usbdevfs_disconnectsignal) +#define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)#define USBDEVFS_CLAIMINTERFACE _IOR('U', 15, unsigned int)#define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int)#define USBDEVFS_CONNECTINFO _IOW('U', 17, struct usbdevfs_connectinfo)
Signature · 1 line
1.6.3.3
Re: [PATCH 10/12] usbdevfs: move compat_ioctl handling to devio.c
Quoted 7 lines · Arnd Bergmann
Half the
compat_ioctlhandling is indevio.c, the other half is infs/compat_ioctl.c. This moves everything into one place for consistency.As a positive side-effect, push down the BKL into the ioctl methods.
Quoted 7 lines
Signed-off-by Arnd Bergmann <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Alan Stern <[email protected]>Cc Oliver Neukum <[email protected]>Cc Alon Bar-Lev <[email protected]>Cc David Vrabel <[email protected]>
thanks for doing this.
greg k-h
Arnd Bergmann
maintainerPATCH 11/12 hamradio/mkiss: fix typo in compat_ioctl
In reply to Arnd BergmannMy last commit introduced an typo causing the compat_ioctl function to do nothing useful. The obvious way for an ioctl function to work is to look at the command, not the argument first.
--- drivers/net/hamradio/mkiss.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/hamradio/mkiss.c +1 -1
@@ -903,7 +903,7 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file,static long mkiss_compat_ioctl (struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned long arg) { -switch (arg) { +switch (cmd) {case SIOCGIFNAME :case SIOCGIFENCAP :case SIOCSIFENCAP :
Signature · 1 line
1.6.3.3
Re: [PATCH 11/12] hamradio/mkiss: fix typo in compat_ioctl
From: Arnd Bergmann <[email protected]>
Date: Mon, 16 Nov 2009 00:27:06 +0000
Quoted 6 lines
My last commit introduced an typo causing the
compat_ioctlfunction to do nothing useful. The obvious way for an ioctl function to work is to look at the command, not the argument first.Signed-off-by Arnd Bergmann <[email protected]>
Applied, but please CC: netdev on all networking patches so that they get properly tracked in patchwork.
Thanks.
Arnd Bergmann
maintainerPATCH 12/12 compat_ioctl: remove unused handlers
In reply to Arnd BergmannThese handlers were moved into the respective drivers and can now be deleted from common code.
--- fs/compat_ioctl.c | 26 -------------------------- 1 files changed, 0 insertions(+), 26 deletions(-)
fs/compat_ioctl.c +0 -26
@@ -735,21 +735,6 @@ COMPATIBLE_IOCTL(FIGETBSZ)/* 'X' - originally XFS but some now in the VFS */ COMPATIBLE_IOCTL(FIFREEZE) COMPATIBLE_IOCTL(FITHAW) -COMPATIBLE_IOCTL(KDGETKEYCODE) -COMPATIBLE_IOCTL(KDSETKEYCODE) -COMPATIBLE_IOCTL(KDGKBTYPE) -COMPATIBLE_IOCTL(KDGETMODE) -COMPATIBLE_IOCTL(KDGKBMODE) -COMPATIBLE_IOCTL(KDGKBMETA) -COMPATIBLE_IOCTL(KDGKBENT) -COMPATIBLE_IOCTL(KDSKBENT) -COMPATIBLE_IOCTL(KDGKBSENT) -COMPATIBLE_IOCTL(KDSKBSENT) -COMPATIBLE_IOCTL(KDGKBDIACR) -COMPATIBLE_IOCTL(KDSKBDIACR) -COMPATIBLE_IOCTL(KDKBDREP) -COMPATIBLE_IOCTL(KDGKBLED) -COMPATIBLE_IOCTL(KDGETLED) #ifdef CONFIG_BLOCK /* Big S */ COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
@@ -1277,26 +1262,15 @@ static long do_ioctl_trans(int fd, unsigned int cmd,return do_video_stillpicture (fd, cmd, argp);case VIDEO_SET_SPU_PALETTE :return do_video_set_spu_palette (fd, cmd, argp); - }/* * These take an integer instead of a pointer as 'arg', * so we must not do a compat_ptr() translation. */ -switch (cmd) {/* Big T */ case TCSBRKP :case TIOCMIWAIT :case TIOCSCTTY : -/* Big K */ -case KDSIGACCEPT : -case KIOCSOUND : -case KDMKTONE : -case KDSETMODE : -case KDSKBMODE : -case KDSKBMETA : -case KDSKBLED : -case KDSETLED :return do_vfs_ioctl (file, fd, cmd, arg); }
Signature · 1 line
1.6.3.3
Quoted 11 lines · On Mon, 16 Nov 2009 00:26:55 +0000 Arnd Bergmann <[email protected]> wrote:
This is the second series of patches on
compat_ioctlhandling, moving compat handlers into more drivers. Most of these patches consist on a part that adds acompat_ioctlmethod in one driver and another part removing the respective section fromfs/compat_ioctl.c. Thefs/compat_ioctl.cportion depends on other patches[1], but the driver code can be applied independently.If some of you feel responsible for the code I patched, please look at my changes and if they are ok, either take them into your tree or give me an Acked-by for them.
I would take the md ones into my tree, but I suspect that if everyone did that we would end up with lots of conflicts in fs/compat_ioctl.c.
So how about I just take the changes to md.c, and give you an:
for the changes to fs/compat_ioctl.c
??
NeilBrown
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
Arnd Bergmann
maintainerQuoted 10 lines · Neil Brown
I would take the md ones into my tree, but I suspect that if everyone did that we would end up with lots of conflicts in
fs/compat_ioctl.c.So how about I just take the changes to
md.c, and give you an:Acked-by NeilBrown <[email protected]>for the changes to
fs/compat_ioctl.c
??
Yes, that is exactly what I was trying to suggest. Thanks,
Arnd <><
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july