[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: Kees Cook <kees@xxxxxxxxxx>
- From: Ian Rogers <irogers@xxxxxxxxxx>
- Date: Wed, 14 Oct 2026 09:41:25 -0700
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=NIItl0pCQ/aBq2U1h8kgQBz3yZb99mdO46VMaoMNnUw=; fh=7Sl6RuB46XcB3hLo2hiDeMAC2zJfk/KndZQSgKU/DKk=; b=p08iKYvinnGnAkabL0PtJsV2R+EUuJAS7GQthfqNF80hM+X3Yw5IUS5FZX+d0Bvscr ZDlojeDy7KmD2oz2wIP7s9jCL8nezyiyeQbnmNsdgdhjCkdvpfW0fRBwWZrXE//40zXO S6pJZ9bBqTnyTlFknZynDB1tHfcP90UjNRrvlDlhXXzN3Ixl3/6ciYhP3S56hpupPksZ YOatmHx/ztl95lxI/Z/KBSvrJDv+VuzVaoM4/gwW1bUCK0KBXesjqXTa8FQd0T+jZ2Ug nP1R2N7+/eoNnS7Xq6kCcQ4vOhniHH1KbtpAxJEcxVldEWtcI8nnY7MfyUMm86JeJCWM TFCQ==; darn=lists.xenproject.org
- Arc-seal: i=1; a=rsa-sha256; t=1791996098; cv=none; d=google.com; s=arc-20260327; b=OAOAO1AGIoELK0SFEyO41SduL8KlZ87ioDH/zCSiCSGYWkzGDt94RIKaoXP3o7YGHm XfHsnTTKOE8ox5r5A9Gk0s2NkYDnsWlp6LiJ2kqKG5QN0S8SSJUgDMntjs3HbTOohwBr /dqSAbQDqV1fuVDpC68U7II6Ht+LiGcmINF0KOIbGTgx5zeW3rmYYKaI1qoOjoIHHeg0 UPQ6i5G0vo0H3XH1zqKPyP/PmV+0kJs1z1Mlk4y3S3Ge0KHBYWYyNt5UaYkcGlhy6OBh 02UDbp1sXNKNJ6bCV7uRAjHaKiDMiyYyC/CtnK2VZBiePfTU8Ig3h58DrraL4fl9b06r 6ekg==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=google.com header.i="@google.com" header.h="Content-Transfer-Encoding:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
- Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, "Rafael J . Wysocki" <rafael@xxxxxxxxxx>, Danilo Krummrich <dakr@xxxxxxxxxx>, Miguel Ojeda <ojeda@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 16:41:41 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Wed, Oct 14, 2026 at 9:37 AM Kees Cook <kees@xxxxxxxxxx> wrote:
>
> On Wed, Oct 14, 2026 at 07:36:41AM +0200, Greg Kroah-Hartman wrote:
> > 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.
>
> Yeah, I'm really liking these compile-time checks. :)
>
> >
> > > 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.
>
> I'd really like to have the attribute available, and I've got at least
> one user I can apply today that don't require fix-ups (seq_file), so
> if Miguel is okay with it, I'd like to snag patch 1 and send it with
> my seq_file "first user" for this coming merge window so it's available
> starting with v7.4-rc1, and we don't end up needing to wait 10 weeks for
> other subsystems to be able to use it. And the kobj fixups can continue
> in parallel. Does that sounds okay?
I'm happy with that. I'm working to address/incorporate the other
feedback for a v2 of this series, but I can drop individual patches
that have already been merged. Thanks, everyone, for the positive
reception in getting this landed, I plan to follow up with patch
series for the other uses I found.
Thanks!
Ian
> --
> Kees Cook
|