mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-11 13:27:06 +09:00
ANDROID: keychord: Check for write data size
keychord driver causes a kernel warning when writing more than (1 << (MAX_ORDER - 1)) * PAGE_SIZE bytes to /dev/keychord. In reality writes to this file should be much smaller, so limiting data size to PAGE_SIZE seems to be appropriate. This change checks write data size and if it's more than PAGE_SIZE causes write to fail. Bug: 73962978 Change-Id: I8a064a396d4259ffca924fa35d80e9700c4f8d79 Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
@@ -276,7 +276,7 @@ static ssize_t keychord_write(struct file *file, const char __user *buffer,
|
||||
size_t resid = count;
|
||||
size_t key_bytes;
|
||||
|
||||
if (count < sizeof(struct input_keychord))
|
||||
if (count < sizeof(struct input_keychord) || count > PAGE_SIZE)
|
||||
return -EINVAL;
|
||||
keychords = kzalloc(count, GFP_KERNEL);
|
||||
if (!keychords)
|
||||
|
||||
Reference in New Issue
Block a user