lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Tue,  1 Sep 2015 13:51:29 -0400
From:	Mike Snitzer <snitzer@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	linux-mm@...ck.org, riel@...hat.com, david@...morbit.com,
	axboe@...nel.dk, dm-devel@...hat.com, anderson@...hat.com
Subject: [PATCH 1/2] mm/slab_common: add SLAB_NO_MERGE flag for use when creating slabs

The slab aliasing/merging by default transition went unnoticed (at least
to the DM subsystem).  Add a new SLAB_NO_MERGE flag that allows
individual slabs to be created without slab merging.  This beats forcing
all slabs to be created in this fashion by specifying sl[au]b_nomerge on
the kernel commandline.

DM has historically taken care to have separate named slabs that each
devices' mempool_t are backed by.  These separate slabs are useful --
even if only to aid inspection of DM's memory use (via /proc/slabinfo)
on production systems.

I stumbled onto slab merging as a side-effect of a leak in dm-cache
being attributed to 'kmalloc-96' rather than the expected
'dm_bio_prison_cell' named slab.  Moving forward DM will disable slab
merging for all of DM's slabs by using SLAB_NO_MERGE.

Signed-off-by: Mike Snitzer <snitzer@...hat.com>
---
 include/linux/slab.h | 2 ++
 mm/slab.h            | 2 +-
 mm/slab_common.c     | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/slab.h b/include/linux/slab.h
index a99f0e5..d007407 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -87,6 +87,8 @@
 # define SLAB_FAILSLAB		0x00000000UL
 #endif
 
+#define SLAB_NO_MERGE		0x04000000UL	/* Do not merge with existing slab */
+
 /* The following flags affect the page allocator grouping pages by mobility */
 #define SLAB_RECLAIM_ACCOUNT	0x00020000UL		/* Objects are reclaimable */
 #define SLAB_TEMPORARY		SLAB_RECLAIM_ACCOUNT	/* Objects are short-lived */
diff --git a/mm/slab.h b/mm/slab.h
index 8da63e4..35eb6f4 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -115,7 +115,7 @@ static inline unsigned long kmem_cache_flags(unsigned long object_size,
 
 /* Legal flag mask for kmem_cache_create(), for various configurations */
 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
-			 SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
+			 SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_NO_MERGE)
 
 #if defined(CONFIG_DEBUG_SLAB)
 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 8683110..3a5a8ed 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -35,7 +35,7 @@ struct kmem_cache *kmem_cache;
  */
 #define SLAB_NEVER_MERGE (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | \
 		SLAB_TRACE | SLAB_DESTROY_BY_RCU | SLAB_NOLEAKTRACE | \
-		SLAB_FAILSLAB)
+		SLAB_FAILSLAB | SLAB_NO_MERGE)
 
 #define SLAB_MERGE_SAME (SLAB_RECLAIM_ACCOUNT | SLAB_CACHE_DMA | SLAB_NOTRACK)
 
-- 
2.3.2 (Apple Git-55)

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ