mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* + proc-avoid-mixing-integer-types-in-mem_rw.patch added to -mm tree
@ 2021-05-12 21:38 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2021-05-12 21:38 UTC (permalink / raw)
  To: adobriyan, cascardo, christian.brauner, ddiss, deller, lstoakes,
	marcelo.cerri, mm-commits, oleg, walken


The patch titled
     Subject: proc: Avoid mixing integer types in mem_rw()
has been added to the -mm tree.  Its filename is
     proc-avoid-mixing-integer-types-in-mem_rw.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/proc-avoid-mixing-integer-types-in-mem_rw.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/proc-avoid-mixing-integer-types-in-mem_rw.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
Subject: proc: Avoid mixing integer types in mem_rw()

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@suse.de>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Souza Cascardo <cascardo@canonical.com>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Lorenzo Stoakes <lstoakes@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/proc/base.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/proc/base.c~proc-avoid-mixing-integer-types-in-mem_rw
+++ a/fs/proc/base.c
@@ -854,7 +854,7 @@ static ssize_t mem_rw(struct file *file,
 	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;
_

Patches currently in -mm which might be from marcelo.cerri@canonical.com are

proc-avoid-mixing-integer-types-in-mem_rw.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-12 22:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12 21:38 + proc-avoid-mixing-integer-types-in-mem_rw.patch added to -mm tree akpm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).