mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dax/bus: Fix size_store() error path locking
@ 2026-11-29 23:29 Bart Van Assche
  2026-11-30 23:15 ` Verma, Vishal L
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Van Assche @ 2026-11-29 23:29 UTC (permalink / raw)
  To: Vishal Verma, Dave Jiang, Alison Schofield
  Cc: nvdimm, linux-cxl, linux-kernel, Bart Van Assche, Dan Williams

If down_write_killable(&dax_dev_rwsem) fails, size_store() jumps to the
err_dev label and calls up_write(&dax_dev_rwsem) on a rwsem it does not
hold. Jump to err_region instead such that only dax_region_rwsem is
released on that error path. This locking bug was detected by the Clang
thread-safety analyzer.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Alison Schofield <alison.schofield@intel.com>
Cc: nvdimm@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
Fixes: c05ae9d85b47 ("dax/bus.c: replace driver-core lock usage by a local rwsem")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 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 e40c25401cf0..fc83be5d6663 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -1129,11 +1129,10 @@ static ssize_t size_store(struct device *dev, struct device_attribute *attr,
 	}
 	rc = down_write_killable(&dax_dev_rwsem);
 	if (rc)
-		goto err_dev;
+		goto err_region;
 
 	rc = dev_dax_resize(dax_region, dev_dax, val);
 
-err_dev:
 	up_write(&dax_dev_rwsem);
 err_region:
 	up_write(&dax_region_rwsem);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] dax/bus: Fix size_store() error path locking
  2026-11-29 23:29 [PATCH] dax/bus: Fix size_store() error path locking Bart Van Assche
@ 2026-11-30 23:15 ` Verma, Vishal L
  0 siblings, 0 replies; 2+ messages in thread
From: Verma, Vishal L @ 2026-11-30 23:15 UTC (permalink / raw)
  To: Jiang, Dave, Schofield, Alison, bvanassche
  Cc: dan.j.williams, linux-cxl, nvdimm, linux-kernel

On Sun, 2026-11-29 at 15:29 -0800, Bart Van Assche wrote:
> If down_write_killable(&dax_dev_rwsem) fails, size_store() jumps to the
> err_dev label and calls up_write(&dax_dev_rwsem) on a rwsem it does not
> hold. Jump to err_region instead such that only dax_region_rwsem is
> released on that error path. This locking bug was detected by the Clang
> thread-safety analyzer.
> 
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Cc: nvdimm@lists.linux.dev
> Cc: linux-cxl@vger.kernel.org
> Fixes: c05ae9d85b47 ("dax/bus.c: replace driver-core lock usage by a local rwsem")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Reviewed-by: Vishal Verma <vishal.l.verma@intel.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 e40c25401cf0..fc83be5d6663 100644
> --- a/drivers/dax/bus.c
> +++ b/drivers/dax/bus.c
> @@ -1129,11 +1129,10 @@ static ssize_t size_store(struct device *dev, struct device_attribute *attr,
>  	}
>  	rc = down_write_killable(&dax_dev_rwsem);
>  	if (rc)
> -		goto err_dev;
> +		goto err_region;
>  
>  	rc = dev_dax_resize(dax_region, dev_dax, val);
>  
> -err_dev:
>  	up_write(&dax_dev_rwsem);
>  err_region:
>  	up_write(&dax_region_rwsem);


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-30 23:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-29 23:29 [PATCH] dax/bus: Fix size_store() error path locking Bart Van Assche
2026-11-30 23:15 ` Verma, Vishal L

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®