[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdUEmfOUT8xLZgH+i57uKA4TvYt_8DoDk4_3HbedFKY10A@mail.gmail.com>
Date: Mon, 6 May 2013 08:59:39 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Christoph Lameter <cl@...ux.com>
Cc: Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
glommer@...allels.com, Pekka Enberg <penberg@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [linux-next-20130422] Bug in SLAB?
On Fri, May 3, 2013 at 5:43 PM, Christoph Lameter <cl@...ux.com> wrote:
> Subject: slab: Return NULL for oversized allocations
>
> The inline path seems to have changed the SLAB behavior for very large
> kmalloc allocations. This patch restores the old behavior but also
> adds diagnostics so that we can figure where in the code these
> large allocations occur.
>
> Signed-off-by: Christoph Lameter <cl@...ux.com>
>
>
> Index: linux/include/linux/slab_def.h
> ===================================================================
> --- linux.orig/include/linux/slab_def.h 2013-05-03 10:36:46.019564801 -0500
> +++ linux/include/linux/slab_def.h 2013-05-03 10:37:28.860302188 -0500
> @@ -126,6 +126,11 @@ static __always_inline void *kmalloc(siz
> if (!size)
> return ZERO_SIZE_PTR;
>
> + if (size > KMALLOC_MAX_SIZE) {
> + WARN_ON(1);
As we were worried about this being triggered frm userspace, this needs
some rate limiting, to avoid flooding the kernel logs.
> + return NULL;
> + }
> +
> i = kmalloc_index(size);
>
> #ifdef CONFIG_ZONE_DMA
> @@ -172,6 +177,11 @@ static __always_inline void *kmalloc_nod
> if (!size)
> return ZERO_SIZE_PTR;
>
> + if (size > KMALLOC_MAX_SIZE) {
> + WARN_ON(1);
Idem ditto.
> + return NULL;
> + }
> +
> i = kmalloc_index(size);
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists