]> git.baikalelectronics.ru Git - kernel.git/commit
xfs: use kmem_cache_free() for kmem_cache objects
authorRustam Kovhaev <rkovhaev@gmail.com>
Tue, 28 Jun 2022 18:39:45 +0000 (11:39 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 2 Jul 2022 14:41:12 +0000 (16:41 +0200)
commit825d4664d866d6f7c31c084f964281da3160dde0
tree428bd7acc09bda6a768b5f6d961e9a5131fbfdde
parent7b78f1ae90878b35e0e2ccfd9f22ae1b48aa0927
xfs: use kmem_cache_free() for kmem_cache objects

[ Upstream commit 8be81606144c504bca84587b4154991578b8d4d4 ]

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: ba235cc6074b ("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>
Signed-off-by: Leah Rumancik <leah.rumancik@gmail.com>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/xfs/xfs_extfree_item.c