Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 108515
b: refs/heads/master
c: f2afa77
h: refs/heads/master
i:
  108513: e77750b
  108511: e87772a
v: v3
  • Loading branch information
Dmitry Torokhov committed Aug 8, 2008
1 parent 4932511 commit a1063da
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5402a7349d26875f69c184badf87b88541b1cf6c
refs/heads/master: f2afa7711f8585ffc088ba538b9a510e0d5dca12
21 changes: 20 additions & 1 deletion trunk/drivers/input/evdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,10 @@ static int str_to_user(const char *str, unsigned int maxlen, void __user *p)
return copy_to_user(p, str, len) ? -EFAULT : len;
}

#define OLD_KEY_MAX 0x1ff
static int handle_eviocgbit(struct input_dev *dev, unsigned int cmd, void __user *p, int compat_mode)
{
static unsigned long keymax_warn_time;
unsigned long *bits;
int len;

Expand All @@ -665,9 +667,26 @@ static int handle_eviocgbit(struct input_dev *dev, unsigned int cmd, void __user
case EV_SW: bits = dev->swbit; len = SW_MAX; break;
default: return -EINVAL;
}

/*
* Work around bugs in userspace programs that like to do
* EVIOCGBIT(EV_KEY, KEY_MAX) and not realize that 'len'
* should be in bytes, not in bits.
*/
if ((_IOC_NR(cmd) & EV_MAX) == EV_KEY && _IOC_SIZE(cmd) == OLD_KEY_MAX) {
len = OLD_KEY_MAX;
if (printk_timed_ratelimit(&keymax_warn_time, 10 * 1000))
printk(KERN_WARNING
"evdev.c(EVIOCGBIT): Suspicious buffer size %d, "
"limiting output to %d bytes. See "
"http://userweb.kernel.org/~dtor/eviocgbit-bug.html\n",
OLD_KEY_MAX,
BITS_TO_LONGS(OLD_KEY_MAX) * sizeof(long));
}

return bits_to_user(bits, len, _IOC_SIZE(cmd), p, compat_mode);
}

#undef OLD_KEY_MAX

static long evdev_do_ioctl(struct file *file, unsigned int cmd,
void __user *p, int compat_mode)
Expand Down

0 comments on commit a1063da

Please sign in to comment.