mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Muchun Song <songmuchun@bytedance.com>,
	Dan Williams <djbw@kernel.org>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Alison Schofield <alison.schofield@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Joao Martins <joao.m.martins@oracle.com>,
	nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org,
	linux-kernel@vger.kernel.org, muchun.song@linux.dev
Subject: Re: [PATCH 2/2] dax/bus: fix mapping attribute error reporting
Date: Mon, 21 Sep 2026 12:23:02 -0700	[thread overview]
Message-ID: <7619863e-0690-4f45-ae99-c75ad7573c61@intel.com> (raw)
In-Reply-To: <20260915095621.3744167-3-songmuchun@bytedance.com>



On 9/15/26 2:56 AM, Muchun Song wrote:
> After the DAX configuration locking was converted to rwsems, successful
> lock acquisition leaves rc set to zero in mapping_store(). If the requested
> range size is misaligned, the allocation is skipped and the zero rc is
> converted to len. The sysfs write therefore reports success without
> allocating the requested range.
> 
> Call alloc_dev_dax_range() unconditionally and let its full range
> validation return -EINVAL for a misaligned start or size.
> 
> Fixes: c05ae9d85b47 ("dax/bus.c: replace driver-core lock usage by a local rwsem")
> Assisted-by: LLM
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
>  drivers/dax/bus.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
> index 54e4bbc98218..f232001ff5b7 100644
> --- a/drivers/dax/bus.c
> +++ b/drivers/dax/bus.c
> @@ -1276,8 +1276,7 @@ static ssize_t mapping_store(struct device *dev, struct device_attribute *attr,
>  	}
>  
>  	to_alloc = range_len(&r);
> -	if (size_is_aligned(dev_dax, to_alloc))
> -		rc = alloc_dev_dax_range(dev_dax, r.start, to_alloc);
> +	rc = alloc_dev_dax_range(dev_dax, r.start, to_alloc);
>  	up_write(&dax_dev_rwsem);
>  	up_write(&dax_region_rwsem);
>  

So this patch becomes somewhat of a backport issue as it depends on patch 1. Please consider swap the ordering of your patch series and fix this issue first. Maybe something like so the fix can be independently backported:

diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index b809e1a264af..e40c25401cf0 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -1192,7 +1192,7 @@ static ssize_t mapping_store(struct device *dev, struct de
vice_attribute *attr,
                return rc;
        if (!dax_region->dev->driver) {
                up_write(&dax_region_rwsem);
-               return rc;
+               return -ENXIO;
        }
        rc = down_write_killable(&dax_dev_rwsem);
        if (rc) {
@@ -1201,8 +1201,12 @@ static ssize_t mapping_store(struct device *dev, struct d
evice_attribute *attr,
        }

        to_alloc = range_len(&r);
-       if (alloc_is_aligned(dev_dax, to_alloc))
+       if (!alloc_is_aligned(dev_dax, to_alloc)) {
+               dev_dbg(dev, "%s: size: %zu misaligned\n", __func__, to_alloc);
+               rc = -EINVAL;
+       } else {
                rc = alloc_dev_dax_range(dev_dax, r.start, to_alloc);
+       }
        up_write(&dax_dev_rwsem);
        up_write(&dax_region_rwsem);



  reply	other threads:[~2026-09-21 19:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15  9:56 [PATCH 0/2] dax: Fix Device DAX range allocation validation Muchun Song
2026-09-15  9:56 ` [PATCH 1/2] dax/bus: fix Device DAX range alignment validation Muchun Song
2026-09-21 21:01   ` Dave Jiang
2026-09-22  2:21     ` Muchun Song
2026-09-15  9:56 ` [PATCH 2/2] dax/bus: fix mapping attribute error reporting Muchun Song
2026-09-21 19:23   ` Dave Jiang [this message]
2026-09-22  2:27     ` Muchun Song
2026-09-18 17:02 ` [PATCH 0/2] dax: Fix Device DAX range allocation validation Dave Jiang
2026-09-19  5:03   ` Muchun Song
2026-09-21 18:58     ` Dave Jiang
2026-09-22  2:25       ` Muchun Song

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=7619863e-0690-4f45-ae99-c75ad7573c61@intel.com \
    --to=dave.jiang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=alison.schofield@intel.com \
    --cc=djbw@kernel.org \
    --cc=joao.m.martins@oracle.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=nvdimm@lists.linux.dev \
    --cc=songmuchun@bytedance.com \
    --cc=vishal.l.verma@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

all inboxes | Powered by JetHome®