From: sashiko-bot@kernel.org
To: "Yeoreum Yun" <yeoreum.yun@arm.com>
Cc: linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND v13 04/14] coresight: etm4x: fix inconsistencies with sysfs configuration
Date: Sat, 03 Oct 2026 03:06:32 +0000 [thread overview]
Message-ID: <20261003030633.477A61F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261003-separate_etm_cfg_v2-v13-4-5d8a29aead95@arm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] coresight: data race in etm4_disable_sysfs() due to missing spinlock
--
commit 047fa1646a004922cd9c2e2d801758f38062c7c6
Author: Yeoreum Yun <yeoreum.yun@arm.com>
Subject: coresight: etm4x: fix inconsistencies with sysfs configuration
This commit separates the ETM4x configuration into a session-specific
curr_config and a sysfs-set config to prevent corruption and inconsistency.
It also removes drvdata->spinlock coverage from the enable/disable paths
except when explicitly accessing configuration fields.
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
[ ... ]
> @@ -1134,8 +1142,9 @@ static int etm4_disable_perf(struct coresight_device *csdev,
> static void etm4_disable_sysfs(struct coresight_device *csdev)
> {
> struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
> -
> - raw_spin_lock(&drvdata->spinlock);
> + struct etmv4_config *config = &drvdata->config;
> + const struct etmv4_config *curr_config = &drvdata->curr_config;
> + int i;
>
> /*
> * Executing etm4_disable_hw on the cpu whose ETM is being disabled
> @@ -1144,9 +1153,19 @@ static void etm4_disable_sysfs(struct coresight_device *csdev)
> smp_call_function_single(drvdata->cpu, etm4_disable_sysfs_smp_call,
> drvdata, 1);
>
> - raw_spin_unlock(&drvdata->spinlock);
> + /*
> + * Userspace may read ss_status and cntr_val through sysfs after
> + * the sysfs-session has been disabled.
> + */
> + for (i = 0; i < drvdata->nr_ss_cmp; i++)
> + config->ss_status[i] = curr_config->ss_status[i];
>
> - cscfg_csdev_disable_active_config(csdev);
> + for (i = 0; i < drvdata->nr_cntr; i++)
> + config->cntr_val[i] = curr_config->cntr_val[i];
> +
> + config->seq_state = curr_config->seq_state;
[Severity: Medium]
Does this modification to the config fields require drvdata->spinlock
protection?
The commit message notes the intent to remove the lock "except when to
access config fields", which is correctly followed during sysfs enable
via scoped_guard. However, sysfs readers expect this spinlock to be held
when reading these arrays.
For example, a sysfs read legitimately holds the lock here:
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c:sshot_status_show() {
...
raw_spin_lock(&drvdata->spinlock);
val = config->ss_status[config->ss_idx];
raw_spin_unlock(&drvdata->spinlock);
...
}
Writing to config->ss_status, config->cntr_val, and config->seq_state
concurrently without the lock in etm4_disable_sysfs() could create a
data race resulting in KCSAN warnings and inconsistent reads.
> +
> + coresight_set_mode(drvdata->csdev, CS_MODE_DISABLED);
>
> /*
> * we only release trace IDs when resetting sysfs.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261003-separate_etm_cfg_v2-v13-0-5d8a29aead95@arm.com?part=4
next prev parent reply other threads:[~2026-10-03 3:06 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-03 2:52 [PATCH RESEND v13 00/14] fix several inconsistencies with sysfs configuration in etmX Yeoreum Yun
2026-10-03 2:52 ` [PATCH RESEND v13 01/14] coresight: etm4x: read-back TRCSEQSTR at disabling and prohibit modifying seq_state while enabling Yeoreum Yun
2026-10-03 3:08 ` sashiko-bot
2026-10-03 3:44 ` Yeoreum Yun
2026-10-03 6:07 ` Suzuki K Poulose
2026-10-03 2:52 ` [PATCH RESEND v13 02/14] coresight: etm4x: prohibit modifying cntr_val while session is enabled Yeoreum Yun
2026-10-03 3:06 ` sashiko-bot
2026-10-03 4:29 ` Yeoreum Yun
2026-10-03 2:52 ` [PATCH RESEND v13 03/14] coresight: etm3x: prohibit modifying cntr_val and reset " Yeoreum Yun
2026-10-03 3:06 ` sashiko-bot
2026-10-03 4:34 ` Yeoreum Yun
2026-10-03 6:10 ` Suzuki K Poulose
2026-10-03 2:52 ` [PATCH RESEND v13 04/14] coresight: etm4x: fix inconsistencies with sysfs configuration Yeoreum Yun
2026-10-03 3:06 ` sashiko-bot [this message]
2026-10-03 4:40 ` Yeoreum Yun
2026-10-03 2:52 ` [PATCH RESEND v13 05/14] coresight: etm3x: " Yeoreum Yun
2026-10-03 2:52 ` [PATCH RESEND v13 06/14] coresight: etm3x: remove redundant cpu online check on etm_enable_sysfs() Yeoreum Yun
2026-10-03 2:52 ` [PATCH RESEND v13 07/14] coresight: etm4x: introduce struct etm4_caps Yeoreum Yun
2026-10-03 2:52 ` [PATCH RESEND v13 08/14] coresight: etm4x: exclude ss_status from drvdata->config Yeoreum Yun
2026-10-03 2:52 ` [PATCH RESEND v13 09/14] coresight: etm4x: remove s_ex_level from config Yeoreum Yun
2026-10-03 6:14 ` Suzuki K Poulose
2026-10-03 2:52 ` [PATCH RESEND v13 10/14] coresight: etm4x: rename local config as curr_config referring drvdata->curr_config Yeoreum Yun
2026-10-03 2:52 ` [PATCH RESEND v13 11/14] coresight: etm4x: rename drvdata->config to sysfs_config Yeoreum Yun
2026-10-03 2:52 ` [PATCH RESEND v13 12/14] coresight: etm3x: introduce struct etm_caps Yeoreum Yun
2026-10-03 2:52 ` [PATCH RESEND v13 13/14] coresight: etm3x: rename local config as curr_config referring drvdata->curr_config Yeoreum Yun
2026-10-03 2:52 ` [PATCH RESEND v13 14/14] coresight: etm3x: rename drvdata->config to sysfs_config Yeoreum Yun
2026-10-03 6:56 ` [PATCH RESEND v13 00/14] fix several inconsistencies with sysfs configuration in etmX Suzuki K Poulose
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=20261003030633.477A61F000FF@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.