From: Greg KH <gregkh@linuxfoundation.org>
To: l1za0.sec@gmail.com
Cc: mcgrof@kernel.org, russ.weight@linux.dev, rafael@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: firmware_loader: fix race between sysfs fallback cleanup and device removal
Date: Tue, 21 Apr 2026 16:14:44 +0200 [thread overview]
Message-ID: <2026042116-matrix-shield-01dd@gregkh> (raw)
In-Reply-To: <20260421135013.36322-1-l1za0.sec@gmail.com>
On Tue, Apr 21, 2026 at 09:49:57PM +0800, l1za0.sec@gmail.com wrote:
> From: Haocheng Yu <l1za0.sec@gmail.com>
>
> A WARNING in firmware_fallback_sysfs is reported by a modified
> Syzkaller-based kernel fuzzing tool that we developed.
>
> The cause of this issue is a possible race condition between
> firmware sysfs fallback cleanup and hot-plug or other device
> lifecycle paths.
How exactly? This device is under full control of this function, it
should "know" if it is registered or not. No other code path should be
ever unregistering it.
> In this case, fw_load_sysfs_fallback() might run cleanup after the
> fallback device has already been removed, i.e., it would execute
> device_del(), then dpm_sysfs_remove(), and finally trigger a
> warning in sysfs_remove_group().
How exactly does that happen?
> This problem can be avoided by adding device_is_registered()
> check before calling device_del().
>
> Signed-off-by: Haocheng Yu <l1za0.sec@gmail.com>
Do you have a reproducer for this issue?
> ---
> drivers/base/firmware_loader/fallback.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c
> index bf68e3947814..a8d8c494f82d 100644
> --- a/drivers/base/firmware_loader/fallback.c
> +++ b/drivers/base/firmware_loader/fallback.c
> @@ -116,8 +116,9 @@ static int fw_load_sysfs_fallback(struct fw_sysfs *fw_sysfs, long timeout)
> } else if (fw_priv->is_paged_buf && !fw_priv->data)
> retval = -ENOMEM;
>
> -out:
> - device_del(f_dev);
> +out:
> + if (device_is_registered(f_dev))
> + device_del(f_dev);
Again, this feels wrong. And why was the "out:" line added and added
back? That feels like something is odd with the diff?
thanks,
greg k-h
next prev parent reply other threads:[~2026-04-21 14:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 13:49 [PATCH] drivers: firmware_loader: fix race between sysfs fallback cleanup and device removal l1za0.sec
2026-04-21 14:14 ` Greg KH [this message]
2026-04-22 11:36 ` Li Zao
2026-04-22 11:52 ` Greg KH
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=2026042116-matrix-shield-01dd@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=l1za0.sec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=rafael@kernel.org \
--cc=russ.weight@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