All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Miklos Szeredi" <mszeredi@redhat.com>
Cc: nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org
Subject: Re: [PATCH v3 2/9] dax: use READ_ONCE() in dax_holder()
Date: Tue, 06 Oct 2026 18:13:36 +0000	[thread overview]
Message-ID: <sashiko-outbox-162321@kernel.org> (raw)
In-Reply-To: <20261006180115.1425232-3-mszeredi@redhat.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] xfs: missing NULL check in xfs_dax_notify_failure() causes NULL pointer dereference
- [High] dax: missing synchronize_srcu() in fs_put_dax() leads to Use-After-Free of xfs_mount
--

commit b62dcd3b2d7873db8fcf1fc4a0c2b9c52417ad0a
Author: Miklos Szeredi <mszeredi@redhat.com>

dax: use READ_ONCE() in dax_holder()
    
Make sure that a non-NULL check in callers remains valid even when racing
with fs_put_dax().

> diff --git a/drivers/dax/super.c b/drivers/dax/super.c
> index 824e1f6df3780..0a440f8b42e4f 100644
> --- a/drivers/dax/super.c
> +++ b/drivers/dax/super.c
> @@ -677,7 +677,7 @@ EXPORT_SYMBOL_GPL(put_dax);
>   */
>  void *dax_holder(struct dax_device *dax_dev)
>  {
> -	return dax_dev->holder_data;
> +	return READ_ONCE(dax_dev->holder_data);

[Severity: High]
Does this code still leave a window for a NULL pointer dereference?

The commit message mentions protecting a non-NULL check in callers, but the
caller in xfs_dax_notify_failure() doesn't appear to have one:

fs/xfs/xfs_notify_failure.c:xfs_dax_notify_failure() {
	struct xfs_mount	*mp = dax_holder(dax_dev);

	if (!(mp->m_super->s_flags & SB_BORN)) {
		...
}

If a concurrent unmount clears dax_dev->holder_data to NULL via
fs_put_dax(), won't this result in assigning NULL to mp and immediately
dereferencing mp->m_super?


[Severity: High]
Can a use-after-free occur on the returned xfs_mount pointer even if a NULL
check is added?

When a memory failure triggers dax_holder_notify_failure(), it acquires
dax_read_lock() (which is SRCU) and calls xfs_dax_notify_failure().

Concurrently, if an unmount calls fs_put_dax(), it clears the holder data:

drivers/dax/super.c:fs_put_dax() {
	...
	WRITE_ONCE(dax_dev->holder_ops, NULL);
	prev = cmpxchg(&dax_dev->holder_data, holder, NULL);
	...
}

Since fs_put_dax() returns without calling synchronize_srcu(&dax_srcu) to
wait for active readers, the unmount process can proceed and destroy the
xfs_mount structure.

Won't the still-executing xfs_dax_notify_failure() then access the freed
xfs_mount, resulting in a use-after-free?

>  }
>  EXPORT_SYMBOL_GPL(dax_holder);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261006180115.1425232-1-mszeredi@redhat.com?part=2

  reply	other threads:[~2026-10-06 18:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 18:01 [PATCH v3 0/9] fuse: DAX device based extent maps (famfs) Miklos Szeredi
2026-10-06 18:01 ` [PATCH v3 1/9] dax: replace exported dax_dev_get() with non-allocating dax_dev_find() Miklos Szeredi
2026-10-06 18:10   ` sashiko-bot
2026-10-06 18:01 ` [PATCH v3 2/9] dax: use READ_ONCE() in dax_holder() Miklos Szeredi
2026-10-06 18:13   ` sashiko-bot [this message]
2026-10-08  1:02   ` Alison Schofield
2026-10-08  6:58     ` Miklos Szeredi
2026-10-06 18:01 ` [PATCH v3 3/9] fuse: add helpers for EIO return value with kernel message Miklos Szeredi
2026-10-06 21:03   ` Amir Goldstein
2026-10-06 18:01 ` [PATCH v3 4/9] fuse: support 64 bit, server allocated backing ID Miklos Szeredi
2026-10-06 18:20   ` sashiko-bot
2026-10-06 20:10   ` John Groves
2026-10-07 12:49     ` Miklos Szeredi
2026-10-06 22:08   ` Amir Goldstein
2026-10-07 12:54     ` Miklos Szeredi
2026-10-06 18:01 ` [PATCH v3 5/9] fuse: support opening 64 bit " Miklos Szeredi
2026-10-06 18:01 ` [PATCH v3 6/9] fuse: add support for opening dax device as backing Miklos Szeredi
2026-10-06 18:18   ` sashiko-bot
2026-10-06 18:01 ` [PATCH v3 7/9] fuse: add extent map data structure Miklos Szeredi
2026-10-06 18:17   ` sashiko-bot
2026-10-06 18:01 ` [PATCH v3 8/9] fuse: add extent map I/O support Miklos Szeredi
2026-10-06 18:22   ` sashiko-bot
2026-10-06 18:01 ` [PATCH v3 9/9] fuse: add support for striped backing Miklos Szeredi

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=sashiko-outbox-162321@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=mszeredi@redhat.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 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.