[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210726153850.880812722@linuxfoundation.org>
Date: Mon, 26 Jul 2021 17:38:54 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, David Disseldorp <ddiss@...e.de>,
Thadeu Lima de Souza Cascardo <cascardo@...onical.com>,
Marcelo Henrique Cerri <marcelo.cerri@...onical.com>,
Alexey Dobriyan <adobriyan@...il.com>,
Christian Brauner <christian.brauner@...ntu.com>,
Michel Lespinasse <walken@...gle.com>,
Helge Deller <deller@....de>, Oleg Nesterov <oleg@...hat.com>,
Lorenzo Stoakes <lstoakes@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 5.13 142/223] proc: Avoid mixing integer types in mem_rw()
From: Marcelo Henrique Cerri <marcelo.cerri@...onical.com>
[ 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/20210512125215.3348316-1-marcelo.cerri@canonical.com
Reviewed-by: David Disseldorp <ddiss@...e.de>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@...onical.com>
Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@...onical.com>
Cc: Alexey Dobriyan <adobriyan@...il.com>
Cc: Souza Cascardo <cascardo@...onical.com>
Cc: Christian Brauner <christian.brauner@...ntu.com>
Cc: Michel Lespinasse <walken@...gle.com>
Cc: Helge Deller <deller@....de>
Cc: Oleg Nesterov <oleg@...hat.com>
Cc: Lorenzo Stoakes <lstoakes@...il.com>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
fs/proc/base.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 9cbd915025ad..a0a2fc1c9da2 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -854,7 +854,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;
--
2.30.2
Powered by blists - more mailing lists