From: "Sverdlin, Alexander" <alexander.sverdlin@siemens.com>
To: "sashiko-reviews@lists.linux.dev" <sashiko-reviews@lists.linux.dev>
Cc: "lee@kernel.org" <lee@kernel.org>,
"linux-leds@vger.kernel.org" <linux-leds@vger.kernel.org>
Subject: Re: [PATCH v3 4/4] leds: trigger: netdev: Serialize mode/interval stores with trigger lock
Date: Tue, 29 Sep 2026 12:37:43 +0000 [thread overview]
Message-ID: <20339b46edb23ade58d71417d82bcee160c00480.camel@siemens.com> (raw)
In-Reply-To: <20260929121934.AF3661F000FF@smtp.kernel.org>
Hi all,
On Tue, 2026-09-29 at 12:19 +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] leds: netdev: async work cancel allows zombie worker to overwrite hw offload
> --
>
> commit d51dca8c4abbb112c1f8e31383d3f2334d50c585
> Author: Alexander Sverdlin <alexander.sverdlin@siemens.com>
>
> leds: trigger: netdev: Serialize mode/interval stores with trigger lock
>
> This commit adds explicit mutex locking to serialize mode and interval stores.
> It replaces the synchronous delayed work cancellation with an asynchronous
> cancellation while holding the trigger lock.
>
> > diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
> > index b27a453bbb859..7ad61c4be282e 100644
> > --- a/drivers/leds/trigger/ledtrig-netdev.c
> > +++ b/drivers/leds/trigger/ledtrig-netdev.c
> [ ... ]
> > @@ -424,6 +424,10 @@ static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,
> > return -EINVAL;
> > }
> >
> > + /* async cancel: the worker takes this lock */
> > + mutex_lock(&trigger_data->lock);
> > +
> > + mode = trigger_data->mode;
> > assign_bit(bit, &mode, state);
> >
> > if (test_bit(TRIGGER_NETDEV_LINK, &mode) &&
> > @@ -436,20 +440,26 @@ static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,
> > test_bit(TRIGGER_NETDEV_LINK_25000, &mode) ||
> > test_bit(TRIGGER_NETDEV_LINK_40000, &mode) ||
> > test_bit(TRIGGER_NETDEV_LINK_50000, &mode) ||
> > - test_bit(TRIGGER_NETDEV_LINK_100000, &mode)))
> > + test_bit(TRIGGER_NETDEV_LINK_100000, &mode))) {
> > + mutex_unlock(&trigger_data->lock);
> > return -EINVAL;
> > + }
> >
> > - cancel_delayed_work_sync(&trigger_data->work);
> > + cancel_delayed_work(&trigger_data->work);
>
> [Severity: Medium]
> If the worker netdev_trig_work() is concurrently executing and blocked on
> trigger_data->lock, will this asynchronous cancel fail to stop it?
>
> Once netdev_led_attr_store() finishes configuring hardware offload and
> releases the lock, could the worker unblock and continue to execute?
>
> If it does, the worker doesn't appear to check trigger_data->hw_control
> before falling back to software blinking and rescheduling itself:
>
> drivers/leds/trigger/ledtrig-netdev.c:netdev_trig_work() {
> ...
> /* If we are not looking for RX/TX then return */
> if (!test_bit(TRIGGER_NETDEV_TX, &trigger_data->mode) &&
> !test_bit(TRIGGER_NETDEV_RX, &trigger_data->mode) &&
> !test_bit(TRIGGER_NETDEV_TX_ERR, &trigger_data->mode) &&
> !test_bit(TRIGGER_NETDEV_RX_ERR, &trigger_data->mode)) {
> mutex_unlock(&trigger_data->lock);
> return;
> }
> ...
> /* no check for hw_control */
> ...
> led_blink_set_oneshot(trigger_data->led_cdev, ...);
> trigger_data->last_activity = new_activity;
> }
>
> schedule_delayed_work(&trigger_data->work, ...);
>
> mutex_unlock(&trigger_data->lock);
> }
>
> Will this cause the zombie worker to permanently overwrite the hardware
> offload state configured here and waste CPU by continuously rescheduling
> itself?
Sashiko is right here, this requires re-work.
pw-bot: cr
--
Alexander Sverdlin
Siemens AG
www.siemens.com
prev parent reply other threads:[~2026-09-29 12:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 12:08 [PATCH v3 0/4] leds: trigger: netdev: fix sysfs_update_group() races A. Sverdlin
2026-09-29 12:08 ` [PATCH v3 1/4] leds: trigger: netdev: Put netdev on activate error path A. Sverdlin
2026-09-29 12:17 ` sashiko-bot
2026-09-29 12:08 ` [PATCH v3 2/4] leds: trigger: netdev: Access net_dev under trigger_data->lock in the worker A. Sverdlin
2026-09-29 12:22 ` sashiko-bot
2026-09-29 12:08 ` [PATCH v3 3/4] leds: trigger: netdev: Fix sysfs_update_group() races A. Sverdlin
2026-09-29 12:19 ` sashiko-bot
2026-09-29 12:08 ` [PATCH v3 4/4] leds: trigger: netdev: Serialize mode/interval stores with trigger lock A. Sverdlin
2026-09-29 12:19 ` sashiko-bot
2026-09-29 12:37 ` Sverdlin, Alexander [this message]
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=20339b46edb23ade58d71417d82bcee160c00480.camel@siemens.com \
--to=alexander.sverdlin@siemens.com \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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