[PATCH] Fix kernel BUGs when enable SLOB allocator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

When enable the SLOB allocator on a nommu system(uClinux), the
following bug occurs when remove a large file.
=========================================================
root:~> cp /bin/busybox /busy
root:~> ls -l /bin/busybox /busy
-rwxr-xr-x    1 0        0          423904 /bin/busybox
-rwxr-xr-x    1 0        0          423904 /busy
root:~> md5sum /bin/busybox
7db253a2259ab71bc854c9e5dac544d6  /bin/busybox
root:~> md5sum /busy
7db253a2259ab71bc854c9e5dac544d6  /busy
root:~> rm /busy
kernel BUG at mm/nommu.c:124!
Kernel panic - not syncing: BUG!
=========================================================

The root cause is the slob allocator get the pages but does not set
the PageSlab bit.
So when kobjsize is called, the bug occurs.

My patch found a simple way to fix the issue. When SLOB is enabled, we
don't need to set the PageSlab bit, and don't need to check the
PageSlab bit(PageSlab(page)) in the kobjsize routine call.

Signed-off-by: Aubrey Li <[email protected]>

------
diff --git a/mm/nommu.c b/mm/nommu.c
index 029fada..8a54391 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -18,7 +18,9 @@ #include <linux/swap.h>
#include <linux/file.h>
#include <linux/highmem.h>
#include <linux/pagemap.h>
-#include <linux/slab.h>
+#ifdef CONFIG_SLAB
+# include <linux/slab.h>
+#endif
#include <linux/vmalloc.h>
#include <linux/ptrace.h>
#include <linux/blkdev.h>
@@ -112,7 +114,9 @@ unsigned int kobjsize(const void *objp)
       if (!objp || !((page = virt_to_page(objp))))
               return 0;

+#ifdef CONFIG_SLAB
       if (PageSlab(page))
+#endif
               return ksize(objp);

       BUG_ON(page->index < 0);
------
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux