mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Usyskin <alexander.usyskin@intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Reuven Abliyev <reuven.abliyev@intel.com>,
	Alexander Usyskin <alexander.usyskin@intel.com>,
	linux-kernel@vger.kernel.org
Subject: [char-misc-next v3 0/5] mei: fix mei_device lifetime
Date: Wed,  9 Jul 2025 18:13:39 +0300	[thread overview]
Message-ID: <20250709151344.104942-1-alexander.usyskin@intel.com> (raw)

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 device is
opened when parent device is destroyed.

Connect mei_device structure lifteme to mei class device lifetime
by adding mei_device free to class device remove callback.
Decouple character device lifetime from parwnt structure lifetime.

As dev pointer in mei_device structure is converted to non-pointer
device all dev_* calls should be touched in this patch series.

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

V2: Make cdev patches first to avoid double refcounting
    in the middle of the series.
    Replace manual refcount with special device.

V3: Use existing class device by Greg's insight, thanks!

Alexander Usyskin (5):
  mei: set parent for char device
  mei: make char device control its own lifetime
  mei: bus: use cldev in prints
  mei: more prints with client prefix
  mei: hook mei_device on class device

 drivers/misc/mei/bus-fixup.c    |  16 ++--
 drivers/misc/mei/bus.c          |  42 +++++-----
 drivers/misc/mei/client.c       |  82 +++++++++----------
 drivers/misc/mei/client.h       |   6 +-
 drivers/misc/mei/dma-ring.c     |   8 +-
 drivers/misc/mei/gsc-me.c       |  16 ++--
 drivers/misc/mei/hbm.c          | 135 +++++++++++++++-----------------
 drivers/misc/mei/hw-me.c        | 100 +++++++++++------------
 drivers/misc/mei/hw-txe.c       |  60 +++++++-------
 drivers/misc/mei/init.c         |  47 ++++++-----
 drivers/misc/mei/interrupt.c    |  47 ++++++-----
 drivers/misc/mei/main.c         | 135 +++++++++++++++++++-------------
 drivers/misc/mei/mei_dev.h      |  12 +--
 drivers/misc/mei/pci-me.c       |  20 ++---
 drivers/misc/mei/pci-txe.c      |   4 +-
 drivers/misc/mei/platform-vsc.c |  26 +++---
 16 files changed, 390 insertions(+), 366 deletions(-)

-- 
2.43.0


             reply	other threads:[~2025-07-09 15:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09 15:13 Alexander Usyskin [this message]
2025-07-09 15:13 ` [char-misc-next v3 1/5] mei: set parent for char device Alexander Usyskin
2025-07-10  5:31   ` Greg Kroah-Hartman
2025-07-16  9:47   ` Greg Kroah-Hartman
2025-07-09 15:13 ` [char-misc-next v3 2/5] mei: make char device control its own lifetime Alexander Usyskin
2025-07-16  9:54   ` Greg Kroah-Hartman
2025-07-17 11:54     ` Usyskin, Alexander
2025-07-09 15:13 ` [char-misc-next v3 3/5] mei: bus: use cldev in prints Alexander Usyskin
2025-07-09 15:13 ` [char-misc-next v3 4/5] mei: more prints with client prefix Alexander Usyskin
2025-07-09 15:13 ` [char-misc-next v3 5/5] mei: hook mei_device on class device Alexander Usyskin

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=20250709151344.104942-1-alexander.usyskin@intel.com \
    --to=alexander.usyskin@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reuven.abliyev@intel.com \
    /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

all inboxes | Powered by JetHome®