From: sashiko-bot@kernel.org
To: "Yeoreum Yun" <yeoreum.yun@arm.com>
Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH v11 2/9] coresight: etm3x: prohibit modifying cntr_val and reset while session is enabled
Date: Tue, 15 Sep 2026 11:48:44 +0000 [thread overview]
Message-ID: <20260915114845.CFA601F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260915-separate_etm_cfg_v2-v11-2-d2b258d51747@arm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] coresight: TOCTOU race in sysfs configuration store functions
--
commit 9a331a4cd5a9fd51e7380e92ed6bdd6d8e20d5e4
Author: Yeoreum Yun <yeoreum.yun@arm.com>
coresight: etm3x: prohibit modifying cntr_val and reset while session is enabled
This commit attempts to prevent modifications to cntr_val and reset while
a CoreSight trace session is enabled. It adds a check for the current
mode using coresight_get_mode() before proceeding with the sysfs store
operations.
> diff --git a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
> --- a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
> @@ -74,6 +74,8 @@ static ssize_t reset_store(struct device *dev,
> ret = kstrtoul(buf, 16, &val);
> if (ret)
> return ret;
> + if (coresight_get_mode(drvdata->csdev))
> + return -EBUSY;
>
> if (val) {
> spin_lock(&drvdata->spinlock);
[Severity: Medium]
Could this lockless check introduce a time-of-check to time-of-use race?
If a concurrent thread starts a trace session via the enable_source sysfs
file right after coresight_get_mode() returns false, it might win the race
before spin_lock() is acquired here.
This could result in resetting the configuration of an active trace session
and erroneously releasing its trace ID, potentially leading to trace ID
collisions and hardware trace stream corruption.
[ ... ]
> @@ -744,6 +746,8 @@ static ssize_t cntr_val_store(struct device *dev,
> ret = kstrtoul(buf, 16, &val);
> if (ret)
> return ret;
> + if (coresight_get_mode(drvdata->csdev))
> + return -EBUSY;
>
> spin_lock(&drvdata->spinlock);
[Severity: Medium]
Is this susceptible to a similar race condition as reset_store?
Since coresight_get_mode() is checked outside the spinlock, a concurrent
thread could enable the session just before spin_lock() is acquired,
allowing the counter value to be modified while the session is active.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260915-separate_etm_cfg_v2-v11-0-d2b258d51747@arm.com?part=2
next prev parent reply other threads:[~2026-09-15 11:48 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 11:34 [PATCH v11 0/9] fix several inconsistencies with sysfs configuration in etmX Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 1/9] coresight: etm4x: prohibit modifying ss_status and cntr_val while session is enabled Yeoreum Yun
2026-09-15 11:51 ` sashiko-bot
2026-09-15 13:26 ` Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 2/9] coresight: etm3x: prohibit modifying cntr_val and reset " Yeoreum Yun
2026-09-15 11:48 ` sashiko-bot [this message]
2026-09-15 13:30 ` Yeoreum Yun
2026-09-15 13:55 ` Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 3/9] coresight: etm4x: fix inconsistencies with sysfs configuration Yeoreum Yun
2026-09-15 11:53 ` sashiko-bot
2026-09-15 12:36 ` Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 4/9] coresight: etm3x: " Yeoreum Yun
2026-09-15 11:47 ` sashiko-bot
2026-09-15 13:42 ` Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 5/9] coresight: etm3x: remove redundant cpu online check on etm_enable_sysfs() Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 6/9] coresight: etm4x: introduce struct etm4_caps Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 7/9] coresight: etm4x: exclude ss_status from drvdata->config Yeoreum Yun
2026-09-15 11:49 ` sashiko-bot
2026-09-15 13:35 ` Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 8/9] coresight: etm4x: remove s_ex_level from config Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 9/9] coresight: etm3x: introduce struct etm_caps Yeoreum Yun
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=20260915114845.CFA601F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yeoreum.yun@arm.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®