All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: cl@linux.com, glommer@parallels.com
Cc: penberg@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [linux-next-20130422] Bug in SLAB?
Date: Tue, 30 Apr 2013 01:16:17 +0900	[thread overview]
Message-ID: <201304300116.FGJ56210.FMSOJHFOtFQVOL@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <201304300028.IAD13051.OHOVMJSLFFFQOt@I-love.SAKURA.ne.jp>

Tetsuo Handa wrote:
> Glauber Costa wrote:
> > If I am right, the following (untested) patch should solve the problem.
> 
> This patch did not help;
> 
>   kmalloc(8 * 1024 * 1024, GFP_KERNEL)
> 
> still causes both
> 
>   include/linux/slab_def.h:136: warning: array subscript is above array bounds
> 
> and
> 
>   BUG: unable to handle kernel NULL pointer dereference at 00000058
>   IP: [<c10b9d76>] kmem_cache_alloc+0x26/0xb0
> 
> .

I copied this patch (which modifies "static __always_inline void *kmalloc_node
(size_t size, gfp_t flags, int node)") to "static __always_inline void *kmalloc
(size_t size, gfp_t flags)", but it didn't help.

-------- test cases --------
        volatile unsigned int size = 0;
        void *ptr = kmalloc(size, GFP_KERNEL);
        printk("kmalloc(0)=%p\n", ptr);
        kfree(ptr);
        for (size = 1; size <= 256 * 1024 * 1024; size *= 2) {
                ptr = kmalloc(size, GFP_KERNEL);
                printk("kmalloc(%u)=%p\n", size, ptr);
                kfree(ptr);
        }
-------- test cases --------

kmalloc(0)=00000010
kmalloc(1)=de7eb840
kmalloc(2)=de7eb840
kmalloc(4)=de7eb840
kmalloc(8)=de7eb840
kmalloc(16)=de7eb840
kmalloc(32)=de7eb840
kmalloc(64)=de28ae40
kmalloc(128)=de5ba140
kmalloc(256)=de69e180
kmalloc(512)=dea14600
kmalloc(1024)=de522400
kmalloc(2048)=de1e4000
kmalloc(4096)=de9b3000
kmalloc(8192)=de24a000
kmalloc(16384)=de444000
kmalloc(32768)=de9b8000
kmalloc(65536)=dea20000
kmalloc(131072)=de980000
kmalloc(262144)=deb00000
kmalloc(524288)=dea80000
kmalloc(1048576)=de800000
kmalloc(2097152)=dde00000
kmalloc(4194304)=d5800000
kmalloc(8388608)=  (null)
kmalloc(16777216)=  (null)

Got BUG() at 32 * 1024 * 1024 bytes.

  Kernel BUG at c10b9c9b [verbose debug info unavailable]
  invalid opcode: 0000 [#1] SMP

There still seems to be a bug in the non-constant case.



> Christoph Lameter wrote:
> > What is MAX_ORDER on the architecture?
> 
> In my environment (x86_32), the constants are
> 
>   MAX_ORDER=11 PAGE_SHIFT=12 KMALLOC_SHIFT_HIGH=22 KMALLOC_MAX_SIZE=4194304
> 

I don't know if any, but on an architecture with PAGE_SHIFT + MAX_ORDER > 26,

  static void init_node_lock_keys(int q)
  {
          int i;
  
          if (slab_state < UP)
                  return;
  
          for (i = 1; i < PAGE_SHIFT + MAX_ORDER; i++) {
                  struct kmem_cache_node *n;
                  struct kmem_cache *cache = kmalloc_caches[i];

looks like out of bounds access due to

  #define KMALLOC_SHIFT_HIGH      ((MAX_ORDER + PAGE_SHIFT - 1) <= 25 ? \
                                  (MAX_ORDER + PAGE_SHIFT - 1) : 25)

and

  struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];

.

  reply	other threads:[~2013-04-29 16:16 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-24 12:08 [linux-next-20130422] Bug in bootup code or debug code? Tetsuo Handa
2013-04-25 12:20 ` [linux-next-20130422] Bug in SLAB? Tetsuo Handa
2013-04-29  2:40   ` Tetsuo Handa
2013-04-29 10:12     ` Pekka Enberg
2013-04-29 14:44       ` Glauber Costa
2013-04-29 14:59         ` Christoph Lameter
2013-04-29 15:16           ` Glauber Costa
2013-04-29 15:46             ` Christoph Lameter
2013-04-29 15:54               ` Glauber Costa
2013-04-29 15:28           ` Tetsuo Handa
2013-04-29 16:16             ` Tetsuo Handa [this message]
2013-05-09 12:25               ` Tetsuo Handa
2013-05-09 14:14                 ` Christoph Lameter
2013-05-09 21:54                   ` Tetsuo Handa
2013-05-10 12:38                     ` Tetsuo Handa
2013-05-10 15:57                       ` Christoph Lameter
     [not found]                         ` <201305272153.HEH51089.OHFQMOOtFLSFVJ@I-love.SAKURA.ne.jp>
2013-06-17 11:59                           ` Tetsuo Handa
2013-04-29 17:48             ` Christoph Lameter
2013-04-29 21:45               ` Tetsuo Handa
2013-04-30 14:26                 ` Christoph Lameter
2013-04-30 16:01                   ` Tetsuo Handa
2013-04-30 17:27                     ` Christoph Lameter
2013-05-01  8:05                       ` Pekka Enberg
2013-05-02 15:12                         ` Christoph Lameter
2013-05-01 12:14                       ` Tetsuo Handa
2013-05-02 11:51                         ` Tetsuo Handa
2013-05-02 20:53                         ` Christoph Lameter
2013-05-03  8:26                           ` Tetsuo Handa
2013-05-03 15:43                             ` Christoph Lameter
2013-05-06  6:59                               ` Geert Uytterhoeven
2013-05-06  7:27                                 ` Pekka Enberg
2013-05-03 18:04                             ` Christoph Lameter
2013-05-03 18:48                               ` Tetsuo Handa
2013-05-03 19:21                                 ` Christoph Lameter
2013-05-04  0:15                                   ` Tetsuo Handa
2013-05-06 13:46                                     ` Christoph Lameter
2013-05-07 10:38                                       ` Tetsuo Handa
2013-05-07 14:28                                         ` Christoph Lameter
2013-07-01 20:09                                           ` Andrew Morton
2013-07-01 21:45                                             ` Tetsuo Handa
2013-07-01 21:53                                               ` Andrew Morton
2013-07-02 12:49                                                 ` Tetsuo Handa
2013-07-02 19:12                                                   ` Andrew Morton
2013-07-07 15:58                                                     ` Pekka Enberg
2013-05-06  6:32                               ` Pekka Enberg
2013-05-06 13:47                                 ` Christoph Lameter
2013-05-06 20:24                               ` Pekka Enberg
2013-05-07 14:23                                 ` Christoph Lameter
2013-05-07 14:44                                   ` Pekka Enberg
2013-05-07 15:40                                     ` Christoph Lameter
2013-04-30 14:34                 ` Christoph Lameter
2013-05-01  8:03                   ` Pekka Enberg
2013-05-02 15:13                     ` Christoph Lameter
2013-04-30 15:16                 ` Fix off by one error in slab.h Christoph Lameter
2013-04-29  2:56   ` [linux-next-20130422] Bug in SLAB? Zhan Jianyu
2013-04-29  2:56     ` Zhan Jianyu
2013-04-29  3:56     ` Tetsuo Handa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201304300116.FGJ56210.FMSOJHFOtFQVOL@I-love.SAKURA.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=cl@linux.com \
    --cc=glommer@parallels.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.