mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
stm class: Prevent user-controllable allocations
[ Upstream commit f08b18266c ]
Currently, the character device write method allocates a temporary buffer
for user's data, but the user's data size is not sanitized and can cause
arbitrarily large allocations via kzalloc() or an integer overflow that
will then result in overwriting kernel memory.
This patch trims the input buffer size to avoid these issues.
Reported-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
30e94dc24e
commit
ffb2f3f86b
@@ -410,6 +410,9 @@ static ssize_t stm_char_write(struct file *file, const char __user *buf,
|
||||
char *kbuf;
|
||||
int err;
|
||||
|
||||
if (count + 1 > PAGE_SIZE)
|
||||
count = PAGE_SIZE - 1;
|
||||
|
||||
/*
|
||||
* if no m/c have been assigned to this writer up to this
|
||||
* point, use "default" policy entry
|
||||
|
||||
Reference in New Issue
Block a user