[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 00/11] kobject: Require explicit initialization of struct kobj_type::release
- To: Ian Rogers <irogers@xxxxxxxxxx>
- From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 14 Oct 2026 07:36:41 +0200
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=korg header.d=linuxfoundation.org header.i="@linuxfoundation.org" header.h="Date:From:To:Cc:Subject:References:In-Reply-To"
- Cc: "Rafael J . Wysocki" <rafael@xxxxxxxxxx>, Danilo Krummrich <dakr@xxxxxxxxxx>, Miguel Ojeda <ojeda@xxxxxxxxxx>, Kees Cook <kees@xxxxxxxxxx>, Nathan Chancellor <nathan@xxxxxxxxxx>, Nick Desaulniers <ndesaulniers@xxxxxxxxxx>, Bill Wendling <morbo@xxxxxxxxxx>, Justin Stitt <justinstitt@xxxxxxxxxx>, Jonathan Corbet <corbet@xxxxxxx>, Madhavan Srinivasan <maddy@xxxxxxxxxxxxx>, Michael Ellerman <mpe@xxxxxxxxxxxxxx>, Nicholas Piggin <npiggin@xxxxxxxxx>, Christophe Leroy <chleroy@xxxxxxxxxx>, Nayna Jain <nayna@xxxxxxxxxxxxx>, Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>, Rich Felker <dalias@xxxxxxxx>, John Paul Adrian Glaubitz <glaubitz@xxxxxxxxxxxxxxxxxxx>, Viresh Kumar <viresh.kumar@xxxxxxxxxx>, David Teigland <teigland@xxxxxxxxxx>, Alexander Aring <aahringo@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Heiko Carstens <hca@xxxxxxxxxxxxx>, Vasily Gorbik <gor@xxxxxxxxxxxxx>, Alexander Gordeev <agordeev@xxxxxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>, Sven Schnelle <svens@xxxxxxxxxxxxx>, Richard Weinberger <richard@xxxxxx>, Zhihao Cheng <chengzhihao1@xxxxxxxxxx>, Felix Kuehling <Felix.Kuehling@xxxxxxx>, Alex Deucher <alexander.deucher@xxxxxxx>, Christian König <christian.koenig@xxxxxxx>, driver-core@xxxxxxxxxxxxxxx, llvm@xxxxxxxxxxxxxxx, linux-hardening@xxxxxxxxxxxxxxx, linux-doc@xxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, linux-sh@xxxxxxxxxxxxxxx, linux-pm@xxxxxxxxxxxxxxx, linux-acpi@xxxxxxxxxxxxxxx, gfs2@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, linux-mtd@xxxxxxxxxxxxxxxxxxx, amd-gfx@xxxxxxxxxxxxxxxxxxxxx, dri-devel@xxxxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
- Delivery-date: Wed, 14 Oct 2026 05:37:10 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Tue, Oct 13, 2026 at 03:39:35PM -0700, Ian Rogers wrote:
> 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.
Cool, sorry I missed that talk.
> 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.
Sounds great, but let's fix up the users before adding the attribute.
Looks like some of these need another version so it might take a bit of
time to get them all merged.
thanks,
greg k-h
|