public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/23] gpiolib: Adopt revocable mechanism for UAF prevention
@ 2026-01-16  8:10 Tzung-Bi Shih
  2026-01-16  8:10 ` [PATCH 01/23] gpiolib: Correct wrong kfree() usage for `kobj->name` Tzung-Bi Shih
                   ` (24 more replies)
  0 siblings, 25 replies; 49+ messages in thread
From: Tzung-Bi Shih @ 2026-01-16  8:10 UTC (permalink / raw)
  To: Benson Leung, Greg Kroah-Hartman, Rafael J . Wysocki,
	Danilo Krummrich, Bartosz Golaszewski, Linus Walleij
  Cc: Jonathan Corbet, Shuah Khan, linux-doc, linux-kernel,
	chrome-platform, linux-kselftest, tzungbi, Laurent Pinchart,
	Wolfram Sang, Simona Vetter, Dan Williams, Jason Gunthorpe,
	linux-gpio

This series transitions the UAF prevention logic within the GPIO core
(gpiolib) to use the 'revocable' mechanism.

The existing code aims to prevent UAF issues when the underlying GPIO
chip is removed.  This series replaces that custom logic with the
generic 'revocable' API, which is designed to handle such lifecycle
dependencies.  There should be no change in behavior.

This series depends on the 'revocable' API, introduced in [1].  Some
build bots may report errors due to undefined symbols related to
'revocable' until the dependency is merged.

[1] https://lore.kernel.org/chrome-platform/20260116080235.350305-1-tzungbi@kernel.org

Tzung-Bi Shih (23):
  gpiolib: Correct wrong kfree() usage for `kobj->name`
  gpiolib: cdev: Fix resource leaks on errors in gpiolib_cdev_register()
  gpiolib: Fix resource leaks on errors in gpiochip_add_data_with_key()
  gpiolib: Fix resource leaks on errors in lineinfo_changed_notify()
  gpiolib: cdev: Correct return code on memory allocation failure

=> The first 5 patches are fixes.  They aren't directly related to the
   replacement, and should be able to apply independently.

  gpiolib: Access `gpio_bus_type` in gpiochip_setup_dev()
  gpiolib: Remove redundant check for struct gpio_chip
  gpiolib: sysfs: Remove redundant check for struct gpio_chip
  gpiolib: Ensure struct gpio_chip for gpiochip_setup_dev()
  gpiolib: cdev: Don't check struct gpio_chip in gpio_chrdev_open()

=> The following 5 patches are refactors.  Makes the subsequent changes
   easier or at least clear.

  selftests: gpio: Add gpio-cdev-uaf tests

=> The following patch adds kselftest cases for some classic UAF
   scenarios.

  gpiolib: Add revocable provider handle for struct gpio_chip
  gpiolib: cdev: Leverage revocable for gpio_fileops
  gpiolib: cdev: Leverage revocable for linehandle_fileops
  gpiolib: cdev: Leverage revocable for line_fileops
  gpiolib: cdev: Leverage revocable for lineevent_fileops
  gpiolib: cdev: Leverage revocable for lineinfo_changed_notify
  gpiolib: Leverage revocable for gpiolib_sops

=> The following 7 patches start to replace the existing code.  They
   are intentionally making small changes for easier to review.

  revocable: Support to define revocable consumer handle on stack
  revocable: Add Kunit test case for DEFINE_REVOCABLE()
  selftests: revocable: Add test case for DEFINE_REVOCABLE()

=> The following 3 patches introduce a new way to define revocable
   consumer handles on stack and its test cases.

  gpiolib: Leverage revocable for other independent lifecycle instances

=> The following patch handles the "others" (i.e., the rest of those
   custom logic) by using DEFINE_REVOCABLE() to at least make the usage
   easier.  A big patch.

  gpiolib: Remove unused `chip` and `srcu` in struct gpio_device

=> The last patch removes the unused fields for the custom logic as all
   of them should be transiting to revocable.

 .../driver-api/driver-model/revocable.rst     |   5 +-
 drivers/base/revocable.c                      |  60 ++-
 drivers/base/revocable_test.c                 |  54 +++
 drivers/gpio/gpiolib-cdev.c                   | 262 ++++++-----
 drivers/gpio/gpiolib-cdev.h                   |   3 +-
 drivers/gpio/gpiolib-sysfs.c                  |  55 ++-
 drivers/gpio/gpiolib-sysfs.h                  |  11 +-
 drivers/gpio/gpiolib.c                        | 410 ++++++++++--------
 drivers/gpio/gpiolib.h                        |  27 +-
 include/linux/revocable.h                     |  30 +-
 .../drivers/base/revocable/revocable_test.c   |  12 +
 .../revocable/test_modules/revocable_test.c   |  37 +-
 tools/testing/selftests/gpio/Makefile         |   5 +-
 tools/testing/selftests/gpio/gpio-cdev-uaf.c  | 320 ++++++++++++++
 tools/testing/selftests/gpio/gpio-cdev-uaf.sh |  67 +++
 15 files changed, 974 insertions(+), 384 deletions(-)
 create mode 100644 tools/testing/selftests/gpio/gpio-cdev-uaf.c
 create mode 100755 tools/testing/selftests/gpio/gpio-cdev-uaf.sh

-- 
2.52.0.457.g6b5491de43-goog


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

end of thread, other threads:[~2026-01-27 15:56 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-16  8:10 [PATCH 00/23] gpiolib: Adopt revocable mechanism for UAF prevention Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 01/23] gpiolib: Correct wrong kfree() usage for `kobj->name` Tzung-Bi Shih
2026-01-16 13:15   ` Bartosz Golaszewski
2026-01-16 13:27     ` Greg Kroah-Hartman
2026-01-16 13:30       ` Bartosz Golaszewski
2026-01-20  4:29     ` Tzung-Bi Shih
2026-01-16 14:13   ` Jason Gunthorpe
2026-01-16 14:38     ` Bartosz Golaszewski
2026-01-20  4:30       ` Tzung-Bi Shih
2026-01-20  9:43         ` Bartosz Golaszewski
2026-01-16  8:10 ` [PATCH 02/23] gpiolib: cdev: Fix resource leaks on errors in gpiolib_cdev_register() Tzung-Bi Shih
2026-01-20  8:50   ` Bartosz Golaszewski
2026-01-20  9:34     ` Tzung-Bi Shih
2026-01-20  9:39       ` Bartosz Golaszewski
2026-01-16  8:10 ` [PATCH 03/23] gpiolib: Fix resource leaks on errors in gpiochip_add_data_with_key() Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 04/23] gpiolib: Fix resource leaks on errors in lineinfo_changed_notify() Tzung-Bi Shih
2026-01-16 13:26   ` Bartosz Golaszewski
2026-01-20  3:11     ` Tzung-Bi Shih
2026-01-20  8:49       ` Bartosz Golaszewski
2026-01-16  8:10 ` [PATCH 05/23] gpiolib: cdev: Correct return code on memory allocation failure Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 06/23] gpiolib: Access `gpio_bus_type` in gpiochip_setup_dev() Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 07/23] gpiolib: Remove redundant check for struct gpio_chip Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 08/23] gpiolib: sysfs: " Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 09/23] gpiolib: Ensure struct gpio_chip for gpiochip_setup_dev() Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 10/23] gpiolib: cdev: Don't check struct gpio_chip in gpio_chrdev_open() Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 11/23] selftests: gpio: Add gpio-cdev-uaf tests Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 12/23] gpiolib: Add revocable provider handle for struct gpio_chip Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 13/23] gpiolib: cdev: Leverage revocable for gpio_fileops Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 14/23] gpiolib: cdev: Leverage revocable for linehandle_fileops Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 15/23] gpiolib: cdev: Leverage revocable for line_fileops Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 16/23] gpiolib: cdev: Leverage revocable for lineevent_fileops Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 17/23] gpiolib: cdev: Leverage revocable for lineinfo_changed_notify Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 18/23] gpiolib: Leverage revocable for gpiolib_sops Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 19/23] revocable: Support to define revocable consumer handle on stack Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 20/23] revocable: Add Kunit test case for DEFINE_REVOCABLE() Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 21/23] selftests: revocable: Add " Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 22/23] gpiolib: Leverage revocable for other independent lifecycle instances Tzung-Bi Shih
2026-01-24 16:52   ` Johan Hovold
2026-01-26 13:58     ` Johan Hovold
2026-01-27 15:56       ` Tzung-Bi Shih
2026-01-16  8:10 ` [PATCH 23/23] gpiolib: Remove unused `chip` and `srcu` in struct gpio_device Tzung-Bi Shih
2026-01-16 10:35 ` [PATCH 00/23] gpiolib: Adopt revocable mechanism for UAF prevention Bartosz Golaszewski
2026-01-16 16:07   ` Laurent Pinchart
2026-01-17 12:48   ` Tzung-Bi Shih
2026-01-19  8:33     ` Bartosz Golaszewski
2026-01-21  4:17       ` Tzung-Bi Shih
2026-01-21 10:42         ` Bartosz Golaszewski
2026-01-19 14:21 ` (subset) " Bartosz Golaszewski
2026-01-20  3:13   ` Tzung-Bi Shih

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