Thread (18 messages) 18 messages, 4 authors, 2021-07-30

Re: [PATCH v5 0/6] compat: remove compat_alloc_user_space

From: Arnd Bergmann <arnd@kernel.org>
Date: 2021-07-30 13:36:32
Also in: linux-api, linux-arch, linux-arm-kernel, linux-mips, linux-mm, linux-s390, lkml, sparclinux
Subsystem: memory management, memory management - memory policy and migration, the rest · Maintainers: Andrew Morton, David Hildenbrand, Linus Torvalds

On Fri, Jul 30, 2021 at 11:49 AM Heiko Carstens [off-list ref] wrote:
On Tue, Jul 27, 2021 at 04:48:53PM +0200, Arnd Bergmann wrote:

Our CI reports this with linux-next and running strace selftest in
compat mode:
Thanks a lot for the report! I managed track it down based on your
output, it turns out that I end up copying data from the stack according
to how much the user asked for, and in this case that was much more
than the 8 byte nodemask_t, copying all of the kernel stack all the
way into the guard page with CONFIG_VMAP_STACK, where it
crashed. Without CONFIG_VMAP_STACK, or with user space that
asks for less data, it would just be an information leak, so others
probably haven't noticed the problem.

The change below should fix that, I'll double-check the other callers
as well before sending a proper fixup patch to Andrew.

        Arnd
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 4fabf2dddbc0..0d1f3be32723 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1438,6 +1438,7 @@ static int copy_nodes_to_user(unsigned long
__user *mask, unsigned long maxnode,
                if (clear_user((char __user *)mask + nbytes, copy - nbytes))
                        return -EFAULT;
                copy = nbytes;
+               maxnode = nr_node_ids;
        }

        if (compat)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help