[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200406130155.GB29306@infradead.org>
Date: Mon, 6 Apr 2020 06:01:55 -0700
From: Christoph Hellwig <hch@...radead.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org, jroedel@...e.de,
vbabka@...e.cz, urezki@...il.com,
Thomas Gleixner <tglx@...utronix.de>,
Olof Johansson <olof@...om.net>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>
Subject: Re: [PATCH] mm/vmalloc: Sanitize __get_vm_area() arguments
On Fri, Apr 03, 2020 at 06:32:53PM +0200, Peter Zijlstra wrote:
>
> __get_vm_area() is an exported symbol, make sure the callers stay in
> the expected memory range. When calling this function with memory
> ranges outside of the VMALLOC range *bad* things can happen.
>
> (I noticed this when I managed to corrupt the kernel text by accident)
Maybe it is time to unexport it? There are only two users:
- staging/media/ipu3 really should be using vmap. And given that it
is a staging driver it really doesn't matter anyway if we break it.
- pcmcia/electra_cf.c is actually using it for something that is not
a vmalloc address. But it is so special that I think prohibiting
to build it as module seems fine.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> ---
> mm/vmalloc.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2130,6 +2130,13 @@ static struct vm_struct *__get_vm_area_n
> struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
> unsigned long start, unsigned long end)
> {
> + /*
> + * Ensure callers stay in the vmalloc range.
> + */
> + if (WARN_ON(start < VMALLOC_START || start > VMALLOC_END ||
> + end < VMALLOC_START || end > VMALLOC_END))
> + return NULL;
> +
> return __get_vm_area_node(size, 1, flags, start, end, NUMA_NO_NODE,
> GFP_KERNEL, __builtin_return_address(0));
> }
---end quoted text---
Powered by blists - more mailing lists