diff --git a/include/uapi/linux/rfkill.h b/include/uapi/linux/rfkill.h index db6c8588c1d0..9b77cfc42efa 100644 --- a/include/uapi/linux/rfkill.h +++ b/include/uapi/linux/rfkill.h @@ -159,16 +159,8 @@ struct rfkill_event_ext { * old behaviour for all userspace, unless it explicitly opts in to the * rules outlined here by using the new &struct rfkill_event_ext. * - * Additionally, some other userspace (bluez, g-s-d) was reading with a - * large size but as streaming reads rather than message-based, or with - * too strict checks for the returned size. So eventually, we completely - * reverted this, and extended messages need to be opted in to by using - * an ioctl: - * - * ioctl(fd, RFKILL_IOCTL_MAX_SIZE, sizeof(struct rfkill_event_ext)); - * - * Userspace using &struct rfkill_event_ext and the ioctl must adhere to - * the following rules: + * Userspace using &struct rfkill_event_ext must adhere to the following + * rules * * 1. accept short writes, optionally using them to detect that it's * running on an older kernel; @@ -183,8 +175,6 @@ struct rfkill_event_ext { #define RFKILL_IOC_MAGIC 'R' #define RFKILL_IOC_NOINPUT 1 #define RFKILL_IOCTL_NOINPUT _IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT) -#define RFKILL_IOC_MAX_SIZE 2 -#define RFKILL_IOCTL_MAX_SIZE _IOW(RFKILL_IOC_MAGIC, RFKILL_IOC_MAX_SIZE, __u32) /* and that's all userspace gets */ diff --git a/net/rfkill/core.c b/net/rfkill/core.c index c3feb4f49d09..4a18bc7142dd 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c @@ -79,7 +79,6 @@ struct rfkill_data { struct mutex mtx; wait_queue_head_t read_wait; bool input_handler; - u8 max_size; }; @@ -1173,8 +1172,6 @@ static int rfkill_fop_open(struct inode *inode, struct file *file) if (!data) return -ENOMEM; - data->max_size = RFKILL_EVENT_SIZE_V1; - INIT_LIST_HEAD(&data->events); mutex_init(&data->mtx); init_waitqueue_head(&data->read_wait); @@ -1257,7 +1254,6 @@ static ssize_t rfkill_fop_read(struct file *file, char __user *buf, list); sz = min_t(unsigned long, sizeof(ev->ev), count); - sz = min_t(unsigned long, sz, data->max_size); ret = sz; if (copy_to_user(buf, &ev->ev, sz)) ret = -EFAULT; @@ -1272,7 +1268,6 @@ static ssize_t rfkill_fop_read(struct file *file, char __user *buf, static ssize_t rfkill_fop_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { - struct rfkill_data *data = file->private_data; struct rfkill *rfkill; struct rfkill_event_ext ev; int ret; @@ -1287,7 +1282,6 @@ static ssize_t rfkill_fop_write(struct file *file, const char __user *buf, * our API version even in a write() call, if it cares. */ count = min(count, sizeof(ev)); - count = min_t(size_t, count, data->max_size); if (copy_from_user(&ev, buf, count)) return -EFAULT; @@ -1347,47 +1341,31 @@ static int rfkill_fop_release(struct inode *inode, struct file *file) return 0; } +#ifdef CONFIG_RFKILL_INPUT static long rfkill_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct rfkill_data *data = file->private_data; - int ret = -ENOTTY; - u32 size; if (_IOC_TYPE(cmd) != RFKILL_IOC_MAGIC) return -ENOTTY; + if (_IOC_NR(cmd) != RFKILL_IOC_NOINPUT) + return -ENOSYS; + mutex_lock(&data->mtx); - switch (_IOC_NR(cmd)) { -#ifdef CONFIG_RFKILL_INPUT - case RFKILL_IOC_NOINPUT: - if (!data->input_handler) { - if (atomic_inc_return(&rfkill_input_disabled) == 1) - printk(KERN_DEBUG "rfkill: input handler disabled\n"); - data->input_handler = true; - } - ret = 0; - break; -#endif - case RFKILL_IOC_MAX_SIZE: - if (get_user(size, (__u32 __user *)arg)) { - ret = -EFAULT; - break; - } - if (size < RFKILL_EVENT_SIZE_V1 || size > U8_MAX) { - ret = -EINVAL; - break; - } - data->max_size = size; - ret = 0; - break; - default: - break; + + if (!data->input_handler) { + if (atomic_inc_return(&rfkill_input_disabled) == 1) + printk(KERN_DEBUG "rfkill: input handler disabled\n"); + data->input_handler = true; } + mutex_unlock(&data->mtx); - return ret; + return 0; } +#endif static const struct file_operations rfkill_fops = { .owner = THIS_MODULE, @@ -1396,8 +1374,10 @@ static const struct file_operations rfkill_fops = { .write = rfkill_fop_write, .poll = rfkill_fop_poll, .release = rfkill_fop_release, +#ifdef CONFIG_RFKILL_INPUT .unlocked_ioctl = rfkill_fop_ioctl, .compat_ioctl = compat_ptr_ioctl, +#endif .llseek = no_llseek, };