* [PATCH] driver: core: Fix list corruption after device_del()
@ 2020-12-08 19:03 Takashi Iwai
2020-12-08 19:20 ` Rafael J. Wysocki
2020-12-08 19:52 ` Greg Kroah-Hartman
0 siblings, 2 replies; 4+ messages in thread
From: Takashi Iwai @ 2020-12-08 19:03 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Rafael J . Wysocki, linux-kernel
The device_links_purge() function (called from device_del()) tries to
remove the links.needs_suppliers list entry, but it's using
list_del(), hence it doesn't initialize after the removal. This is OK
for normal cases where device_del() is called via device_destroy().
However, it's not guaranteed that the device object will be really
deleted soon after device_del(). In a minor case like HD-audio codec
reconfiguration that re-initializes the device after device_del(), it
may lead to a crash by the corrupted list entry.
As a simple fix, replace list_del() with list_del_init() in order to
make the list intact after the device_del() call.
Fixes: e2ae9bcc4aaa ("driver core: Add support for linking devices during device addition")
Cc: <stable@vger.kernel.org>
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209207
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
drivers/base/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index d661ada1518f..e8cb66093f21 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1386,7 +1386,7 @@ static void device_links_purge(struct device *dev)
return;
mutex_lock(&wfs_lock);
- list_del(&dev->links.needs_suppliers);
+ list_del_init(&dev->links.needs_suppliers);
mutex_unlock(&wfs_lock);
/*
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] driver: core: Fix list corruption after device_del()
2020-12-08 19:03 [PATCH] driver: core: Fix list corruption after device_del() Takashi Iwai
@ 2020-12-08 19:20 ` Rafael J. Wysocki
2020-12-08 19:52 ` Greg Kroah-Hartman
1 sibling, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2020-12-08 19:20 UTC (permalink / raw)
To: Takashi Iwai
Cc: Greg Kroah-Hartman, Rafael J . Wysocki, Linux Kernel Mailing List
On Tue, Dec 8, 2020 at 8:03 PM Takashi Iwai <tiwai@suse.de> wrote:
>
> The device_links_purge() function (called from device_del()) tries to
> remove the links.needs_suppliers list entry, but it's using
> list_del(), hence it doesn't initialize after the removal. This is OK
> for normal cases where device_del() is called via device_destroy().
> However, it's not guaranteed that the device object will be really
> deleted soon after device_del(). In a minor case like HD-audio codec
> reconfiguration that re-initializes the device after device_del(), it
> may lead to a crash by the corrupted list entry.
>
> As a simple fix, replace list_del() with list_del_init() in order to
> make the list intact after the device_del() call.
>
> Fixes: e2ae9bcc4aaa ("driver core: Add support for linking devices during device addition")
> Cc: <stable@vger.kernel.org>
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209207
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/base/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index d661ada1518f..e8cb66093f21 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -1386,7 +1386,7 @@ static void device_links_purge(struct device *dev)
> return;
>
> mutex_lock(&wfs_lock);
> - list_del(&dev->links.needs_suppliers);
> + list_del_init(&dev->links.needs_suppliers);
> mutex_unlock(&wfs_lock);
>
> /*
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] driver: core: Fix list corruption after device_del()
2020-12-08 19:03 [PATCH] driver: core: Fix list corruption after device_del() Takashi Iwai
2020-12-08 19:20 ` Rafael J. Wysocki
@ 2020-12-08 19:52 ` Greg Kroah-Hartman
2020-12-08 20:25 ` Takashi Iwai
1 sibling, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2020-12-08 19:52 UTC (permalink / raw)
To: Takashi Iwai; +Cc: Rafael J . Wysocki, linux-kernel
On Tue, Dec 08, 2020 at 08:03:26PM +0100, Takashi Iwai wrote:
> The device_links_purge() function (called from device_del()) tries to
> remove the links.needs_suppliers list entry, but it's using
> list_del(), hence it doesn't initialize after the removal. This is OK
> for normal cases where device_del() is called via device_destroy().
> However, it's not guaranteed that the device object will be really
> deleted soon after device_del(). In a minor case like HD-audio codec
> reconfiguration that re-initializes the device after device_del(), it
> may lead to a crash by the corrupted list entry.
>
> As a simple fix, replace list_del() with list_del_init() in order to
> make the list intact after the device_del() call.
>
> Fixes: e2ae9bcc4aaa ("driver core: Add support for linking devices during device addition")
> Cc: <stable@vger.kernel.org>
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209207
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
> drivers/base/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index d661ada1518f..e8cb66093f21 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -1386,7 +1386,7 @@ static void device_links_purge(struct device *dev)
> return;
>
> mutex_lock(&wfs_lock);
> - list_del(&dev->links.needs_suppliers);
> + list_del_init(&dev->links.needs_suppliers);
> mutex_unlock(&wfs_lock);
Can this wait until 5.11-rc1 and then get backported, as it has been
around for a while, or are you hitting this on 5.10-rc7 now and need
this for 5.10-final?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] driver: core: Fix list corruption after device_del()
2020-12-08 19:52 ` Greg Kroah-Hartman
@ 2020-12-08 20:25 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2020-12-08 20:25 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Rafael J . Wysocki, linux-kernel
On Tue, 08 Dec 2020 20:52:34 +0100,
Greg Kroah-Hartman wrote:
>
> On Tue, Dec 08, 2020 at 08:03:26PM +0100, Takashi Iwai wrote:
> > The device_links_purge() function (called from device_del()) tries to
> > remove the links.needs_suppliers list entry, but it's using
> > list_del(), hence it doesn't initialize after the removal. This is OK
> > for normal cases where device_del() is called via device_destroy().
> > However, it's not guaranteed that the device object will be really
> > deleted soon after device_del(). In a minor case like HD-audio codec
> > reconfiguration that re-initializes the device after device_del(), it
> > may lead to a crash by the corrupted list entry.
> >
> > As a simple fix, replace list_del() with list_del_init() in order to
> > make the list intact after the device_del() call.
> >
> > Fixes: e2ae9bcc4aaa ("driver core: Add support for linking devices during device addition")
> > Cc: <stable@vger.kernel.org>
> > BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209207
> > Signed-off-by: Takashi Iwai <tiwai@suse.de>
> > ---
> > drivers/base/core.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/base/core.c b/drivers/base/core.c
> > index d661ada1518f..e8cb66093f21 100644
> > --- a/drivers/base/core.c
> > +++ b/drivers/base/core.c
> > @@ -1386,7 +1386,7 @@ static void device_links_purge(struct device *dev)
> > return;
> >
> > mutex_lock(&wfs_lock);
> > - list_del(&dev->links.needs_suppliers);
> > + list_del_init(&dev->links.needs_suppliers);
> > mutex_unlock(&wfs_lock);
>
> Can this wait until 5.11-rc1 and then get backported, as it has been
> around for a while, or are you hitting this on 5.10-rc7 now and need
> this for 5.10-final?
This is rather a minor (but long-standing) issue, so no problem to
wait for 5.11.
thanks,
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-12-08 20:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 19:03 [PATCH] driver: core: Fix list corruption after device_del() Takashi Iwai
2020-12-08 19:20 ` Rafael J. Wysocki
2020-12-08 19:52 ` Greg Kroah-Hartman
2020-12-08 20:25 ` Takashi Iwai
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.