]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mm/slub.c: init_on_free=1 should wipe freelist ptr for bulk allocations
authorAlexander Potapenko <glider@google.com>
Mon, 14 Oct 2019 21:11:57 +0000 (14:11 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 29 Nov 2019 09:08:22 +0000 (10:08 +0100)
commit37984225b9aec5b4c880421d67b85939b743a8cb
tree631cb524d7718d7a831342905a250769ceeb833e
parent3d45290ca924a561a72e9a2d86cfa649c58000bf
mm/slub.c: init_on_free=1 should wipe freelist ptr for bulk allocations

[ Upstream commit 0f181f9fbea8bc7ea2f7e13ae7f8c256b39e254c ]

slab_alloc_node() already zeroed out the freelist pointer if
init_on_free was on.  Thibaut Sautereau noticed that the same needs to
be done for kmem_cache_alloc_bulk(), which performs the allocations
separately.

kmem_cache_alloc_bulk() is currently used in two places in the kernel,
so this change is unlikely to have a major performance impact.

SLAB doesn't require a similar change, as auto-initialization makes the
allocator store the freelist pointers off-slab.

Link: http://lkml.kernel.org/r/20191007091605.30530-1-glider@google.com
Fixes: 6471384af2a6 ("mm: security: introduce init_on_alloc=1 and init_on_free=1 boot options")
Signed-off-by: Alexander Potapenko <glider@google.com>
Reported-by: Thibaut Sautereau <thibaut@sautereau.fr>
Reported-by: Kees Cook <keescook@chromium.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: Laura Abbott <labbott@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
mm/slub.c