All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC char-misc-next 0/2] Add private pointer to struct cdev
@ 2022-01-03  5:01 Daniel Xu
  2022-01-03  5:01 ` [RFC char-misc-next 1/2] cdev: " 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
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Xu @ 2022-01-03  5:01 UTC (permalink / raw)
  To: arnd, gregkh, giometti, linux-kernel; +Cc: Daniel Xu, thesven73, ojeda

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


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

end of thread, other threads:[~2022-01-04  5:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-03  5:01 [RFC char-misc-next 0/2] Add private pointer to struct cdev Daniel Xu
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

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.