From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28AF95616A7 for ; Tue, 13 Oct 2026 22:40:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791931217; cv=none; b=mipTvvsUBh7hJW1Z4tHK4yEMl4LzYVY7aRdv/cSE1OL66axAElM+lmOUh28xh98lIn8Mm3ojQtGMjhCgISw9X9dlyrloq/7noyli8V7woS3vFHBkR5MFsC2uYp8XBRiQe0RoyD8DY51B7jOY+LfZ+44T0wW9Bz8uDWSb9hW53dY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791931217; c=relaxed/simple; bh=4WrpaiXx1GRQVpjm8b7gmWUkva2m2HTUpEY5WAi28rA=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=YEDl5xNtc2gwc04K+fV5EvnyL9n7DJHnkcFVWHl2oAFNYsLUmX0y0lajvmSVlJWJGIUod2JkXWND+RqrtEgTAoP/8rDs6nPBW1Bxq0p8JuvmOLZJ/40GwISH+CESbcfqbsWSpy6y6WoYP1cwhnps80TSpXqjuVWPo9yunVve6uo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Bn7hz90c; arc=none smtp.client-ip=74.125.82.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Bn7hz90c" Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-33c35f5ca6cso7840277eec.1 for ; Tue, 13 Oct 2026 15:40:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1791931213; x=1792536013; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=6CWZGGdh7JOQ6UqV1gxmMbPkjK0LPv1nbOU26QpmZ10=; b=Bn7hz90c5SJwfQmP2+AW3dGAkw3UtweF3iEJs/fRS4ftpX9ZUfay81B5NwyLYLDRu0 JjNCwwMOY0bD6FwU7BsgiuLRwurYP8wW9es3IJGv8W7CiB4fefjuPLFLPJCVKKi7I6RI oV6uPm/zxlsOkbWwFy17l83iB7KSy6ghSZjl7g4d+WDxw47jSVJgwBFEE2gZJh3cGYCh AJc/NlWZK3dIlCPz7w6Mhk08iXNFzMsqxUm42YSyD70MPigXT5E+D88R2wBPNCYmOgB9 sx+IjU/fnz6dU6nMTKMNh1pR9SUPORMsjJrcOn4zw5C6K9GMMYn0RxKiDx0CTtsij7Gc ISow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791931213; x=1792536013; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=6CWZGGdh7JOQ6UqV1gxmMbPkjK0LPv1nbOU26QpmZ10=; b=BCFX0PowPIzJUkv6+zawLwgqn54QNTAXoNdRsuDSvoxdwRYcxbKElFQ5zc2x/HItMd 8C23uKRVImkVQHGUKvjaZdloAkBN1boojW5VP66TaAbsUKJAQIOOq16sxeEGQRcIByc2 LfuT7KeEdNMdY1KJIX/f4yHoBqc2rfLbRzFSVblDTryN+SO7uxjLGt9ljAOOlnbVIRcX zAzca68w4pxNkIfBWVMvK5OepIR0/JlbAYmDVGtuyldgB9VG6H6pudAIgzvX2fSj5CQ4 Z0J8uaO2jzxFBen2Bfksr0UR20cj/DOOGql9+qyXMvqq24XBmezACMQAV2pWbLdI8H/L 9o7Q== X-Forwarded-Encrypted: i=1; AKwUvBxnWOlC2SWB85LDLYp8QHA6TVmzkkaJjymJUmzRR1EaKO/X89EeKos+2atuPRJX/rkjkTcj7KsMFGqn@vger.kernel.org X-Gm-Message-State: AFq9FYJ1tXos7nhN8mnHNaXJb3hE75NFqYE3QKakPWM7DLOcjwTSCV8e c9ZXA7GXS319CgrCWlKOfuIB34Mo1AJUehRHNZipGfie9Qj31mM4TsNjo35aTU4pIhOo+yN/xzi FNLvbU6nxqg== X-Received: from dlak14.prod.google.com ([2002:a05:701b:290e:b0:14e:f9ab:6f83]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:2309:b0:153:7a27:b89 with SMTP id a92af1059eb24-16a5ed4008cmr22709999c88.21.1791931212336; Tue, 13 Oct 2026 15:40:12 -0700 (PDT) Date: Tue, 13 Oct 2026 15:39:35 -0700 Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.56.0.385.gd3acb90ef8-goog Message-ID: <20261013223946.1836757-1-irogers@google.com> Subject: [PATCH 00/11] kobject: Require explicit initialization of struct kobj_type::release From: Ian Rogers 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 , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , driver-core@lists.linux.dev, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, gfs2@lists.linux.dev, xen-devel@lists.xenproject.org, linux-s390@vger.kernel.org, linux-mtd@lists.infradead.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ian Rogers Content-Type: text/plain; charset="UTF-8" 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