Skip to content

Commit 4f6ac47

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
xfs: fix a use after free in xfs_defer_finish_recovery
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: 7f2f753 ("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> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
1 parent 378b6ae commit 4f6ac47

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/xfs/libxfs/xfs_defer.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,12 +915,14 @@ xfs_defer_finish_recovery(
915915
struct xfs_defer_pending *dfp,
916916
struct list_head *capture_list)
917917
{
918+
const struct xfs_defer_op_type *ops = dfp->dfp_ops;
918919
int error;
919920

920-
error = dfp->dfp_ops->recover_work(dfp, capture_list);
921+
/* dfp is freed by recover_work and must not be accessed afterwards */
922+
error = ops->recover_work(dfp, capture_list);
921923
if (error)
922924
trace_xlog_intent_recovery_failed(mp, error,
923-
dfp->dfp_ops->recover_work);
925+
ops->recover_work);
924926
return error;
925927
}
926928

0 commit comments

Comments
 (0)