]> git.baikalelectronics.ru Git - kernel.git/commit
xfs: use kmem_cache_free() for kmem_cache objects
authorRustam Kovhaev <rkovhaev@gmail.com>
Mon, 11 Oct 2021 23:02:22 +0000 (16:02 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 11 Oct 2021 23:13:30 +0000 (16:13 -0700)
commit89b525b2144e58f437116f74c84383ac76e43c9e
treef34ba1c6084e01aeab941523e91ddda9c61f4237
parent75cbc6975682b0922a7c77050d1f527e452f1b75
xfs: use kmem_cache_free() for kmem_cache objects

For kmalloc() allocations SLOB prepends the blocks with a 4-byte header,
and it puts the size of the allocated blocks in that header.
Blocks allocated with kmem_cache_alloc() allocations do not have that
header.

SLOB explodes when you allocate memory with kmem_cache_alloc() and then
try to free it with kfree() instead of kmem_cache_free().
SLOB will assume that there is a header when there is none, read some
garbage to size variable and corrupt the adjacent objects, which
eventually leads to hang or panic.

Let's make XFS work with SLOB by using proper free function.

Fixes: 34fcf7e4bca3 ("xfs: enable the xfs_defer mechanism to process extents to free")
Signed-off-by: Rustam Kovhaev <rkovhaev@gmail.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/xfs_extfree_item.c