mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-11-30 15:53:22 -05:00
proc: Avoid mixing integer types in mem_rw()
[ Upstream commit d238692b4b9f2c36e35af4c6e6f6da36184aeb3e ] Use size_t when capping the count argument received by mem_rw(). Since count is size_t, using min_t(int, ...) can lead to a negative value that will later be passed to access_remote_vm(), which can cause unexpected behavior. Since we are capping the value to at maximum PAGE_SIZE, the conversion from size_t to int when passing it to access_remote_vm() as "len" shouldn't be a problem. Link: https://lkml.kernel.org/r/[email protected] Reviewed-by: David Disseldorp <[email protected]> Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]> Signed-off-by: Marcelo Henrique Cerri <[email protected]> Cc: Alexey Dobriyan <[email protected]> Cc: Souza Cascardo <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Michel Lespinasse <[email protected]> Cc: Helge Deller <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
This commit is contained in:
parent
b71a75209f
commit
f323809e31
1 changed files with 1 additions and 1 deletions
|
|
@ -836,7 +836,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
|
|||
flags = FOLL_FORCE | (write ? FOLL_WRITE : 0);
|
||||
|
||||
while (count > 0) {
|
||||
int this_len = min_t(int, count, PAGE_SIZE);
|
||||
size_t this_len = min_t(size_t, count, PAGE_SIZE);
|
||||
|
||||
if (write && copy_from_user(page, buf, this_len)) {
|
||||
copied = -EFAULT;
|
||||
|
|
|
|||
Loading…
Reference in a new issue