]> Git Repo - linux.git/commit - lib/test_kasan.c
kasan: add memcg kmem_cache test
authorGreg Thelen <[email protected]>
Fri, 24 Feb 2017 23:00:08 +0000 (15:00 -0800)
committerLinus Torvalds <[email protected]>
Sat, 25 Feb 2017 01:46:56 +0000 (17:46 -0800)
commit0386bf385d9dbb277ff565765ac9d13fe36232d6
tree457ff134d858bf175aa403743b1f589a4756030e
parentf9fa1d919c696e90c887d8742198023e7639d139
kasan: add memcg kmem_cache test

Make a kasan test which uses a SLAB_ACCOUNT slab cache.  If the test is
run within a non default memcg, then it uncovers the bug fixed by
"kasan: drain quarantine of memcg slab objects"[1].

If run without fix [1] it shows "Slab cache still has objects", and the
kmem_cache structure is leaked.
Here's an unpatched kernel test:

 $ dmesg -c > /dev/null
 $ mkdir /sys/fs/cgroup/memory/test
 $ echo $$ > /sys/fs/cgroup/memory/test/tasks
 $ modprobe test_kasan 2> /dev/null
 $ dmesg | grep -B1 still
 [ 123.456789] kasan test: memcg_accounted_kmem_cache allocate memcg accounted object
 [ 124.456789] kmem_cache_destroy test_cache: Slab cache still has objects

Kernels with fix [1] don't have the "Slab cache still has objects"
warning or the underlying leak.

The new test runs and passes in the default (root) memcg, though in the
root memcg it won't uncover the problem fixed by [1].

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Greg Thelen <[email protected]>
Reviewed-by: Vladimir Davydov <[email protected]>
Cc: Andrey Ryabinin <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
lib/test_kasan.c
This page took 0.053049 seconds and 4 git commands to generate.