* [PATCH] auxdisplay: ht16k33: fix potential user-after-free on module unload
@ 2019-02-09 0:15 Miguel Ojeda
2019-02-09 16:52 ` Dmitry Torokhov
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Miguel Ojeda @ 2019-02-09 0:15 UTC (permalink / raw)
To: Robin van der Gracht
Cc: Sven Van Asbroeck, Tejun Heo, Lai Jiangshan, Sebastian Reichel,
Dmitry Torokhov, Kees Cook, linux-kernel
On module unload/remove, we need to ensure that work does not run
after we have freed resources. Concretely, cancel_delayed_work()
may return while the callback function is still running.
From kernel/workqueue.c:
The work callback function may still be running on return,
unless it returns true and the work doesn't re-arm itself.
Explicitly flush or use cancel_delayed_work_sync() to wait on it.
Link: https://lore.kernel.org/lkml/20190204220952.30761-1-TheSven73@googlemail.com/
Reported-by: Sven Van Asbroeck <thesven73@gmail.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
---
drivers/auxdisplay/ht16k33.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c
index a43276c76fc6..21393ec3b9a4 100644
--- a/drivers/auxdisplay/ht16k33.c
+++ b/drivers/auxdisplay/ht16k33.c
@@ -509,7 +509,7 @@ static int ht16k33_remove(struct i2c_client *client)
struct ht16k33_priv *priv = i2c_get_clientdata(client);
struct ht16k33_fbdev *fbdev = &priv->fbdev;
- cancel_delayed_work(&fbdev->work);
+ cancel_delayed_work_sync(&fbdev->work);
unregister_framebuffer(fbdev->info);
framebuffer_release(fbdev->info);
free_page((unsigned long) fbdev->buffer);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] auxdisplay: ht16k33: fix potential user-after-free on module unload
2019-02-09 0:15 [PATCH] auxdisplay: ht16k33: fix potential user-after-free on module unload Miguel Ojeda
@ 2019-02-09 16:52 ` Dmitry Torokhov
2019-02-10 22:03 ` Sven Van Asbroeck
2019-02-11 7:26 ` Robin van der Gracht
2 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2019-02-09 16:52 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Robin van der Gracht, Sven Van Asbroeck, Tejun Heo,
Lai Jiangshan, Sebastian Reichel, Kees Cook, linux-kernel
On Sat, Feb 09, 2019 at 01:15:22AM +0100, Miguel Ojeda wrote:
> On module unload/remove, we need to ensure that work does not run
> after we have freed resources. Concretely, cancel_delayed_work()
> may return while the callback function is still running.
>
> From kernel/workqueue.c:
>
> The work callback function may still be running on return,
> unless it returns true and the work doesn't re-arm itself.
> Explicitly flush or use cancel_delayed_work_sync() to wait on it.
>
> Link: https://lore.kernel.org/lkml/20190204220952.30761-1-TheSven73@googlemail.com/
> Reported-by: Sven Van Asbroeck <thesven73@gmail.com>
> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/auxdisplay/ht16k33.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c
> index a43276c76fc6..21393ec3b9a4 100644
> --- a/drivers/auxdisplay/ht16k33.c
> +++ b/drivers/auxdisplay/ht16k33.c
> @@ -509,7 +509,7 @@ static int ht16k33_remove(struct i2c_client *client)
> struct ht16k33_priv *priv = i2c_get_clientdata(client);
> struct ht16k33_fbdev *fbdev = &priv->fbdev;
>
> - cancel_delayed_work(&fbdev->work);
> + cancel_delayed_work_sync(&fbdev->work);
> unregister_framebuffer(fbdev->info);
> framebuffer_release(fbdev->info);
> free_page((unsigned long) fbdev->buffer);
> --
> 2.17.1
>
--
Dmitry
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] auxdisplay: ht16k33: fix potential user-after-free on module unload
2019-02-09 0:15 [PATCH] auxdisplay: ht16k33: fix potential user-after-free on module unload Miguel Ojeda
2019-02-09 16:52 ` Dmitry Torokhov
@ 2019-02-10 22:03 ` Sven Van Asbroeck
2019-02-11 7:26 ` Robin van der Gracht
2 siblings, 0 replies; 5+ messages in thread
From: Sven Van Asbroeck @ 2019-02-10 22:03 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Robin van der Gracht, Tejun Heo, Lai Jiangshan,
Sebastian Reichel, Dmitry Torokhov, Kees Cook,
Linux Kernel Mailing List
On Fri, Feb 8, 2019 at 7:15 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On module unload/remove, we need to ensure that work does not run
> after we have freed resources. Concretely, cancel_delayed_work()
> may return while the callback function is still running.
>
> From kernel/workqueue.c:
>
> The work callback function may still be running on return,
> unless it returns true and the work doesn't re-arm itself.
> Explicitly flush or use cancel_delayed_work_sync() to wait on it.
>
> Link: https://lore.kernel.org/lkml/20190204220952.30761-1-TheSven73@googlemail.com/
> Reported-by: Sven Van Asbroeck <thesven73@gmail.com>
> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Yes, this should do the trick.
Reviewed-by: Sven Van Asbroeck <TheSven73@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] auxdisplay: ht16k33: fix potential user-after-free on module unload
2019-02-09 0:15 [PATCH] auxdisplay: ht16k33: fix potential user-after-free on module unload Miguel Ojeda
2019-02-09 16:52 ` Dmitry Torokhov
2019-02-10 22:03 ` Sven Van Asbroeck
@ 2019-02-11 7:26 ` Robin van der Gracht
2019-02-14 1:12 ` Miguel Ojeda
2 siblings, 1 reply; 5+ messages in thread
From: Robin van der Gracht @ 2019-02-11 7:26 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Sven Van Asbroeck, Tejun Heo, Lai Jiangshan, Sebastian Reichel,
Dmitry Torokhov, Kees Cook, linux-kernel
On Sat, 9 Feb 2019 01:15:22 +0100
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:
> On module unload/remove, we need to ensure that work does not run
> after we have freed resources. Concretely, cancel_delayed_work()
> may return while the callback function is still running.
>
> From kernel/workqueue.c:
>
> The work callback function may still be running on return,
> unless it returns true and the work doesn't re-arm itself.
> Explicitly flush or use cancel_delayed_work_sync() to wait on it.
>
> Link: https://lore.kernel.org/lkml/20190204220952.30761-1-TheSven73@googlemail.com/
> Reported-by: Sven Van Asbroeck <thesven73@gmail.com>
> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> ---
> drivers/auxdisplay/ht16k33.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c
> index a43276c76fc6..21393ec3b9a4 100644
> --- a/drivers/auxdisplay/ht16k33.c
> +++ b/drivers/auxdisplay/ht16k33.c
> @@ -509,7 +509,7 @@ static int ht16k33_remove(struct i2c_client *client)
> struct ht16k33_priv *priv = i2c_get_clientdata(client);
> struct ht16k33_fbdev *fbdev = &priv->fbdev;
>
> - cancel_delayed_work(&fbdev->work);
> + cancel_delayed_work_sync(&fbdev->work);
> unregister_framebuffer(fbdev->info);
> framebuffer_release(fbdev->info);
> free_page((unsigned long) fbdev->buffer);
Looks good
Acked-by: Robin van der Gracht <robin@protonic.nl>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] auxdisplay: ht16k33: fix potential user-after-free on module unload
2019-02-11 7:26 ` Robin van der Gracht
@ 2019-02-14 1:12 ` Miguel Ojeda
0 siblings, 0 replies; 5+ messages in thread
From: Miguel Ojeda @ 2019-02-14 1:12 UTC (permalink / raw)
To: Robin van der Gracht
Cc: Sven Van Asbroeck, Tejun Heo, Lai Jiangshan, Sebastian Reichel,
Dmitry Torokhov, Kees Cook, linux-kernel
On Mon, Feb 11, 2019 at 8:26 AM Robin van der Gracht <robin@protonic.nl> wrote:
>
> Looks good
>
> Acked-by: Robin van der Gracht <robin@protonic.nl>
Thanks all! I will send this for -rc7.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-02-14 1:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-09 0:15 [PATCH] auxdisplay: ht16k33: fix potential user-after-free on module unload Miguel Ojeda
2019-02-09 16:52 ` Dmitry Torokhov
2019-02-10 22:03 ` Sven Van Asbroeck
2019-02-11 7:26 ` Robin van der Gracht
2019-02-14 1:12 ` Miguel Ojeda
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.