diff options
author | Alexander Shishkin <alexander.shishkin@linux.intel.com> | 2015-12-22 17:25:21 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-02-07 22:43:17 -0800 |
commit | f08b18266c7116e2ec6885dd53a928f580060a71 (patch) | |
tree | 90487bb127914a64084190520a3517f1d5137150 /drivers/hwtracing | |
parent | 7b3bb0e75395b2f3b0f95d9ae50581e989ba5e4c (diff) | |
download | lwn-f08b18266c7116e2ec6885dd53a928f580060a71.tar.gz lwn-f08b18266c7116e2ec6885dd53a928f580060a71.zip |
stm class: Prevent user-controllable allocations
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>
Diffstat (limited to 'drivers/hwtracing')
-rw-r--r-- | drivers/hwtracing/stm/core.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c index 40a8b79ab7db..aef8ddb24451 100644 --- a/drivers/hwtracing/stm/core.c +++ b/drivers/hwtracing/stm/core.c @@ -406,6 +406,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 |