All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] kobject: Require explicit initialization of struct kobj_type::release
@ 2026-10-13 22:39 ` Ian Rogers
  0 siblings, 0 replies; 52+ messages in thread
From: Ian Rogers @ 2026-10-13 22:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich,
	Miguel Ojeda, Kees Cook, Nathan Chancellor
  Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, Jonathan Corbet,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Nayna Jain, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, Viresh Kumar, David Teigland,
	Alexander Aring, Juergen Gross, Stefano Stabellini,
	Oleksandr Tyshchenko, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Richard Weinberger, Zhihao Cheng, Felix Kuehling, Alex Deucher,
	Christian König, driver-core, llvm, linux-hardening,
	linux-doc, linuxppc-dev, linux-sh, linux-pm, linux-acpi, gfs2,
	xen-devel, linux-s390, linux-mtd, amd-gfx, dri-devel,
	linux-kernel, Ian Rogers

Clang supports the 'require_explicit_initialization' attribute on struct
fields to enforce that the field is explicitly initialized when an
aggregate object is constructed, emitting -Wuninitialized-explicit-init
(enabled by default) if the field is omitted.

Following discussion at the Linux Plumbers Conference [1], this series
introduces __require_explicit_initialization in
include/linux/compiler_attributes.h and applies it to
struct kobj_type::release.

As Documentation/core-api/kobject.rst notes:
  "One important point cannot be overstated: every kobject must have a
  release() method, and the kobject must persist (in a consistent state)
  until that method is called. If these constraints are not met, the code
  is flawed."

Annotating struct kobj_type::release caught 30 struct kobj_type
definitions across the tree that omitted .release:
- Patches 2-10 fix 10 struct kobj_type definitions where dynamically
  allocated kobjects, ksets, or enclosing structures were either leaked on
  kobject_put() or freed prematurely before kobject release (risking a
  use-after-free when CONFIG_DEBUG_KOBJECT_RELEASE=y).
- Patch 11 annotates struct kobj_type::release with
  __require_explicit_initialization and explicitly sets .release = NULL
  (with explanatory comments) on the remaining legacy struct kobj_type
  definitions whose kobjects are static, per-CPU, or embedded in devm- or
  parent-managed structures.

[1] https://lpc.events/event/20/contributions/2392/

Ian Rogers (11):
  Compiler Attributes: Add __require_explicit_initialization macro
  powerpc/secvar: Add missing kobject release callback to secvar_ktype
  sh: sq: Add missing kobject release callback to ktype_percpu_entry
  cpufreq: Initialize kobj_type release callback in ondemand and
    conservative governors
  ACPI: CPPC: Free cpc_desc in kobject release callback
  dlm: Free dlm_ls in kobject release callback
  xen/sys-hypervisor: Add release callback to hyp_sysfs_kobj_type
  s390/sclp_mem: Allocate struct sclp_mem dynamically and add kobject
    release
  ubifs: sysfs: Use kset_create_and_add() for ubifs_kset
  drm/amdkfd: Free queue in procfs_queue_type kobject release callback
  kobject: Require explicit initialization of struct kobj_type::release

 Documentation/conf.py                         |  1 +
 arch/arm64/kernel/cpuinfo.c                   |  2 +
 arch/powerpc/kernel/secvar-sysfs.c            |  6 ++
 arch/sh/kernel/cpu/sh4/sq.c                   |  6 ++
 drivers/acpi/cppc_acpi.c                      | 39 +++++-----
 drivers/acpi/sysfs.c                          |  2 +
 drivers/cpufreq/cpufreq_conservative.c        |  5 +-
 drivers/cpufreq/cpufreq_governor.c            |  3 +-
 drivers/cpufreq/cpufreq_governor.h            |  1 +
 drivers/cpufreq/cpufreq_ondemand.c            |  5 +-
 drivers/dma/ioat/sysfs.c                      |  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c       |  4 +
 drivers/gpu/drm/amd/amdkfd/kfd_process.c      | 10 ++-
 drivers/gpu/drm/amd/amdkfd/kfd_queue.c        |  5 +-
 drivers/infiniband/hw/hfi1/sysfs.c            |  2 +
 drivers/infiniband/hw/usnic/usnic_ib_sysfs.c  |  2 +
 drivers/parisc/pdc_stable.c                   |  2 +
 drivers/power/supply/ab8500_fg.c              |  2 +
 drivers/s390/char/sclp_mem.c                  | 73 +++++++++----------
 drivers/soc/hisilicon/kunpeng_hccs.c          |  6 ++
 .../fbdev/omap2/omapfb/dss/display-sysfs.c    |  2 +
 .../fbdev/omap2/omapfb/dss/manager-sysfs.c    |  2 +
 .../fbdev/omap2/omapfb/dss/overlay-sysfs.c    |  2 +
 drivers/xen/sys-hypervisor.c                  |  6 ++
 fs/dlm/lockspace.c                            | 19 +++--
 fs/erofs/sysfs.c                              |  4 +
 fs/f2fs/sysfs.c                               |  6 ++
 fs/ocfs2/cluster/masklog.c                    |  2 +
 fs/ubifs/sysfs.c                              | 24 ++----
 include/linux/compiler_attributes.h           | 11 +++
 include/linux/kobject.h                       |  2 +-
 scripts/checkpatch.pl                         |  1 +
 tools/lib/python/kdoc/xforms_lists.py         |  1 +
 33 files changed, 170 insertions(+), 90 deletions(-)

-- 
2.56.0.385.gd3acb90ef8-goog



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

end of thread, other threads:[~2026-10-14 12:05 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 22:39 [PATCH 00/11] kobject: Require explicit initialization of struct kobj_type::release Ian Rogers
2026-10-13 22:39 ` Ian Rogers
2026-10-13 22:39 ` [PATCH 01/11] Compiler Attributes: Add __require_explicit_initialization macro Ian Rogers
2026-10-13 22:39   ` Ian Rogers
2026-10-13 22:48   ` sashiko-bot
2026-10-14  7:27   ` Christian König
2026-10-14  7:27     ` Christian König
2026-10-14 11:28   ` Miguel Ojeda
2026-10-14 11:28     ` Miguel Ojeda
2026-10-13 22:39 ` [PATCH 02/11] powerpc/secvar: Add missing kobject release callback to secvar_ktype Ian Rogers
2026-10-13 22:39   ` Ian Rogers
2026-10-13 22:47   ` sashiko-bot
2026-10-13 22:39 ` [PATCH 03/11] sh: sq: Add missing kobject release callback to ktype_percpu_entry Ian Rogers
2026-10-13 22:39   ` Ian Rogers
2026-10-13 22:53   ` sashiko-bot
2026-10-13 22:39 ` [PATCH 04/11] cpufreq: Initialize kobj_type release callback in ondemand and conservative governors Ian Rogers
2026-10-13 22:39   ` Ian Rogers
2026-10-13 22:52   ` sashiko-bot
2026-10-14  4:24   ` Zhongqiu Han
2026-10-14  4:24     ` Zhongqiu Han
2026-10-13 22:39 ` [PATCH 05/11] ACPI: CPPC: Free cpc_desc in kobject release callback Ian Rogers
2026-10-13 22:39   ` Ian Rogers
2026-10-13 22:54   ` sashiko-bot
2026-10-13 22:54     ` sashiko-bot
2026-10-13 22:39 ` [PATCH 06/11] dlm: Free dlm_ls " Ian Rogers
2026-10-13 22:39   ` Ian Rogers
2026-10-13 22:55   ` sashiko-bot
2026-10-13 22:55     ` sashiko-bot
2026-10-13 22:39 ` [PATCH 07/11] xen/sys-hypervisor: Add release callback to hyp_sysfs_kobj_type Ian Rogers
2026-10-13 22:39   ` Ian Rogers
2026-10-13 22:52   ` sashiko-bot
2026-10-13 22:39 ` [PATCH 08/11] s390/sclp_mem: Allocate struct sclp_mem dynamically and add kobject release Ian Rogers
2026-10-13 22:39   ` Ian Rogers
2026-10-13 22:48   ` sashiko-bot
2026-10-13 22:48     ` sashiko-bot
2026-10-14 12:04   ` Sumanth Korikkar
2026-10-14 12:04     ` Sumanth Korikkar
2026-10-13 22:39 ` [PATCH 09/11] ubifs: sysfs: Use kset_create_and_add() for ubifs_kset Ian Rogers
2026-10-13 22:39   ` Ian Rogers
2026-10-13 22:47   ` sashiko-bot
2026-10-14 11:51   ` Zhihao Cheng
2026-10-14 11:51     ` Zhihao Cheng
2026-10-13 22:39 ` [PATCH 10/11] drm/amdkfd: Free queue in procfs_queue_type kobject release callback Ian Rogers
2026-10-13 22:39   ` Ian Rogers
2026-10-13 22:57   ` sashiko-bot
2026-10-13 22:57     ` sashiko-bot
2026-10-13 22:39 ` [PATCH 11/11] kobject: Require explicit initialization of struct kobj_type::release Ian Rogers
2026-10-13 22:39   ` Ian Rogers
2026-10-13 22:56   ` sashiko-bot
2026-10-13 22:56     ` sashiko-bot
2026-10-14  5:36 ` [PATCH 00/11] " Greg Kroah-Hartman
2026-10-14  5:36   ` Greg Kroah-Hartman

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.