From: sashiko-bot@kernel.org
To: "Ivaylo Dimitrov" <ivo.g.dimitrov.75@gmail.com>
Cc: robh@kernel.org, olteanv@gmail.com,
linux-phy@lists.infradead.org, conor+dt@kernel.org,
vkoul@kernel.org, devicetree@vger.kernel.org,
neil.armstrong@linaro.org
Subject: Re: [PATCH v2 1/5] phy: cpcap-usb: Prevent line glitches from triggering sysrq
Date: Sun, 05 Jul 2026 08:08:59 +0000 [thread overview]
Message-ID: <20260705080900.5CF541F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260705075809.1793784-2-ivo.g.dimitrov.75@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Modifying system-wide SysRq state from a leaf PHY driver is a severe layer violation, and the implementation fails to disable SysRq in many configurations while also overwriting administrative changes.
- [High] Lockless manipulation of the global SysRq state introduces a data race that corrupts the input subsystem's handler list, leading to a kernel panic.
--
commit 1e47bb3741a2d7707b55cf24510e851f11fad240
Author: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
phy: cpcap-usb: Prevent line glitches from triggering sysrq
This commit temporarily disables sysrq support when switching between
USB and debug serial port modes to prevent line glitches from
triggering spurious sysrq events.
> diff --git a/drivers/phy/motorola/phy-cpcap-usb.c b/drivers/phy/motorola/phy-cpcap-usb.c
> index 7cb020dd3423c..d1c70c7153466 100644
> --- a/drivers/phy/motorola/phy-cpcap-usb.c
> +++ b/drivers/phy/motorola/phy-cpcap-usb.c
[ ... ]
> @@ -413,7 +414,12 @@ static int cpcap_usb_gpio_set_mode(struct cpcap_phy_ddata *ddata,
>
> static int cpcap_usb_set_uart_mode(struct cpcap_phy_ddata *ddata)
> {
> - int error;
> + int old_sysrq_mask, error;
> +
> + /* Disable sysrq to prevent random sysrq events on line glitches */
> + old_sysrq_mask = sysrq_mask();
> + if (old_sysrq_mask & 1)
> + sysrq_toggle_support(old_sysrq_mask & ~1);
[Severity: High]
Is it safe to modify the global sysrq state from a leaf PHY driver?
Arbitrarily toggling global SysRq state affects all input devices (keyboard,
network, etc.) system-wide.
Also, checking (old_sysrq_mask & 1) assumes bit 0 is always set when sysrq
is enabled. If the system uses a custom mask without bit 0 (like 0x01b6),
would this fail to disable sysrq and leave the system vulnerable to the
glitch panic?
Additionally, calling sysrq_toggle_support() locklessly from this background
worker path can race with administrative sysctl changes or other drivers.
If this races with another thread calling sysrq_toggle_support(), couldn't
both threads observe that sysrq_on() is false and concurrently call
sysrq_register_handler()?
Since sysrq_register_handler() uses input_register_handler() on a single
statically allocated sysrq_handler, registering it twice would corrupt the
input_handler_list and lead to a crash.
> /* Disable lines to prevent glitches from waking up mdm6600 */
> error = cpcap_usb_gpio_set_mode(ddata, CPCAP_UNKNOWN_DISABLED);
[ ... ]
> out_err:
> - dev_err(ddata->dev, "%s failed with %i\n", __func__, error);
> + if (old_sysrq_mask & 1)
> + sysrq_toggle_support(old_sysrq_mask);
[Severity: High]
By unconditionally restoring the old mask here, could this accidentally
clobber concurrent administrative changes made via sysctl kernel.sysrq while
the mode switch was happening?
> +
> + if (error)
> + dev_err(ddata->dev, "%s failed with %i\n", __func__, error);
>
> return error;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260705075809.1793784-1-ivo.g.dimitrov.75@gmail.com?part=1
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Ivaylo Dimitrov" <ivo.g.dimitrov.75@gmail.com>
Cc: robh@kernel.org, olteanv@gmail.com,
linux-phy@lists.infradead.org, conor+dt@kernel.org,
vkoul@kernel.org, devicetree@vger.kernel.org,
neil.armstrong@linaro.org
Subject: Re: [PATCH v2 1/5] phy: cpcap-usb: Prevent line glitches from triggering sysrq
Date: Sun, 05 Jul 2026 08:08:59 +0000 [thread overview]
Message-ID: <20260705080900.5CF541F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260705075809.1793784-2-ivo.g.dimitrov.75@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Modifying system-wide SysRq state from a leaf PHY driver is a severe layer violation, and the implementation fails to disable SysRq in many configurations while also overwriting administrative changes.
- [High] Lockless manipulation of the global SysRq state introduces a data race that corrupts the input subsystem's handler list, leading to a kernel panic.
--
commit 1e47bb3741a2d7707b55cf24510e851f11fad240
Author: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
phy: cpcap-usb: Prevent line glitches from triggering sysrq
This commit temporarily disables sysrq support when switching between
USB and debug serial port modes to prevent line glitches from
triggering spurious sysrq events.
> diff --git a/drivers/phy/motorola/phy-cpcap-usb.c b/drivers/phy/motorola/phy-cpcap-usb.c
> index 7cb020dd3423c..d1c70c7153466 100644
> --- a/drivers/phy/motorola/phy-cpcap-usb.c
> +++ b/drivers/phy/motorola/phy-cpcap-usb.c
[ ... ]
> @@ -413,7 +414,12 @@ static int cpcap_usb_gpio_set_mode(struct cpcap_phy_ddata *ddata,
>
> static int cpcap_usb_set_uart_mode(struct cpcap_phy_ddata *ddata)
> {
> - int error;
> + int old_sysrq_mask, error;
> +
> + /* Disable sysrq to prevent random sysrq events on line glitches */
> + old_sysrq_mask = sysrq_mask();
> + if (old_sysrq_mask & 1)
> + sysrq_toggle_support(old_sysrq_mask & ~1);
[Severity: High]
Is it safe to modify the global sysrq state from a leaf PHY driver?
Arbitrarily toggling global SysRq state affects all input devices (keyboard,
network, etc.) system-wide.
Also, checking (old_sysrq_mask & 1) assumes bit 0 is always set when sysrq
is enabled. If the system uses a custom mask without bit 0 (like 0x01b6),
would this fail to disable sysrq and leave the system vulnerable to the
glitch panic?
Additionally, calling sysrq_toggle_support() locklessly from this background
worker path can race with administrative sysctl changes or other drivers.
If this races with another thread calling sysrq_toggle_support(), couldn't
both threads observe that sysrq_on() is false and concurrently call
sysrq_register_handler()?
Since sysrq_register_handler() uses input_register_handler() on a single
statically allocated sysrq_handler, registering it twice would corrupt the
input_handler_list and lead to a crash.
> /* Disable lines to prevent glitches from waking up mdm6600 */
> error = cpcap_usb_gpio_set_mode(ddata, CPCAP_UNKNOWN_DISABLED);
[ ... ]
> out_err:
> - dev_err(ddata->dev, "%s failed with %i\n", __func__, error);
> + if (old_sysrq_mask & 1)
> + sysrq_toggle_support(old_sysrq_mask);
[Severity: High]
By unconditionally restoring the old mask here, could this accidentally
clobber concurrent administrative changes made via sysctl kernel.sysrq while
the mode switch was happening?
> +
> + if (error)
> + dev_err(ddata->dev, "%s failed with %i\n", __func__, error);
>
> return error;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260705075809.1793784-1-ivo.g.dimitrov.75@gmail.com?part=1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-07-05 8:09 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-05 7:58 [PATCH v2 0/5] phy: cpcap-usb: improve charger detection and export cable state Ivaylo Dimitrov
2026-07-05 7:58 ` Ivaylo Dimitrov
2026-07-05 7:58 ` [PATCH v2 1/5] phy: cpcap-usb: Prevent line glitches from triggering sysrq Ivaylo Dimitrov
2026-07-05 7:58 ` Ivaylo Dimitrov
2026-07-05 8:08 ` sashiko-bot [this message]
2026-07-05 8:08 ` sashiko-bot
2026-07-05 7:58 ` [PATCH v2 2/5] dt-bindings: phy: motorola,cpcap-usb: add chrg_det interrupt Ivaylo Dimitrov
2026-07-05 7:58 ` Ivaylo Dimitrov
2026-07-05 8:07 ` sashiko-bot
2026-07-05 8:07 ` sashiko-bot
2026-07-05 7:58 ` [PATCH v2 3/5] ARM: dts: ti: cpcap-mapphone: use charger detection interrupt for CPCAP USB PHY Ivaylo Dimitrov
2026-07-05 7:58 ` Ivaylo Dimitrov
2026-07-05 8:07 ` sashiko-bot
2026-07-05 8:07 ` sashiko-bot
2026-07-05 7:58 ` [PATCH v2 4/5] phy: cpcap-usb: add DCP detection and make UART idle mode optional Ivaylo Dimitrov
2026-07-05 7:58 ` Ivaylo Dimitrov
2026-07-05 8:10 ` sashiko-bot
2026-07-05 8:10 ` sashiko-bot
2026-07-05 7:58 ` [PATCH v2 5/5] phy: cpcap-usb: add extcon support Ivaylo Dimitrov
2026-07-05 7:58 ` Ivaylo Dimitrov
2026-07-05 8:11 ` sashiko-bot
2026-07-05 8:11 ` sashiko-bot
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=20260705080900.5CF541F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=ivo.g.dimitrov.75@gmail.com \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/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.