All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5.15 01/15] xfs: use kmem_cache_free() for kmem_cache objects
@ 2022-06-03 18:57 Leah Rumancik
  2022-06-03 18:57 ` [PATCH 5.15 02/15] xfs: punch out data fork delalloc blocks on COW writeback failure Leah Rumancik
                   ` (13 more replies)
  0 siblings, 14 replies; 17+ messages in thread
From: Leah Rumancik @ 2022-06-03 18:57 UTC (permalink / raw)
  To: linux-xfs, djwong; +Cc: Rustam Kovhaev, Leah Rumancik

From: Rustam Kovhaev <rkovhaev@gmail.com>

[ Upstream commit c30a0cbd07ecc0eec7b3cd568f7b1c7bb7913f93 ]

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: 9749fee83f38 ("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>
---
 fs/xfs/xfs_extfree_item.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 3f8a0713573a..a4b8caa2c601 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -482,7 +482,7 @@ xfs_extent_free_finish_item(
 			free->xefi_startblock,
 			free->xefi_blockcount,
 			&free->xefi_oinfo, free->xefi_skip_discard);
-	kmem_free(free);
+	kmem_cache_free(xfs_bmap_free_item_zone, free);
 	return error;
 }
 
@@ -502,7 +502,7 @@ xfs_extent_free_cancel_item(
 	struct xfs_extent_free_item	*free;
 
 	free = container_of(item, struct xfs_extent_free_item, xefi_list);
-	kmem_free(free);
+	kmem_cache_free(xfs_bmap_free_item_zone, free);
 }
 
 const struct xfs_defer_op_type xfs_extent_free_defer_type = {
@@ -564,7 +564,7 @@ xfs_agfl_free_finish_item(
 	extp->ext_len = free->xefi_blockcount;
 	efdp->efd_next_extent++;
 
-	kmem_free(free);
+	kmem_cache_free(xfs_bmap_free_item_zone, free);
 	return error;
 }
 
-- 
2.36.1.255.ge46751e96f-goog


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-06-13 19:15 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-03 18:57 [PATCH 5.15 01/15] xfs: use kmem_cache_free() for kmem_cache objects Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 02/15] xfs: punch out data fork delalloc blocks on COW writeback failure Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 03/15] xfs: Fix the free logic of state in xfs_attr_node_hasname Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 04/15] xfs: remove xfs_inew_wait Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 05/15] xfs: remove all COW fork extents when remounting readonly Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 06/15] xfs: only run COW extent recovery when there are no live extents Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 07/15] xfs: check sb_meta_uuid for dabuf buffer recovery Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 08/15] xfs: prevent UAF in xfs_log_item_in_current_chkpt Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 09/15] xfs: only bother with sync_filesystem during readonly remount Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 10/15] xfs: don't generate selinux audit messages for capability testing Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 11/15] xfs: use setattr_copy to set vfs inode attributes Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 12/15] xfs: async CIL flushes need pending pushes to be made stable Leah Rumancik
2022-06-08  7:43   ` Amir Goldstein
2022-06-13 17:31     ` Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 13/15] xfs: don't include bnobt blocks when reserving free block pool Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 14/15] xfs: run callbacks before waking waiters in xlog_state_shutdown_callbacks Leah Rumancik
2022-06-03 18:57 ` [PATCH 5.15 15/15] xfs: drop async cache flushes from CIL commits Leah Rumancik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.