mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] coresight: tpdm: initialize spinlock before exposing sysfs
@ 2026-08-25  2:06 yingchao
  2026-08-25  3:09 ` Jie Gan
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: yingchao @ 2026-08-25  2:06 UTC (permalink / raw)
  To: Suzuki K Poulose, Alexander Shishkin
  Cc: Mike Leach, James Clark, Leo Yan, Mao Jinlong, Tao Zhang,
	jinlong.mao, qinyungao, coresight, linux-arm-kernel,
	linux-kernel, Yingchao Deng

From: Yingchao Deng <dengyingchao@kylinsec.com.cn>

tpdm_probe() initializes drvdata->spinlock after coresight_register(), but
the sysfs attributes registered by coresight_register() use the spinlock.
This exposes a window where a concurrent sysfs write can lock an
uninitialized spinlock.

Initialize the spinlock before coresight_register().

Fixes: b3c71626a933 ("Coresight: Add coresight TPDM source driver")
Signed-off-by: Yingchao Deng <dengyingchao@kylinsec.com.cn>
---
 drivers/hwtracing/coresight/coresight-tpdm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c
index 8464edbba2d4..50d1351772b9 100644
--- a/drivers/hwtracing/coresight/coresight-tpdm.c
+++ b/drivers/hwtracing/coresight/coresight-tpdm.c
@@ -1457,12 +1457,12 @@ static int tpdm_probe(struct device *dev, struct resource *res)
 		desc.groups = tpdm_attr_grps;
 	else
 		desc.groups = static_tpdm_attr_grps;
+	spin_lock_init(&drvdata->spinlock);
+
 	drvdata->csdev = coresight_register(&desc);
 	if (IS_ERR(drvdata->csdev))
 		return PTR_ERR(drvdata->csdev);
 
-	spin_lock_init(&drvdata->spinlock);
-
 	return 0;
 }
 
-- 
2.33.0


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

* Re: [PATCH] coresight: tpdm: initialize spinlock before exposing sysfs
  2026-08-25  2:06 [PATCH] coresight: tpdm: initialize spinlock before exposing sysfs yingchao
@ 2026-08-25  3:09 ` Jie Gan
  2026-09-07  3:08 ` yingchao deng
  2026-09-08 16:18 ` Leo Yan
  2 siblings, 0 replies; 4+ messages in thread
From: Jie Gan @ 2026-08-25  3:09 UTC (permalink / raw)
  To: yingchao, Suzuki K Poulose, Alexander Shishkin
  Cc: Mike Leach, James Clark, Leo Yan, Mao Jinlong, Tao Zhang,
	jinlong.mao, qinyungao, coresight, linux-arm-kernel,
	linux-kernel



On 8/25/2026 10:06 AM, yingchao wrote:
> From: Yingchao Deng <dengyingchao@kylinsec.com.cn>
> 
> tpdm_probe() initializes drvdata->spinlock after coresight_register(), but
> the sysfs attributes registered by coresight_register() use the spinlock.
> This exposes a window where a concurrent sysfs write can lock an
> uninitialized spinlock.
> 

There is only a very small window during which users have a chance to 
access the sysfs nodes. But still worthy to fix it.

Reviewed-by: Jie Gan <jie.gan@oss.qualcomm.com>

> Initialize the spinlock before coresight_register().
> 
> Fixes: b3c71626a933 ("Coresight: Add coresight TPDM source driver")
> Signed-off-by: Yingchao Deng <dengyingchao@kylinsec.com.cn>
> ---
>   drivers/hwtracing/coresight/coresight-tpdm.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c
> index 8464edbba2d4..50d1351772b9 100644
> --- a/drivers/hwtracing/coresight/coresight-tpdm.c
> +++ b/drivers/hwtracing/coresight/coresight-tpdm.c
> @@ -1457,12 +1457,12 @@ static int tpdm_probe(struct device *dev, struct resource *res)
>   		desc.groups = tpdm_attr_grps;
>   	else
>   		desc.groups = static_tpdm_attr_grps;
> +	spin_lock_init(&drvdata->spinlock);
> +
>   	drvdata->csdev = coresight_register(&desc);
>   	if (IS_ERR(drvdata->csdev))
>   		return PTR_ERR(drvdata->csdev);
>   
> -	spin_lock_init(&drvdata->spinlock);
> -
>   	return 0;
>   }
>   


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

* Re: [PATCH] coresight: tpdm: initialize spinlock before exposing sysfs
  2026-08-25  2:06 [PATCH] coresight: tpdm: initialize spinlock before exposing sysfs yingchao
  2026-08-25  3:09 ` Jie Gan
@ 2026-09-07  3:08 ` yingchao deng
  2026-09-08 16:18 ` Leo Yan
  2 siblings, 0 replies; 4+ messages in thread
From: yingchao deng @ 2026-09-07  3:08 UTC (permalink / raw)
  To: Suzuki K Poulose, Alexander Shishkin, Mike Leach, James Clark, Leo Yan
  Cc: Mao Jinlong, Tao Zhang, jinlong.mao, qinyungao, coresight,
	linux-arm-kernel, linux-kernel, Jie Gan

Gentle reminder

On 25/08/2026 10:06, yingchao wrote:
> From: Yingchao Deng <dengyingchao@kylinsec.com.cn>
>
> tpdm_probe() initializes drvdata->spinlock after coresight_register(), but
> the sysfs attributes registered by coresight_register() use the spinlock.
> This exposes a window where a concurrent sysfs write can lock an
> uninitialized spinlock.
>
> Initialize the spinlock before coresight_register().
>
> Fixes: b3c71626a933 ("Coresight: Add coresight TPDM source driver")
> Signed-off-by: Yingchao Deng <dengyingchao@kylinsec.com.cn>
> ---
>   drivers/hwtracing/coresight/coresight-tpdm.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c
> index 8464edbba2d4..50d1351772b9 100644
> --- a/drivers/hwtracing/coresight/coresight-tpdm.c
> +++ b/drivers/hwtracing/coresight/coresight-tpdm.c
> @@ -1457,12 +1457,12 @@ static int tpdm_probe(struct device *dev, struct resource *res)
>   		desc.groups = tpdm_attr_grps;
>   	else
>   		desc.groups = static_tpdm_attr_grps;
> +	spin_lock_init(&drvdata->spinlock);
> +
>   	drvdata->csdev = coresight_register(&desc);
>   	if (IS_ERR(drvdata->csdev))
>   		return PTR_ERR(drvdata->csdev);
>   
> -	spin_lock_init(&drvdata->spinlock);
> -
>   	return 0;
>   }
>   


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

* Re: [PATCH] coresight: tpdm: initialize spinlock before exposing sysfs
  2026-08-25  2:06 [PATCH] coresight: tpdm: initialize spinlock before exposing sysfs yingchao
  2026-08-25  3:09 ` Jie Gan
  2026-09-07  3:08 ` yingchao deng
@ 2026-09-08 16:18 ` Leo Yan
  2 siblings, 0 replies; 4+ messages in thread
From: Leo Yan @ 2026-09-08 16:18 UTC (permalink / raw)
  To: yingchao
  Cc: Suzuki K Poulose, Alexander Shishkin, Mike Leach, James Clark,
	Mao Jinlong, Tao Zhang, jinlong.mao, qinyungao, coresight,
	linux-arm-kernel, linux-kernel

On Tue, Aug 25, 2026 at 10:06:47AM +0800, yingchao wrote:
> From: Yingchao Deng <dengyingchao@kylinsec.com.cn>
> 
> tpdm_probe() initializes drvdata->spinlock after coresight_register(), but
> the sysfs attributes registered by coresight_register() use the spinlock.
> This exposes a window where a concurrent sysfs write can lock an
> uninitialized spinlock.
> 
> Initialize the spinlock before coresight_register().
> 
> Fixes: b3c71626a933 ("Coresight: Add coresight TPDM source driver")
> Signed-off-by: Yingchao Deng <dengyingchao@kylinsec.com.cn>

Reviewed-by: Leo Yan <leo.yan@arm.com>

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

end of thread, other threads:[~2026-09-08 16:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-25  2:06 [PATCH] coresight: tpdm: initialize spinlock before exposing sysfs yingchao
2026-08-25  3:09 ` Jie Gan
2026-09-07  3:08 ` yingchao deng
2026-09-08 16:18 ` Leo Yan

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®