mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [char-misc-next 0/3] mei: fix mei_device lifetime
@ 2025-06-18  9:54 Alexander Usyskin
  2025-06-18  9:54 ` [char-misc-next 1/3] mei: refcount mei_device Alexander Usyskin
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Alexander Usyskin @ 2025-06-18  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Reuven Abliyev, Alexander Usyskin, linux-kernel

mei_device data structure is allocated using devm_* functions
and hooked to the parent device.
It works for client systems where parent device is pci one.
When parent device is auxiliary bus device produced by
graphics driver, the parent can be destroyed before child
and on the way it cleans all allocated memory.
This leads to use-after-free if mei character is opened
when parent device is destroyed.
Introduce reference counting on mei_device and
decouple cdev from main structure to allow all memory
to be released when it is unused and not before.

Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14201

Alexander Usyskin (3):
  mei: refcount mei_device
  mei: set parent for char device
  mei: make char device control its own lifetime

 drivers/misc/mei/bus.c          | 10 ++++++---
 drivers/misc/mei/gsc-me.c       |  6 ++++--
 drivers/misc/mei/hw-me.c        |  2 +-
 drivers/misc/mei/hw-txe.c       |  2 +-
 drivers/misc/mei/init.c         | 35 +++++++++++++++++++++++++++++++
 drivers/misc/mei/main.c         | 37 ++++++++++++++++++++++-----------
 drivers/misc/mei/mei_dev.h      | 10 +++++++--
 drivers/misc/mei/pci-me.c       |  5 ++++-
 drivers/misc/mei/pci-txe.c      |  5 ++++-
 drivers/misc/mei/platform-vsc.c |  7 ++++---
 10 files changed, 93 insertions(+), 26 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2025-06-22  9:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-18  9:54 [char-misc-next 0/3] mei: fix mei_device lifetime Alexander Usyskin
2025-06-18  9:54 ` [char-misc-next 1/3] mei: refcount mei_device Alexander Usyskin
2025-06-21  9:07   ` Greg Kroah-Hartman
2025-06-22  9:14     ` Usyskin, Alexander
2025-06-22  9:21       ` Greg Kroah-Hartman
2025-06-18  9:54 ` [char-misc-next 2/3] mei: set parent for char device Alexander Usyskin
2025-06-18  9:54 ` [char-misc-next 3/3] mei: make char device control its own lifetime Alexander Usyskin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®