[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 9/9] kobject: Require explicit initialization of struct kobj_type::release
- To: Danilo Krummrich <dakr@xxxxxxxxxx>
- From: Ian Rogers <irogers@xxxxxxxxxx>
- Date: Wed, 18 Nov 2026 21:45:45 -0800
- 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=cIkoHsOVRZS7gIowPl6xkao6tH+bfcK9X/Z+HF8PGU0=; fh=YNw5Bu8yimON7VdOZW3GUBIittkH8mYhBJJox3P6BLw=; b=d7ZbyoTfDzf7GSyJ5U5etoZeta9DiGe3EI4y8dhBkTrkYGhDGuplTpI0ct6i+ogqlc Ei8pmzOXv8y/ohctWZEOwUO30WrbBe8LtocxkGuZoaj3qsLOVBdwLRNTU2YNScJx+aqS hrQ2dsE2asE0Ubs77yStL6GYNZM2baluH9L8OpFuItdHafyIhwI75z5ulUkUCn3xGkBF hKbWfJ7ho2RmPHEEtIizqzCe7MuYUZ3zeVpF+BTqNeotq7xAyYdUnl/AWfllYpZw/mze rN6Cb6Xbk6s0OblQ2yWKZQA0HoaCwkMJkiwsxXvyj7/vfkrPj23YEGz7+cSmaK9XFcTa nLpg==; darn=lists.xenproject.org
- Arc-seal: i=1; a=rsa-sha256; t=1795067158; cv=none; d=google.com; s=arc-20260327; b=Vz6zA4Qoe7lhtbn69/ARAczXXqeaO0KKDsTEh3nmIQtoOJzOPsN+2gaQ4n59WJbCgf EXVpcoN0pGSpIug6JO/U5fQJ0xpnG1VVUqHxbWoN21n5ZOxFODIoSUzVQUWdY3xWtrKU Kw833ndlZYoNKAmx0L0o9LVmIc0++I2lzCxaU5ro3c0Hj16DdiKGU40iBDLMhhpfCLWw JDz+uR02qZFm5tiQ8cP/TupZby8x5HwCS17o0kdecpGycOfkcgKbMKCN8lmoLW8dOIvO lwwgOQ8Kdap8gI/bMcIuSF+rgWW/oWFR2qRoNagqn3yHGpgCynj/Ew/NwFfCaAnAKwiX wMlw==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 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>, Kees Cook <kees@xxxxxxxxxx>, Miguel Ojeda <ojeda@xxxxxxxxxx>, "Rafael J . Wysocki" <rafael@xxxxxxxxxx>, Madhavan Srinivasan <maddy@xxxxxxxxxxxxx>, Michael Ellerman <mpe@xxxxxxxxxxxxxx>, Nicholas Piggin <npiggin@xxxxxxxxx>, Christophe Leroy <chleroy@xxxxxxxxxx>, Nayna Jain <nayna@xxxxxxxxxxxxx>, Srish Srinivasan <ssrish@xxxxxxxxxxxxx>, Mimi Zohar <zohar@xxxxxxxxxxxxx>, Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>, Rich Felker <dalias@xxxxxxxx>, John Paul Adrian Glaubitz <glaubitz@xxxxxxxxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Nathan Chancellor <nathan@xxxxxxxxxx>, Nick Desaulniers <ndesaulniers@xxxxxxxxxx>, Viresh Kumar <viresh.kumar@xxxxxxxxxx>, Zhongqiu Han <zhongqiu.han@xxxxxxxxxxxxxxxx>, Alexander Aring <aahringo@xxxxxxxxxx>, Felix Kuehling <felix.kuehling@xxxxxxx>, Christian König <christian.koenig@xxxxxxx>, Zhihao Cheng <chengzhihao1@xxxxxxxxxx>, Sumanth Korikkar <sumanthk@xxxxxxxxxxxxx>, Bill Wendling <morbo@xxxxxxxxxx>, Justin Stitt <justinstitt@xxxxxxxxxx>, driver-core@xxxxxxxxxxxxxxx, llvm@xxxxxxxxxxxxxxx, linux-hardening@xxxxxxxxxxxxxxx, linux-fsdevel@xxxxxxxxxxxxxxx, linux-doc@xxxxxxxxxxxxxxx, linux-acpi@xxxxxxxxxxxxxxx, linux-pm@xxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, linux-sh@xxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, gfs2@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-mtd@xxxxxxxxxxxxxxxxxxx, amd-gfx@xxxxxxxxxxxxxxxxxxxxx, dri-devel@xxxxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
- Delivery-date: Thu, 19 Nov 2026 05:46:07 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Wed, Nov 18, 2026 at 1:11 PM Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
>
> On Sun Nov 8, 2026 at 11:39 PM CET, Ian Rogers wrote:
> > static const struct kobj_type cpuregs_kobj_type = {
> > + /*
> > + * Pre-existing: info->kobj is embedded in per-CPU cpu_data;
> > + * cpuid_cpu_offline() only calls kobject_del().
> > + */
>
> All of these comments carry a “Pre-existing:” prefix, but that doesn’t
> distinguish cases with broken lifetime management from those where the storage
> remains valid despite the API misuse.
>
> For example:
>
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
> > index ab14079d1c42..0847134a1391 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
> > @@ -797,6 +797,11 @@ static const struct sysfs_ops xcp_cfg_res_sysfs_ops = {
> > };
> >
> > static const struct kobj_type xcp_cfg_res_sysfs_ktype = {
> > + /*
> > + * Pre-existing: xcp_res is embedded in struct amdgpu_xcp_cfg
> > + * rather than freed individually by kobject_put().
> > + */
> > + .release = NULL,
>
> Being embedded in another structure doesn't explain what guarantees that the
> enclosing allocation outlives the kobject’s final cleanup.
>
> Could you please drop the “Pre-existing:” prefix and make that distinction
> explicit? For broken cases, describe the lifetime problem and mark it as
> needing
> a follow-up fix. For cases where the lifetime is safe, explain what guarantees
> that safety, while acknowledging that omitting release() still violates the
> documented API contract.
>
> Also, do you plan to follow up on those cases?
Makes complete sense, thanks Danilo!
Auditing all 17 files in patch 9 with that distinction in mind:
- Only 3 built-in sites (arm64 cpuinfo, ACPI hotplug profiles, and
s390 sclp_mem) have backing storage that genuinely remains valid for
the lifetime of the kernel.
- The other 14 files either free/zero an enclosing dynamic or devm
allocation without waiting for final kobject cleanup, or are tristate
modules that unregister static kobjects/ksets on module_exit and can
unmap module memory before delayed cleanup finishes.
I've dropped the "Pre-existing:" prefix, documented the specific
guarantee or FIXME lifetime hazard at each site in v4, and yes, I plan
to send follow-up fixes to the respective subsystems once __must_init
is in place.
Thanks,
Ian
> Thanks,
> Danilo
>
|