Skip to content

Commit 99d3bf5

Browse files
Tetsuo Handatorvalds
authored andcommitted
Input: MT - limit max slots
syzbot is reporting too large allocation at input_mt_init_slots(), for num_slots is supplied from userspace using ioctl(UI_DEV_CREATE). Since nobody knows possible max slots, this patch chose 1024. Reported-by: syzbot <[email protected]> Closes: https://syzkaller.appspot.com/bug?extid=0122fa359a69694395d5 Suggested-by: Dmitry Torokhov <[email protected]> Signed-off-by: Tetsuo Handa <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 3894840 commit 99d3bf5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/input/input-mt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots,
4646
return 0;
4747
if (mt)
4848
return mt->num_slots != num_slots ? -EINVAL : 0;
49+
/* Arbitrary limit for avoiding too large memory allocation. */
50+
if (num_slots > 1024)
51+
return -EINVAL;
4952

5053
mt = kzalloc(struct_size(mt, slots, num_slots), GFP_KERNEL);
5154
if (!mt)

0 commit comments

Comments
 (0)