All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v1 0/3] Address potential user-after-free on module unload
@ 2019-02-04 22:09 Sven Van Asbroeck
  2019-02-04 22:09 ` [RFC v1 1/3] workqueue: Add resource-managed version of INIT_[DELAYED_]WORK() Sven Van Asbroeck
                   ` (3 more replies)
  0 siblings, 4 replies; 33+ messages in thread
From: Sven Van Asbroeck @ 2019-02-04 22:09 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Lai Jiangshan, linux-kernel, Sebastian Reichel, Dmitry Torokhov,
	Kees Cook

I think there _might_ be potential use-after-free issues on module unload.

They are hard to trigger, but I think I've seen them bring the whole
kernel down when they do occur. Can be triggered by doing an insmod of
a vulnerable module, rapidly followed by an rmmod.

Caused by drivers which schedule work / delayed_work, but do not clean it up
properly on module unload. Which means the work function could run _after_
the module has unloaded.

A quick grep through the kernel sources brings up many instances.
I leave it to people more knowledgeable than me to determine if this problem
is likely to happen, and/or if it can be exploited to become a security risk.

Perhaps developers can be 'nudged' into doing the right thing by using
resource-managed versions of INIT_WORK() / INIT_DELAYED_WORK(), which may
address the issue quite elegantly.

Attached is a proposal patch, followed by sample fixes for two vulnerable
modules. As far as I can tell, many more modules are vulnerable.

Sven Van Asbroeck (3):
  workqueue: Add resource-managed version of INIT_[DELAYED_]WORK()
  max17042_battery: fix potential user-after-free on module unload
  cap11xx: fix potential user-after-free on module unload

 drivers/input/keyboard/cap11xx.c        |  6 ++-
 drivers/power/supply/max17042_battery.c |  5 ++-
 include/linux/workqueue.h               |  7 ++++
 kernel/workqueue.c                      | 54 +++++++++++++++++++++++++
 4 files changed, 70 insertions(+), 2 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2019-02-14 17:52 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-04 22:09 [RFC v1 0/3] Address potential user-after-free on module unload Sven Van Asbroeck
2019-02-04 22:09 ` [RFC v1 1/3] workqueue: Add resource-managed version of INIT_[DELAYED_]WORK() Sven Van Asbroeck
2019-02-08 17:06   ` Tejun Heo
2019-02-08 18:15     ` Sven Van Asbroeck
2019-02-04 22:09 ` [RFC v1 2/3] max17042_battery: fix potential user-after-free on module unload Sven Van Asbroeck
2019-02-05  8:27   ` Dmitry Torokhov
2019-02-05 14:27     ` Sven Van Asbroeck
2019-02-05 17:21       ` Sebastian Reichel
2019-02-04 22:09 ` [RFC v1 3/3] cap11xx: " Sven Van Asbroeck
2019-02-05  8:18   ` Dmitry Torokhov
2019-02-05  8:34     ` Dmitry Torokhov
2019-02-05 21:24     ` Jacek Anaszewski
2019-02-05 21:43       ` Dmitry Torokhov
2019-02-05 22:03         ` Sven Van Asbroeck
2019-02-05 14:57 ` [RFC v1 0/3] Address " Kees Cook
2019-02-05 15:22   ` Sven Van Asbroeck
2019-02-05 18:43     ` Greg KH
2019-02-05 19:12       ` Sven Van Asbroeck
2019-02-06 16:46         ` Greg KH
2019-02-06 17:30           ` Dmitry Torokhov
2019-02-06 17:49             ` Sven Van Asbroeck
2019-02-08  6:51             ` Greg KH
2019-02-05 18:42   ` Greg KH
2019-02-07 21:49   ` Sven Van Asbroeck
2019-02-07 22:20     ` Dmitry Torokhov
2019-02-07 22:27       ` Sven Van Asbroeck
2019-02-07 22:32       ` Sven Van Asbroeck
2019-02-07 22:48         ` Dmitry Torokhov
2019-02-08  4:30         ` Miguel Ojeda
2019-02-10 18:05           ` Sven Van Asbroeck
2019-02-14  1:11             ` Miguel Ojeda
2019-02-14 15:23               ` Sven Van Asbroeck
     [not found]     ` <CAGngYiXcogd69n-MvBD1n5ZJpBzqCau8UOfLMgXEXLnAev=srw@mail.gmail.com>
     [not found]       ` <alpine.DEB.2.21.1902080745480.4201@hadrien>
2019-02-14 17:52         ` Fwd: " Sven Van Asbroeck

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.