From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org,
kernel test robot <oliver.sang@intel.com>
Subject: Re: [PATCH 1/2] xfs: fix a use after free in xfs_defer_finish_recovery
Date: Wed, 27 Dec 2023 22:26:33 -0800 [thread overview]
Message-ID: <20231228062633.GR361584@frogsfrogsfrogs> (raw)
In-Reply-To: <20231228061830.337279-1-hch@lst.de>
On Thu, Dec 28, 2023 at 06:18:29AM +0000, Christoph Hellwig wrote:
> 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);
Since I suck at remembering that dfp can be freed by recovery work, can
you add a comment to that effect? e.g.
/* dfp is freed by recover_work and must not be accessed further */
error = ops->recover_work(dfp, capture_list);
With that added,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> if (error)
> trace_xlog_intent_recovery_failed(mp, error,
> - dfp->dfp_ops->recover_work);
> + ops->recover_work);
> return error;
> }
>
> --
> 2.39.2
>
>
next prev parent reply other threads:[~2023-12-28 6:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Darrick J. Wong [this message]
2023-12-28 6:47 ` [PATCH 1/2] xfs: fix a use after free in xfs_defer_finish_recovery Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231228062633.GR361584@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=chandan.babu@oracle.com \
--cc=hch@lst.de \
--cc=linux-xfs@vger.kernel.org \
--cc=oliver.sang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox