Linux CXL
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Miklos Szeredi" <mszeredi@redhat.com>
Cc: linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev
Subject: Re: [PATCH v4 1/9] dax: add fsdev_dax_from_file()
Date: Thu, 08 Oct 2026 11:34:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-164095@kernel.org> (raw)
In-Reply-To: <20261008112004.1899560-2-mszeredi@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] dax: lockdep splat and user-triggerable WARN_ON in fsdev_dax_from_file()
--

commit f952deffb3bddf19404bc61323d8ebb31e8333ad
Author: John Groves <John@Groves.net>
Date:   Thu Oct 8 11:19:52 2026 +0000

    dax: add fsdev_dax_from_file()

This commit adds the fsdev_dax_from_file() helper to get the dax_dev from a
device inode's i_cdev and grab a reference on the private dax inode. It also
makes dax_dev_get() static again, replacing its export with the new helper.

> diff --git a/drivers/dax/fsdev.c b/drivers/dax/fsdev.c
> --- a/drivers/dax/fsdev.c
> +++ b/drivers/dax/fsdev.c

[ ... ]

> @@ -234,6 +234,30 @@ static const struct file_operations fsdev_fops = {
>  	.release = fsdev_release,
>  };
>  
> +/**
> + * fsdev_dax_from_file - get dax_device from an open file
> + * @file: open device file
> + *
> + * Returns a dax_device pointer if @file refers to a fsdev_dax device.
> + * Otherwise return NULL.
> + *
> + * Caller must put_dax() the returned device when done.
> + */
> +struct dax_device *fsdev_dax_from_file(struct file *file)
> +{
> +	struct dax_device *dax_dev;
> +
> +	if (file->f_op != &fsdev_fops)
> +		return NULL;
> +
> +	dax_dev = inode_dax(file_inode(file));
> +	WARN_ON(!dax_alive(dax_dev));
> +	ihold(dax_inode(dax_dev));
> +
> +	return dax_dev;

[Severity: High]
Does this code trigger a lockdep splat when calling dax_alive()?

Looking at dax_alive() in drivers/dax/super.c, it explicitly asserts that
the dax_srcu lock is held:

bool dax_alive(struct dax_device *dax_dev)
{
        lockdep_assert_held(&dax_srcu);
        return test_bit(DAXDEV_ALIVE, &dax_dev->flags);
}

Since fsdev_dax_from_file() does not appear to acquire the dax_srcu lock
before this call, it looks like this will cause a lockdep splat on every
invocation when lockdep is enabled.

Additionally, if an administrator unbinds the driver via sysfs (which
clears DAXDEV_ALIVE), will this WARN_ON become user-triggerable during a
later file lookup? A user-triggerable kernel splat can cause a panic if
panic_on_warn is enabled.

If the device is actually dead, is it safe to proceed to call ihold() and
return the dead device pointer to the caller? Perhaps this path should
return NULL or an error instead of providing a dead device.

> +}
> +EXPORT_SYMBOL_GPL(fsdev_dax_from_file);

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

  reply	other threads:[~2026-10-08 11:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08 11:19 [PATCH v4 0/9] fuse: DAX device based extent maps (famfs) Miklos Szeredi
2026-10-08 11:19 ` [PATCH v4 1/9] dax: add fsdev_dax_from_file() Miklos Szeredi
2026-10-08 11:34   ` sashiko-bot [this message]
2026-10-08 11:19 ` [PATCH v4 2/9] dax: use READ_ONCE() in dax_holder() Miklos Szeredi
2026-10-08 11:32   ` sashiko-bot
2026-10-08 13:20   ` Gregory Price
2026-10-08 11:19 ` [PATCH v4 3/9] fuse: add helpers for EIO return value with kernel message Miklos Szeredi
2026-10-08 11:19 ` [PATCH v4 4/9] fuse: support 64 bit, server allocated backing ID Miklos Szeredi
2026-10-09  7:36   ` Amir Goldstein
2026-10-08 11:19 ` [PATCH v4 5/9] fuse: support opening 64 bit " Miklos Szeredi
2026-10-08 11:19 ` [PATCH v4 6/9] fuse: add support for opening dax device as backing Miklos Szeredi
2026-10-08 11:34   ` sashiko-bot
2026-10-08 11:19 ` [PATCH v4 7/9] fuse: add extent map data structure Miklos Szeredi
2026-10-08 11:19 ` [PATCH v4 8/9] fuse: add extent map I/O support Miklos Szeredi
2026-10-08 11:36   ` sashiko-bot
2026-10-08 11:20 ` [PATCH v4 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-164095@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox