linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] xfs: fix a use after free in xfs_defer_finish_recovery
@ 2023-12-28  6:18 Christoph Hellwig
  2023-12-28  6:18 ` [PATCH 2/2] xfs: use the op name in trace_xlog_intent_recovery_failed Christoph Hellwig
  2023-12-28  6:26 ` [PATCH 1/2] xfs: fix a use after free in xfs_defer_finish_recovery Darrick J. Wong
  0 siblings, 2 replies; 5+ messages in thread
From: Christoph Hellwig @ 2023-12-28  6:18 UTC (permalink / raw)
  To: chandan.babu; +Cc: djwong, linux-xfs, kernel test robot

dfp will be freed by ->recover_work and thus the tracepoint in case
of an error can lead to a use after free.

Store the defer ops in a local variable to avoid that.

Fixes: 7f2f7531e0d4 ("xfs: store an ops pointer in struct xfs_defer_pending")
Reported-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_defer.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index ca7f0ac0489604..785c92d2acaa73 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -915,12 +915,13 @@ xfs_defer_finish_recovery(
 	struct xfs_defer_pending	*dfp,
 	struct list_head		*capture_list)
 {
+	const struct xfs_defer_op_type	*ops = dfp->dfp_ops;
 	int				error;
 
-	error = dfp->dfp_ops->recover_work(dfp, capture_list);
+	error = ops->recover_work(dfp, capture_list);
 	if (error)
 		trace_xlog_intent_recovery_failed(mp, error,
-				dfp->dfp_ops->recover_work);
+				ops->recover_work);
 	return error;
 }
 
-- 
2.39.2


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

end of thread, other threads:[~2023-12-28  6:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-28  6:18 [PATCH 1/2] xfs: fix a use after free in xfs_defer_finish_recovery Christoph Hellwig
2023-12-28  6:18 ` [PATCH 2/2] xfs: use the op name in trace_xlog_intent_recovery_failed Christoph Hellwig
2023-12-28  6:27   ` Darrick J. Wong
2023-12-28  6:26 ` [PATCH 1/2] xfs: fix a use after free in xfs_defer_finish_recovery Darrick J. Wong
2023-12-28  6:47   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).