Commit 678ff6a
mm: slab: fix potential double free in ___cache_free
With the commit 10befea ("mm: memcg/slab: use a single set of
kmem_caches for all allocations"), it becomes possible to call kfree()
from the slabs_destroy().
The functions cache_flusharray() and do_drain() calls slabs_destroy() on
array_cache of the local CPU without updating the size of the
array_cache. This enables the kfree() call from the slabs_destroy() to
recursively call cache_flusharray() which can potentially call
free_block() on the same elements of the array_cache of the local CPU
and causing double free and memory corruption.
To fix the issue, simply update the local CPU array_cache cache before
calling slabs_destroy().
Fixes: 10befea ("mm: memcg/slab: use a single set of kmem_caches for all allocations")
Signed-off-by: Shakeel Butt <shakeelb@google.com>
Reviewed-by: Roman Gushchin <guro@fb.com>
Tested-by: Ming Lei <ming.lei@redhat.com>
Reported-by: kernel test robot <rong.a.chen@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ted Ts'o <tytso@mit.edu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>1 parent 7c7ec32 commit 678ff6a
1 file changed
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1632 | 1632 | | |
1633 | 1633 | | |
1634 | 1634 | | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
1635 | 1639 | | |
1636 | 1640 | | |
1637 | 1641 | | |
| |||
2153 | 2157 | | |
2154 | 2158 | | |
2155 | 2159 | | |
2156 | | - | |
2157 | 2160 | | |
| 2161 | + | |
2158 | 2162 | | |
2159 | 2163 | | |
2160 | 2164 | | |
| |||
3402 | 3406 | | |
3403 | 3407 | | |
3404 | 3408 | | |
3405 | | - | |
3406 | 3409 | | |
3407 | 3410 | | |
| 3411 | + | |
3408 | 3412 | | |
3409 | 3413 | | |
3410 | 3414 | | |
| |||
0 commit comments