mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Xu <dxu@dxuuu.xyz>
To: arnd@arndb.de, gregkh@linuxfoundation.org, giometti@enneenne.com,
	linux-kernel@vger.kernel.org
Cc: Daniel Xu <dxu@dxuuu.xyz>, thesven73@gmail.com, ojeda@kernel.org
Subject: [RFC char-misc-next 0/2] Add private pointer to struct cdev
Date: Sun,  2 Jan 2022 21:01:38 -0800	[thread overview]
Message-ID: <cover.1641185192.git.dxu@dxuuu.xyz> (raw)

The details are explained more thoroughly in the actual commits, but the
basic idea behind this RFC patchset is that:

* Using cdev_init() on an embedded struct cdev can lead to subtle
  use-after-free issues
* Switching to cdev_alloc() and storing a pointer fixes the lifetime
  issues but also breaks container_of()
* Deal with container_of() breakage by adding a void *private field

I've "fixed" (I'm aware module unloading is best-effort and may not
constitute a "real" bug) the issue in a random driver I found that
exhibits the issue. The other drivers I've seen with the issue are hard
for me to load/unload, so just one for now.

If this patchset is deemed acceptable, I'd be happy to convert other
broken drivers I find, but with the understanding that the best I can do
for testing is compiling them.

Daniel Xu (2):
  cdev: Add private pointer to struct cdev
  pps: Fix use-after-free cdev bug on module unload

 drivers/pps/pps.c          | 20 +++++++++++---------
 include/linux/cdev.h       |  1 +
 include/linux/pps_kernel.h |  2 +-
 3 files changed, 13 insertions(+), 10 deletions(-)

-- 
2.34.1


             reply	other threads:[~2022-01-03  5:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-03  5:01 Daniel Xu [this message]
2022-01-03  5:01 ` [RFC char-misc-next 1/2] cdev: " Daniel Xu
2022-01-03 14:04   ` Greg KH
2022-01-04  5:19     ` Daniel Xu
2022-01-03  5:01 ` [RFC char-misc-next 2/2] pps: Fix use-after-free cdev bug on module unload Daniel Xu
2022-01-03 14:06   ` Greg KH
2022-01-04  5:26     ` Daniel Xu

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=cover.1641185192.git.dxu@dxuuu.xyz \
    --to=dxu@dxuuu.xyz \
    --cc=arnd@arndb.de \
    --cc=giometti@enneenne.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=thesven73@gmail.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

Powered by JetHome