From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) (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 7872E545DB0 for ; Tue, 13 Oct 2026 22:40:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791931222; cv=none; b=qNjflNqEPaYeTMrFjGpVobiVk9m3F5+FFQ67naOuIp0xyYFANoKAAGW474b+wsvbegG5w9Rm5sceJ2Zcks/BCIlHL3ytwgZt/CZxkwiHA9WFzBR/upuWaAcLw0cjVxOt7QvrUojKAFL38we8VNq/oyfWZWkEjtoBl65GykOvqvo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791931222; c=relaxed/simple; bh=4WrpaiXx1GRQVpjm8b7gmWUkva2m2HTUpEY5WAi28rA=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=bBh3a9RZrwIgltZolh0BzJaqazWGSTRaGCRCOdOHPoB4CM50fyXzzXUTdxra6g4JL3D941fCdX8ptRNgLV+PiD1Uio9YLzO4L0OL3TpHA9ZLCgvrToOhrwp2hKv22/WTT2mY8kfVPN0/QB/CcziybpMR1Xzw4+nVt5IXkfS1mgM= 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=q7Upxolf; arc=none smtp.client-ip=74.125.82.197 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="q7Upxolf" Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-30bcb065bfdso6715964eec.0 for ; Tue, 13 Oct 2026 15:40:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1791931214; x=1792536014; 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=q7UpxolfCVuxRdhwnkHdxA28z0SIaeiPpl6chP2hh2qbe14Wsx10ANnbzrRdIDRxdt vQMdGQMmJphz8WqQJGUNkv4xltk0qpKWmCiywdPxwixO0H7olS4QzHXGqAsiWL6dtjrS SK5jGt0yHdzhkoCE+9E2RcpxxHSDQ8F+j+5Jdv9TxLb3kvgeKFncASipVj4l6+L2i8CB 4kMfxcVzrxLETU11fFa5jt/1nm8zFtuHav+gCmKGWMoiMU9NWoy2DyE5fJVErwCgPXOd QgioRuO4WaR7H8klcn4kCwcLW1DNfCxS5fMyyZEGoI2opx8FcantIArfcAkACM7IkhYL CXow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791931214; x=1792536014; 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=XdBYAedbPLagCOT9exMQXwQ9WH6Abz1t/SFHTloQOi4p28igqv1+7WRBHHaRrr9ME2 8vG9gUQvnuRfk7G6VjvX+uwHUuFSRHiMtb3yvkAWgbI/e6SwGKw7TVlV7Jc606HlOM6y daHxErN1JLKSaov/3pQO2914RCGc+vl2Dgu0C09BzyQYOPsCEJtZw+IsTxSPTJB6Zmnm NDgovMZxv0CzRvyqh/7/zbZCdKnZaNqXFCaccCbVXnt5zl2DRitUAgfYk6K3xsgOOBEF emU+xqToobeW8wDXwrdq656jyYqAUlWuwmGXO3r35+zLkzB2x444sJqT6udgTAkP0g6B oGYw== X-Forwarded-Encrypted: i=1; AKwUvBwHXhgbBgxsTLwJ3w4hZHb16tvjJs9cp2wdVzW+X7gyU8wAIkMEPzkZbwhNdUEAWOYAHYME4AkC4A==@vger.kernel.org X-Gm-Message-State: AFq9FYKsHj558KXBK6H7Ww8fvCpITTDWxqHvLebYHp7gjFppPqCqL6cQ gZRHlTuXHRqcnzcs9hM9E/IWKkkJ3P6g8IrO7g7thZFm2BA5QR+zaq+/EVWEYhripvVmJzhEsL8 BiXVUhHTsqw== 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-pm@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