aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slub.c
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2010-08-25 19:32:27 -0400
committerPekka Enberg <penberg@kernel.org>2010-10-02 03:24:29 -0400
commita016471a16b5c4d4ec8f5221575e603a3d11e5e9 (patch)
treeffc9e385f0db13aa5dad34a461fac38a0638474e /mm/slub.c
parent8de66a0c022c7c575c7481224803292cdabed4c4 (diff)
slub: fix SLUB_RESILIENCY_TEST for dynamic kmalloc caches
Now that the kmalloc_caches array is dynamically allocated at boot, SLUB_RESILIENCY_TEST needs to be fixed to pass the correct type. Acked-by: Christoph Lameter <cl@linux.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'mm/slub.c')
-rw-r--r--mm/slub.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/mm/slub.c b/mm/slub.c
index b244a5a11a98..4c5a76f505ea 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3498,6 +3498,8 @@ static void resiliency_test(void)
3498{ 3498{
3499 u8 *p; 3499 u8 *p;
3500 3500
3501 BUILD_BUG_ON(KMALLOC_MIN_SIZE > 16 || SLUB_PAGE_SHIFT < 10);
3502
3501 printk(KERN_ERR "SLUB resiliency testing\n"); 3503 printk(KERN_ERR "SLUB resiliency testing\n");
3502 printk(KERN_ERR "-----------------------\n"); 3504 printk(KERN_ERR "-----------------------\n");
3503 printk(KERN_ERR "A. Corruption after allocation\n"); 3505 printk(KERN_ERR "A. Corruption after allocation\n");
@@ -3507,7 +3509,7 @@ static void resiliency_test(void)
3507 printk(KERN_ERR "\n1. kmalloc-16: Clobber Redzone/next pointer" 3509 printk(KERN_ERR "\n1. kmalloc-16: Clobber Redzone/next pointer"
3508 " 0x12->0x%p\n\n", p + 16); 3510 " 0x12->0x%p\n\n", p + 16);
3509 3511
3510 validate_slab_cache(kmalloc_caches + 4); 3512 validate_slab_cache(kmalloc_caches[4]);
3511 3513
3512 /* Hmmm... The next two are dangerous */ 3514 /* Hmmm... The next two are dangerous */
3513 p = kzalloc(32, GFP_KERNEL); 3515 p = kzalloc(32, GFP_KERNEL);
@@ -3517,7 +3519,7 @@ static void resiliency_test(void)
3517 printk(KERN_ERR 3519 printk(KERN_ERR
3518 "If allocated object is overwritten then not detectable\n\n"); 3520 "If allocated object is overwritten then not detectable\n\n");
3519 3521
3520 validate_slab_cache(kmalloc_caches + 5); 3522 validate_slab_cache(kmalloc_caches[5]);
3521 p = kzalloc(64, GFP_KERNEL); 3523 p = kzalloc(64, GFP_KERNEL);
3522 p += 64 + (get_cycles() & 0xff) * sizeof(void *); 3524 p += 64 + (get_cycles() & 0xff) * sizeof(void *);
3523 *p = 0x56; 3525 *p = 0x56;
@@ -3525,27 +3527,27 @@ static void resiliency_test(void)
3525 p); 3527 p);
3526 printk(KERN_ERR 3528 printk(KERN_ERR
3527 "If allocated object is overwritten then not detectable\n\n"); 3529 "If allocated object is overwritten then not detectable\n\n");
3528 validate_slab_cache(kmalloc_caches + 6); 3530 validate_slab_cache(kmalloc_caches[6]);
3529 3531
3530 printk(KERN_ERR "\nB. Corruption after free\n"); 3532 printk(KERN_ERR "\nB. Corruption after free\n");
3531 p = kzalloc(128, GFP_KERNEL); 3533 p = kzalloc(128, GFP_KERNEL);
3532 kfree(p); 3534 kfree(p);
3533 *p = 0x78; 3535 *p = 0x78;
3534 printk(KERN_ERR "1. kmalloc-128: Clobber first word 0x78->0x%p\n\n", p); 3536 printk(KERN_ERR "1. kmalloc-128: Clobber first word 0x78->0x%p\n\n", p);
3535 validate_slab_cache(kmalloc_caches + 7); 3537 validate_slab_cache(kmalloc_caches[7]);
3536 3538
3537 p = kzalloc(256, GFP_KERNEL); 3539 p = kzalloc(256, GFP_KERNEL);
3538 kfree(p); 3540 kfree(p);
3539 p[50] = 0x9a; 3541 p[50] = 0x9a;
3540 printk(KERN_ERR "\n2. kmalloc-256: Clobber 50th byte 0x9a->0x%p\n\n", 3542 printk(KERN_ERR "\n2. kmalloc-256: Clobber 50th byte 0x9a->0x%p\n\n",
3541 p); 3543 p);
3542 validate_slab_cache(kmalloc_caches + 8); 3544 validate_slab_cache(kmalloc_caches[8]);
3543 3545
3544 p = kzalloc(512, GFP_KERNEL); 3546 p = kzalloc(512, GFP_KERNEL);
3545 kfree(p); 3547 kfree(p);
3546 p[512] = 0xab; 3548 p[512] = 0xab;
3547 printk(KERN_ERR "\n3. kmalloc-512: Clobber redzone 0xab->0x%p\n\n", p); 3549 printk(KERN_ERR "\n3. kmalloc-512: Clobber redzone 0xab->0x%p\n\n", p);
3548 validate_slab_cache(kmalloc_caches + 9); 3550 validate_slab_cache(kmalloc_caches[9]);
3549} 3551}
3550#else 3552#else
3551static void resiliency_test(void) {}; 3553static void resiliency_test(void) {};