From nobody Mon Nov 23 22:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1795116360; cv=none; d=zohomail.com; s=zohoarc; b=PyOIJjPFMNjUHw+shxX/yPU6CFiaO3liuKz4bk1afXhcW2t2+xvLbUZ1yX6SISKy8SHIPPGxxG3nFhE7aF0ZP1pb9IZ6vdM4ze3SaIRsx++78sBsDb/hYpTORo+BDN3htkEWNf8E22whVVNQBD5UwSkDL/JVQxruNNXtuoGbAMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795116360; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5sSK0mEpHDMvzrLQAsEFtk5LbI4UItSogecSbLV64WI=; b=KkKBM8YgYGm5qEwRZt8LUWyyaMeZB37pzFxlDD/5aajoyXoGmEbzHu0/ISI9Zmr3MkRPF8iRt/8ddyyMz4ZTlEc3NKXwb9V8vgGsmUi3sHww1hxR3gjOwDMBWnxCpxFZRkmVFM9tjkKVuZj8dIqu0hxZZ+EjImhfhammgxuPK+M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1795116360514775.5915265651623; Thu, 19 Nov 2026 11:26:00 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1496841.1695165 (Exim 4.92) (envelope-from ) id 1xU7lL-0002KU-MN; Thu, 19 Nov 2026 19:25:39 +0000 Received: by outflank-mailman (output) from mailman id 1496841.1695165; Thu, 19 Nov 2026 19:25:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xU7lL-0002KN-Is; Thu, 19 Nov 2026 19:25:39 +0000 Received: by outflank-mailman (input) for mailman id 1496841; Thu, 19 Nov 2026 19:25:37 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from <3Lk3_agcKCSUJSPHFSTHPPHMF.DPNYFO-EFWFMMJTUT.YFOQSPKFDU.PSH@flex--irogers.bounces.google.com>) id 1xU7lJ-0002K0-QG for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 19:25:37 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xU7lI-001h7f-Vn for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 20:25:36 +0100 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from <3Lk3_agcKCSUJSPHFSTHPPHMF.DPNYFO-EFWFMMJTUT.YFOQSPKFDU.PSH@flex--irogers.bounces.google.com>) id 6aff4d0b-e002-0a2a0a5209dd-0a2a4509a00e-26 for ; Thu, 19 Nov 2026 20:25:36 +0100 Received: from [74.125.82.198] (helo=mail-dy1-f198.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from <3Lk3_agcKCSUJSPHFSTHPPHMF.DPNYFO-EFWFMMJTUT.YFOQSPKFDU.PSH@flex--irogers.bounces.google.com>) id 6aff4d2f-be1a-0a2a45090019-4a7d52c6cc36-3 for ; Thu, 19 Nov 2026 20:25:36 +0100 Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-383f2d05c73so194939eec.0 for ; Thu, 19 Nov 2026 11:25:36 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=google.com header.i="@google.com" header.h="Content-Type:Cc:To:From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795116335; x=1795721135; darn=lists.xenproject.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=5sSK0mEpHDMvzrLQAsEFtk5LbI4UItSogecSbLV64WI=; b=RC09US0MMxchSti5JWIJKwx4dyuXx4TccdV4pZ8qla6oLjtiTkTolAAfXg7uygRPoQ b3UvqKuR0G6hkRf5HSdhdJwSVfQJd8tOAUPmeXoPK5DS9gUuz3pE0bjfDgIx0iCPvFfi SY+y3RxB0dDA9vytDAU449t8zsJquT34Nw3yz5kxF1bNpraTIqTcWmoqljv/gIWh0THn i6M1d9rs53I2BWo5IJCOz7TDjgpbJZVrdHq6UOTWc8webJnjlimCORpB2fBzzc5kSBJm qFxU2ZB6+XI+nNVD+OfVrqhN5Ul2N1KuqdfuMW4tpiBs383/3QJOS083aDzUfHMK6Fiu bz4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795116335; x=1795721135; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5sSK0mEpHDMvzrLQAsEFtk5LbI4UItSogecSbLV64WI=; b=BI20pPnQq4094SQOJqvVZZlqE8n62l/iUE6tJCrF+tFbyHxNtgUTLo5FZNl3z+/10d Vdo3lyIpYKrnqZVDHZf8HMbOYhwCQby7n4YVos73PlpSWSayyo5INY+MJgtIAYHt5E1v tcR1xjwv7ndSkiVjpQAqlGSPhF8sN8ntdZDaJ0GZ0IQVENmkkk/jFbJ9/D/BybMLN3Cc oTOqm5ZOyHgjP+Arj5SRWCxUFwN6J51KdyRs8rdSvMECPi/JWqOw6hvar4pbedyWdgko fw17XVmI1SNDwNIZQKg8RyR71qcjYbs55R1OgpoiWF1qgLPwYkHedFaWy2v4nCu9/bxr zRag== X-Forwarded-Encrypted: i=1; AL+hErFwdnWNWjhmLTY8WX5svxL3CiN3CYPB0aEf5/ofQI08YF/0Bs8OoqvsbP4xnyaCR3bo9a25iOZSfUc=@lists.xenproject.org X-Gm-Message-State: APuU4Z8G2rs9baWsUpdnPkAYgrJXgFDuiCDEAV+RCDnFQ2CsrV/TKX1l x9SensN0iM9jY677A2j+/uZw/tPgzOvqT+si+g0/LYbWB4zKUQOazK7Ltw1H/dkLagne+rDLIpL niNnvlT7DwA== X-Received: from dybqm10.prod.google.com ([2002:a05:7301:670a:b0:385:6c3c:3ea1]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:152f:b0:381:c532:3d88 with SMTP id 5a478bee46e88-3857093c38bmr360600eec.23.1795116334302; Thu, 19 Nov 2026 11:25:34 -0800 (PST) Date: Thu, 19 Nov 2026 11:25:12 -0800 In-Reply-To: <20261119192520.1983406-1-irogers@google.com> Mime-Version: 1.0 References: <20261119192520.1983406-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.750.gf70dc682cf-goog Message-ID: <20261119192520.1983406-2-irogers@google.com> Subject: [PATCH v4 1/9] Compiler Attributes: Add __must_init macro From: Ian Rogers To: Danilo Krummrich , Greg Kroah-Hartman , Kees Cook , Miguel Ojeda , "Rafael J . Wysocki" Cc: Madhavan Srinivasan , Srish Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Nayna Jain , Mimi Zohar , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Nathan Chancellor , Nick Desaulniers , Viresh Kumar , Zhongqiu Han , Alexander Aring , Felix Kuehling , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , Zhihao Cheng , Sumanth Korikkar , Bill Wendling , Justin Stitt , driver-core@lists.linux.dev, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-s390@vger.kernel.org, gfs2@lists.linux.dev, xen-devel@lists.xenproject.org, linux-mtd@lists.infradead.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ian Rogers X-purgate-ID: tlsNG-bad1c0/1795116336-FD06B034-0AAAD8AD/0/0 X-purgate-type: clean X-purgate-size: 4238 X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1795116361857158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Clang supports the 'require_explicit_initialization' attribute on struct fields to indicate that a field must be initialized explicitly by the user when the object is constructed. When an aggregate initializer or uninitialized variable omits an annotated field, Clang emits a -Wuninitialized-explicit-init warning (enabled by default). Add the __must_init macro to include/linux/compiler_attributes.h (which is included by include/linux/compiler_types.h and include/linux/compiler.h) so kernel structs with error-prone initialization (such as mandatory callbacks or cleanup handlers) can enforce explicit initialization at compile time, as discussed at the Linux Plumbers Conference. The shorter __must_init spelling, rather than the attribute's full name, keeps annotated struct members readable and was suggested by Greg Kroah-Hartman. Note that Clang versions prior to the fix for https://github.com/llvm/llvm-project/issues/232483 do not diagnose file-scope objects declared without any initializer (initializers at file scope that omit the field are diagnosed). Also teach Sphinx (Documentation/conf.py), kernel-doc (tools/lib/python/kdoc/xforms_lists.py), and checkpatch.pl about the new attribute macro. Link: https://lpc.events/event/20/contributions/2392/ Link: https://lore.kernel.org/lkml/2026101532-fantastic-deafness-e04c@gregk= h/ Acked-by: Miguel Ojeda Reviewed-by: Nick Desaulniers Reviewed-by: Nathan Chancellor Acked-by: Greg Kroah-Hartman Reviewed-by: Kees Cook Signed-off-by: Ian Rogers --- Documentation/conf.py | 1 + include/linux/compiler_attributes.h | 12 ++++++++++++ scripts/checkpatch.pl | 1 + tools/lib/python/kdoc/xforms_lists.py | 1 + 4 files changed, 15 insertions(+) diff --git a/Documentation/conf.py b/Documentation/conf.py index 5ab26ce89daf..baaa4035258c 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -203,6 +203,7 @@ c_id_attributes =3D [ "__noreturn", "__packed", "__pure", + "__must_init", "__section", "__always_unused", "__maybe_unused", diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_a= ttributes.h index 476c4c560d17..b9c0b56dd22e 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -322,6 +322,18 @@ */ #define __pure __attribute__((__pure__)) =20 +/* + * Optional: not supported by gcc + * Optional: only supported since clang >=3D 20.0 + * + * clang: https://clang.llvm.org/docs/AttributeReference.html#require-expl= icit-initialization + */ +#if __has_attribute(__require_explicit_initialization__) +# define __must_init __attribute__((__require_explicit_initialization__)) +#else +# define __must_init +#endif + /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.ht= ml#index-section-function-attribute * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.ht= ml#index-section-variable-attribute diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index b8b64f720191..6a091c45b1a1 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6888,6 +6888,7 @@ sub process { "noreturn" =3D> "__noreturn", "packed" =3D> "__packed", "pure" =3D> "__pure", + "require_explicit_initialization" =3D> "__must_init", "section" =3D> "__section", "used" =3D> "__used", "weak" =3D> "__weak" diff --git a/tools/lib/python/kdoc/xforms_lists.py b/tools/lib/python/kdoc/= xforms_lists.py index db23fb650ea8..42956b98aae3 100644 --- a/tools/lib/python/kdoc/xforms_lists.py +++ b/tools/lib/python/kdoc/xforms_lists.py @@ -36,6 +36,7 @@ class CTransforms: (CMatch("CRYPTO_MINALIGN_ATTR"), ""), (CMatch("__private"), ""), (CMatch("__rcu"), ""), + (CMatch("__must_init"), ""), (CMatch("____cacheline_aligned_in_smp"), ""), (CMatch("____cacheline_aligned"), ""), (CMatch("__cacheline_group_(?:begin|end)"), ""), --=20 2.56.1.708.g77570a6a1d-goog From nobody Mon Nov 23 22:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1795116359; cv=none; d=zohomail.com; s=zohoarc; b=brrR+qMnGk28SDbWC+QF4cPk5A3ZFJdS/F4Ko9+gYMBuKU/VaVOPHFGIBhQ6bxUqdX7FQB+IJ+ERsjOawXrJ/YudeSBk1k80fRpF/risFGD9rMxI1lv1VW+kyuWZKTHmdLWo4xC6E9EpU0B21cLEwKVh10+VRJ9DTYRZI2/DSxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795116359; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rEPVdW1UHjKh7bwOu3YUjmxSg8vF1ESXVYVOzAB45kQ=; b=QGkqi3S4smjESypUNMy2NUD1aXkxpiyXYvwIE8I7aeo0VJGuSDOphR7L2IdvTTA1i7XE1cve0/Wvf5Q4ugo/XpTlnOBSuW1VNP02NjDSc4tV09IuIpBy6mQdroqyqbBzvosjJ7JYcSaaTQrepm4VIhMl3TwfWi2/NjtyjCWO0EU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1795116359335159.30382915355915; Thu, 19 Nov 2026 11:25:59 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1496842.1695175 (Exim 4.92) (envelope-from ) id 1xU7lN-0002Y6-Ug; Thu, 19 Nov 2026 19:25:41 +0000 Received: by outflank-mailman (output) from mailman id 1496842.1695175; Thu, 19 Nov 2026 19:25:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xU7lN-0002Xy-QV; Thu, 19 Nov 2026 19:25:41 +0000 Received: by outflank-mailman (input) for mailman id 1496842; Thu, 19 Nov 2026 19:25:40 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from <3MU3_agcKCSgMVSKIVWKSSKPI.GSQbIR-HIZIPPMWXW.bIRTVSNIGX.SVK@flex--irogers.bounces.google.com>) id 1xU7lM-0002Qw-Fy for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 19:25:40 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xU7lL-00DAaF-Lj for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 20:25:39 +0100 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from <3MU3_agcKCSgMVSKIVWKSSKPI.GSQbIR-HIZIPPMWXW.bIRTVSNIGX.SVK@flex--irogers.bounces.google.com>) id 6aff4cfe-2eae-0a2a0a5409dd-0a2a450ad990-38 for ; Thu, 19 Nov 2026 20:25:39 +0100 Received: from [209.85.167.198] (helo=mail-oi1-f198.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from <3MU3_agcKCSgMVSKIVWKSSKPI.GSQbIR-HIZIPPMWXW.bIRTVSNIGX.SVK@flex--irogers.bounces.google.com>) id 6aff4d32-f2d2-0a2a450a0019-d155a7c6b465-3 for ; Thu, 19 Nov 2026 20:25:39 +0100 Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-5735cd94235so213380b6e.0 for ; Thu, 19 Nov 2026 11:25:39 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=google.com header.i="@google.com" header.h="Content-Type:Cc:To:From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795116338; x=1795721138; darn=lists.xenproject.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rEPVdW1UHjKh7bwOu3YUjmxSg8vF1ESXVYVOzAB45kQ=; b=SLTNAFypDcJWMgNo0j520FgJ/Z92jVhwbEvx/pFFD4fztPOFSu+njVcKfUdT1lLbU7 ElmA9zvCMC4RhM71TCOv8B0KKVaVlz4XocGHD0BY2737Ba1XLod+dshJqH7f9hT3c35t OTLtp+BBoWGCJ+DO4WPLD8DDr5Lvye8eFqnkQoWHMjF5SkaWdR3dCj+Pg5IftElB/3HF qcqcsAmWv0DRpZboY1lHnpO1GOm6SFLEoAYs0ChfYX4HCI+K9iuWeeQ3kTheBJKuvD04 cv+Igm0LftW5eYFmLjAs0aimSGgW34ShmvJvV2CrGSK6ylEEPrAIrEzMyhHVNUG/iNj+ LN6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795116338; x=1795721138; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rEPVdW1UHjKh7bwOu3YUjmxSg8vF1ESXVYVOzAB45kQ=; b=LSvLOKTNhwMXtH9y88ShlF0xOEx9efpgostNbZzOsgXUMoBZb6L3cZNV789sYuATiz zOJbgVc0p52cXr+jBop+kxy2rxrB/nJYZJXBsU0xqU1BUuFrhmJcLI8wPKQAHK8ayeLu ISvAOXm0soaQC/h4/jT+VVrhmZbWK7zJivXHPbbNjyk2YMBA/3MlD8riza1wfrxHLeYo cwiehiIOGAFUavLsi1sslLk4eE5CfVN8J1TtLIkBhn1ce91y5fRFjL1FJ9S3dtGTP4uY 8uX7ZfEbA7N5fKguBn1xd95FP2M7SFXA3ERtZMizo89jIEJg5HpSEEr4/ije6OiyFonb CKCQ== X-Forwarded-Encrypted: i=1; AL+hErGECGFiSzLzZU6TqbefDU3Uw8l5ZXZBEbYQSGQnwg4BrLoMSgJtj2gJadESJs6hqxpamV79uR5Huyg=@lists.xenproject.org X-Gm-Message-State: APuU4Z+sfMK4Jjm3ckMbTTLuLAB860eao1+HdJQalg5vKt1UQDO2kk4p hG0dGD1NYO4/TaeX4gJdMVM85fCHq54/5HVFA/pSdTothOwOeA6dtIHnbKqPaC6iuhdUfh/AC34 aofasadmhHA== X-Received: from ilmp8.prod.google.com ([2002:a92:c608:0:b0:51e:1b8:eceb]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:c110:b0:576:4595:9836 with SMTP id 5614622812f47-57a0ba52419mr994155b6e.40.1795116337420; Thu, 19 Nov 2026 11:25:37 -0800 (PST) Date: Thu, 19 Nov 2026 11:25:13 -0800 In-Reply-To: <20261119192520.1983406-1-irogers@google.com> Mime-Version: 1.0 References: <20261119192520.1983406-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.750.gf70dc682cf-goog Message-ID: <20261119192520.1983406-3-irogers@google.com> Subject: [PATCH v4 2/9] powerpc/secvar: Add missing kobject release callback to secvar_ktype From: Ian Rogers To: Danilo Krummrich , Greg Kroah-Hartman , Kees Cook , Miguel Ojeda , "Rafael J . Wysocki" Cc: Madhavan Srinivasan , Srish Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Nayna Jain , Mimi Zohar , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Nathan Chancellor , Nick Desaulniers , Viresh Kumar , Zhongqiu Han , Alexander Aring , Felix Kuehling , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , Zhihao Cheng , Sumanth Korikkar , Bill Wendling , Justin Stitt , driver-core@lists.linux.dev, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-s390@vger.kernel.org, gfs2@lists.linux.dev, xen-devel@lists.xenproject.org, linux-mtd@lists.infradead.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ian Rogers X-purgate-ID: tlsNG-4011c0/1795116339-530D9CFC-71486320/0/0 X-purgate-type: clean X-purgate-size: 1390 X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1795116359896158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In add_var(), a struct kobject is dynamically allocated with kzalloc_obj() and initialized with secvar_ktype. If kobject_add() or sysfs_create_file() fails, kobject_put(kobj) is called to clean up. However, secvar_ktype does not define a .release callback, which results in a memory leak of kobj (and a pr_debug warning in kobject_cleanup() when CONFIG_DEBUG_KOBJECT_RELEASE is enabled). Provide a secvar_release() callback that calls kfree(kobj). Fixes: bd5d9c743d38 ("powerpc: expose secure variables to userspace via sys= fs") Reviewed-by: Srish Srinivasan Acked-by: Madhavan Srinivasan Signed-off-by: Ian Rogers --- arch/powerpc/kernel/secvar-sysfs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/powerpc/kernel/secvar-sysfs.c b/arch/powerpc/kernel/secva= r-sysfs.c index 395399bbab2c..f3f6ac25ea78 100644 --- a/arch/powerpc/kernel/secvar-sysfs.c +++ b/arch/powerpc/kernel/secvar-sysfs.c @@ -126,7 +126,13 @@ static const struct attribute_group secvar_attr_group = =3D { }; __ATTRIBUTE_GROUPS(secvar_attr); =20 +static void secvar_release(struct kobject *kobj) +{ + kfree(kobj); +} + static const struct kobj_type secvar_ktype =3D { + .release =3D secvar_release, .sysfs_ops =3D &kobj_sysfs_ops, .default_groups =3D secvar_attr_groups, }; --=20 2.56.1.708.g77570a6a1d-goog From nobody Mon Nov 23 22:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1795116368; cv=none; d=zohomail.com; s=zohoarc; b=EiElh1w9xyoiTrZPk0yOZ1TmCnsbmjV4vT2WSyPHkFw8pV0ZCtFgFJxeMSZGhr0WDAZpCL1x7SVvXJelVzvxrGjhO2TmxX0aAQCzt50xMq4/fTC/HaNmDhwFbCu93AtMdvUf0yhqbUc1JKSd2+QgE4Eqe8BlPJ15hKE1j+Uoj3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795116368; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ALLBk8MdTkFwcPZqYQO+ZVSicu8jJEanZFGqZFoBPVY=; b=RzO8ZzddBEgG8k7+iPnpW9cJ5q6red42WufgGV7tVup9TG9t54H42mM5ISMszhNmsZtnjbBM0J3zvgu9sBME1GHxI0urKShWjNSKHtuZfw51rZFWAPNJYUGITsCHdg7jcV9P9Bbf4fE3LkRrbstGJ958z7S6636s3Nh4qGqIMNM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 179511636847257.09009042671653; Thu, 19 Nov 2026 11:26:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1496844.1695183 (Exim 4.92) (envelope-from ) id 1xU7lR-0002nF-9G; Thu, 19 Nov 2026 19:25:45 +0000 Received: by outflank-mailman (output) from mailman id 1496844.1695183; Thu, 19 Nov 2026 19:25:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xU7lR-0002n8-6W; Thu, 19 Nov 2026 19:25:45 +0000 Received: by outflank-mailman (input) for mailman id 1496844; Thu, 19 Nov 2026 19:25:44 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from <3NU3_agcKCSwQZWOMZaOWWOTM.KWUfMV-LMdMTTQaba.fMVXZWRMKb.WZO@flex--irogers.bounces.google.com>) id 1xU7lQ-0002m3-30 for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 19:25:44 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xU7lP-00DAaF-Fq for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 20:25:43 +0100 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from <3NU3_agcKCSwQZWOMZaOWWOTM.KWUfMV-LMdMTTQaba.fMVXZWRMKb.WZO@flex--irogers.bounces.google.com>) id 6aff4d37-2eae-0a2a0a5409dd-0a2a450a88ee-0 for ; Thu, 19 Nov 2026 20:25:43 +0100 Received: from [209.85.214.197] (helo=mail-pl1-f197.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from <3NU3_agcKCSwQZWOMZaOWWOTM.KWUfMV-LMdMTTQaba.fMVXZWRMKb.WZO@flex--irogers.bounces.google.com>) id 6aff4d35-f2d2-0a2a450a0019-d155d6c5a819-3 for ; Thu, 19 Nov 2026 20:25:43 +0100 Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2ee2d612733so9929625ad.0 for ; Thu, 19 Nov 2026 11:25:42 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=google.com header.i="@google.com" header.h="Content-Type:Cc:To:From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795116341; x=1795721141; darn=lists.xenproject.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ALLBk8MdTkFwcPZqYQO+ZVSicu8jJEanZFGqZFoBPVY=; b=iH8cuMkUaR5CE+IVSf+Z7l3Z51+jTV/vht+1CF9QjTbWi4mbVn6q39zAoJlWMDRgrJ 8RYbYOGp4h2ec03qZaWHXifYmYv7OLjE2M3gJj7FpAPQ974QXLRCuxNaC3w76J6DeiRP S+z/MpOIzwa0utCUBtcQUydWbjr197ewLQmj6CNfj6uH4jOpYkQIfqfXG3zz+YBCYe/9 Tti0v6MdUrIk3p7cjrBMaZj0Kc/2Ha4GJUZlHSDyqe2Aq8w3YScWUtJHAYrrYKc1CX5b xGFkvRN8PxyBVXpnwTJefxDDf7lQpmRJcmxu3i3GrWooyGGG0VfkZkYD7FSBWlvDr0m0 /KvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795116341; x=1795721141; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ALLBk8MdTkFwcPZqYQO+ZVSicu8jJEanZFGqZFoBPVY=; b=boLJWq+VWW51VXxx4upbS0TU2shkVvrw22UZPL3jajNA4LxYmzpYBuxY14ZT4BD87K nyYDQtdLYfn4S2ET9oRZZK3yXGCx9OCENOq0fHIvlwedmArf+ehyIlHixHadoCbfHu5a vji6k0tlYlLo6DvOqbFqPBo8C6HMU/e1qEIEctc4eY32IRVyidflsiM19a9eChfy9UD5 N2TqBsV4IrOkJTOQtmKmARay0j3NRON/DTvudCC1x8ue3ScyQfLjHuIf2bp2C6kcpo3/ h9jsv3HBc7J0352y39GY888WYHfp02TgTxo8lYj6yr93BLvAwrNzQl7AIvB0HtLgr7+u 58fw== X-Forwarded-Encrypted: i=1; AL+hErG1Nj6r+1gLYDHC0Rw7y5hLay2VNM243D0FdzzHBc/98AiWBS3QjWEjYnP8dtcg5MTe04EI75MJqGM=@lists.xenproject.org X-Gm-Message-State: APuU4Z8CwxZHSxT+gCn9Dba5+anfb3S3soIweaMXy7jXZm2CtIu/LWRI H9A2oEu+wFZ0jnHDRwAQ4y/80LnGwC/zlYKVIB0CGmnzmrDOY5nDRCfleLOwpAcNyYaVpsV+lvk O6EpRRUKKBA== X-Received: from pleu15.prod.google.com ([2002:a17:903:41cf:b0:2ef:d860:1c85]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:fda5:b0:2ed:fb0:bfd6 with SMTP id d9443c01a7336-2f031e08699mr15736045ad.11.1795116341051; Thu, 19 Nov 2026 11:25:41 -0800 (PST) Date: Thu, 19 Nov 2026 11:25:14 -0800 In-Reply-To: <20261119192520.1983406-1-irogers@google.com> Mime-Version: 1.0 References: <20261119192520.1983406-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.750.gf70dc682cf-goog Message-ID: <20261119192520.1983406-4-irogers@google.com> Subject: [PATCH v4 3/9] sh: sq: Add missing kobject release callback to ktype_percpu_entry From: Ian Rogers To: Danilo Krummrich , Greg Kroah-Hartman , Kees Cook , Miguel Ojeda , "Rafael J . Wysocki" Cc: Madhavan Srinivasan , Srish Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Nayna Jain , Mimi Zohar , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Nathan Chancellor , Nick Desaulniers , Viresh Kumar , Zhongqiu Han , Alexander Aring , Felix Kuehling , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , Zhihao Cheng , Sumanth Korikkar , Bill Wendling , Justin Stitt , driver-core@lists.linux.dev, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-s390@vger.kernel.org, gfs2@lists.linux.dev, xen-devel@lists.xenproject.org, linux-mtd@lists.infradead.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ian Rogers X-purgate-ID: tlsNG-4011c0/1795116343-59BC0CFC-E1E6199E/0/0 X-purgate-type: clean X-purgate-size: 1123 X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1795116369851158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In sq_dev_add(), sq_kobject[cpu] is dynamically allocated with kzalloc_obj() and initialized with ktype_percpu_entry. When sq_dev_remove() calls kobject_put(kobj), the kobject is never freed because ktype_percpu_entry lacks a .release callback. Provide a sq_kobj_release() callback that calls kfree(kobj). Fixes: d7c30c682a27 ("sh: Store Queue API rework.") Acked-by: John Paul Adrian Glaubitz Signed-off-by: Ian Rogers --- arch/sh/kernel/cpu/sh4/sq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c index 908a8e09113b..f33864958487 100644 --- a/arch/sh/kernel/cpu/sh4/sq.c +++ b/arch/sh/kernel/cpu/sh4/sq.c @@ -331,7 +331,13 @@ static const struct sysfs_ops sq_sysfs_ops =3D { .store =3D sq_sysfs_store, }; =20 +static void sq_kobj_release(struct kobject *kobj) +{ + kfree(kobj); +} + static struct kobj_type ktype_percpu_entry =3D { + .release =3D sq_kobj_release, .sysfs_ops =3D &sq_sysfs_ops, .default_groups =3D sq_sysfs_groups, }; --=20 2.56.1.708.g77570a6a1d-goog From nobody Mon Nov 23 22:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1795116370; cv=none; d=zohomail.com; s=zohoarc; b=NpGfSqG1sHczfH4Xj4diUhx7/mBFtJZS1msZ/jJK5a2wvzqfeaN10B6NgU4tqqibmSR2Y7tue15N2XOSO+LZp/yG/rG69r1kJXoYoa8bcnSX22xlvGlJhiIuQb0+Ekc7J1ah6ZCZvL+1Xw3zGGBxgVh6/GNYARbOoW+K3no1orA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795116370; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kkWfFph3Jhdo1iVdBmUApUet/72n0u945LBk/dYhnBA=; b=IoVjD9tc9dvmvT6CB5jthq7jxH70nGQCZnIefECMvaVdJZW1GWmwNXNJuHjO7RuBzU5zAwcxhBF+KSS3x37xJWq9pxQ3TI0vIvFrowe0ZsuOIQC3kaTHiYHFUz42z9qaCRlez9TynSxiR8b2QQxs8iIFmamqlTFQtK9NqxKBWYY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1795116370537286.02161966498295; Thu, 19 Nov 2026 11:26:10 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1496846.1695192 (Exim 4.92) (envelope-from ) id 1xU7lX-00037I-Ij; Thu, 19 Nov 2026 19:25:51 +0000 Received: by outflank-mailman (output) from mailman id 1496846.1695192; Thu, 19 Nov 2026 19:25:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xU7lX-000376-Ep; Thu, 19 Nov 2026 19:25:51 +0000 Received: by outflank-mailman (input) for mailman id 1496846; Thu, 19 Nov 2026 19:25:50 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from <3Ok3_agcKCTEVebTRefTbbTYR.PbZkRa-QRiRYYVfgf.kRacebWRPg.beT@flex--irogers.bounces.google.com>) id 1xU7lW-00035L-3V for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 19:25:50 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xU7lV-009Gtq-G6 for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 20:25:49 +0100 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from <3Ok3_agcKCTEVebTRefTbbTYR.PbZkRa-QRiRYYVfgf.kRacebWRPg.beT@flex--irogers.bounces.google.com>) id 6aff4d00-bab6-0a2a0a5309dd-0a2a4501bb7a-34 for ; Thu, 19 Nov 2026 20:25:49 +0100 Received: from [74.125.82.198] (helo=mail-dy1-f198.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from <3Ok3_agcKCTEVebTRefTbbTYR.PbZkRa-QRiRYYVfgf.kRacebWRPg.beT@flex--irogers.bounces.google.com>) id 6aff4d3b-5bcc-0a2a45010019-4a7d52c6dd38-3 for ; Thu, 19 Nov 2026 20:25:49 +0100 Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-3854627c1c8so72530eec.1 for ; Thu, 19 Nov 2026 11:25:48 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=google.com header.i="@google.com" header.h="Content-Type:Cc:To:From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795116347; x=1795721147; darn=lists.xenproject.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=kkWfFph3Jhdo1iVdBmUApUet/72n0u945LBk/dYhnBA=; b=R6ZRvg4WhvDYxiJZYziWUtEQ0SNsk534e6rXiKDGaURBmCRrUzFUyysvdB1Y1c22BZ 9GI0R5gpq7aBb6OmCW5nNmKZ3+sPyUCG+R1ns1GuFRDlmwlNHNTOAWk8BFemKfJofNkn NPmzxKoaoEGmox6m+35hdCJTjtWzoKxUABMgWsiPgc9rw8h7QBVj7inRlNoVHRNppqPJ f0erWqOwjS4N1LXVFShSla+lXPtvRGZ6GKwv+tM7DY+FqGNZL085LC2aiJp4VYlmbdC9 zCtQtx7qMjIW0ALCLcjOBJ/Tq3eviakaX1+0RjsVBed7fjcob3FgVDlcalrzgXwhnbiF sKpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795116347; x=1795721147; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=kkWfFph3Jhdo1iVdBmUApUet/72n0u945LBk/dYhnBA=; b=1+XVRXaMHi+yxm6pAgIULoauCtpSchXSr2v6g4+umPPT+f8ByiSx5P5Kln6GwVi4OP MOKBZzNbplVSCTAqAHT89HqjIHRW3qGg2rCe0zfyELpd6+CgpKj56WlH+3e5vX+TkZEv tkuMagRJm5z89C5Z7Fvn+JrWQSvcSoNiKa9Z40ATiK9FGtsoiJORaTbZ92OCSOuMVr0s 9QBLY9jL5kdzyvbH1jOQmf39Zcv2aKEZMdLxKfDU18oVVl73kx/DGPniR5uiJilq060n S41gVhz6nhrlnBE4B5/2MYMpnNQBLllRxHZrYR7YN+RPfE+ZDllAxBzl/Rcxf7NdhLdx DcLg== X-Forwarded-Encrypted: i=1; AL+hErFmZpryNQcDFqclm6tNIo/IjBSjj37shprZYHa8A63UHDaEzCjBEk+y0EjtJ80zOybB4sLFZ7vUFAY=@lists.xenproject.org X-Gm-Message-State: APuU4Z/80rXdlIL+zFshx6KGtKpQ2FdQNTfwDrPW2Kkqrje1IOUu7kwZ 6ETSzK7Oi96QVddXupOwEY/b+xqgUPPs36uBBuNRASWRAmqvQQBmPubZhDflrYSwIu/E7ncESxv cjt7WNkEovA== X-Received: from dyvo18-n1.prod.google.com ([2002:a05:693c:41d2:10b0:370:f640:2508]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:693c:820d:b0:36d:394d:e690 with SMTP id 5a478bee46e88-38570b34f2fmr260461eec.40.1795116346621; Thu, 19 Nov 2026 11:25:46 -0800 (PST) Date: Thu, 19 Nov 2026 11:25:15 -0800 In-Reply-To: <20261119192520.1983406-1-irogers@google.com> Mime-Version: 1.0 References: <20261119192520.1983406-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.750.gf70dc682cf-goog Message-ID: <20261119192520.1983406-5-irogers@google.com> Subject: [PATCH v4 4/9] cpufreq: governor: Initialize kobj_type release callback statically From: Ian Rogers To: Danilo Krummrich , Greg Kroah-Hartman , Kees Cook , Miguel Ojeda , "Rafael J . Wysocki" Cc: Madhavan Srinivasan , Srish Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Nayna Jain , Mimi Zohar , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Nathan Chancellor , Nick Desaulniers , Viresh Kumar , Zhongqiu Han , Alexander Aring , Felix Kuehling , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , Zhihao Cheng , Sumanth Korikkar , Bill Wendling , Justin Stitt , driver-core@lists.linux.dev, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-s390@vger.kernel.org, gfs2@lists.linux.dev, xen-devel@lists.xenproject.org, linux-mtd@lists.infradead.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ian Rogers X-purgate-ID: tlsNG-d62444/1795116349-BC6E65FD-854999FC/0/0 X-purgate-type: clean X-purgate-size: 3807 X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1795116372081158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Export cpufreq_dbs_data_release() and initialize .kobj_type.release statically in the ondemand and conservative governors instead of assigning it at runtime in cpufreq_dbs_governor_init(). This prepares for annotating struct kobj_type::release with __must_init. Reviewed-by: Zhongqiu Han Acked-by: Rafael J. Wysocki (Intel) # cpufreq Acked-by: Viresh Kumar Signed-off-by: Ian Rogers --- drivers/cpufreq/cpufreq_conservative.c | 5 ++++- drivers/cpufreq/cpufreq_governor.c | 4 ++-- drivers/cpufreq/cpufreq_governor.h | 1 + drivers/cpufreq/cpufreq_ondemand.c | 5 ++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufr= eq_conservative.c index 02bfd46543e9..146a2353b1a2 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c @@ -318,7 +318,10 @@ static void cs_limits(struct cpufreq_policy *policy) =20 static struct dbs_governor cs_governor =3D { .gov =3D CPUFREQ_DBS_GOVERNOR_INITIALIZER("conservative"), - .kobj_type =3D { .default_groups =3D cs_groups }, + .kobj_type =3D { + .release =3D cpufreq_dbs_data_release, + .default_groups =3D cs_groups, + }, .gov_dbs_update =3D cs_dbs_update, .alloc =3D cs_alloc, .free =3D cs_free, diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_g= overnor.c index f3bd3dbe7c41..f8b5aca09b6b 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -419,7 +419,7 @@ static void free_policy_dbs_info(struct policy_dbs_info= *policy_dbs, gov->free(policy_dbs); } =20 -static void cpufreq_dbs_data_release(struct kobject *kobj) +void cpufreq_dbs_data_release(struct kobject *kobj) { struct dbs_data *dbs_data =3D to_dbs_data(to_gov_attr_set(kobj)); struct dbs_governor *gov =3D dbs_data->gov; @@ -427,6 +427,7 @@ static void cpufreq_dbs_data_release(struct kobject *ko= bj) gov->exit(dbs_data); kfree(dbs_data); } +EXPORT_SYMBOL_GPL(cpufreq_dbs_data_release); =20 int cpufreq_dbs_governor_init(struct cpufreq_policy *policy) { @@ -488,7 +489,6 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *po= licy) policy->governor_data =3D policy_dbs; =20 gov->kobj_type.sysfs_ops =3D &governor_sysfs_ops; - gov->kobj_type.release =3D cpufreq_dbs_data_release; ret =3D kobject_init_and_add(&dbs_data->attr_set.kobj, &gov->kobj_type, get_governor_parent_kobj(policy), "%s", gov->gov.name); diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_g= overnor.h index 806d8fb4dff1..1026712bb79b 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h @@ -150,6 +150,7 @@ static inline struct dbs_governor *dbs_governor_of(stru= ct cpufreq_policy *policy } =20 /* Governor callback routines */ +void cpufreq_dbs_data_release(struct kobject *kobj); int cpufreq_dbs_governor_init(struct cpufreq_policy *policy); void cpufreq_dbs_governor_exit(struct cpufreq_policy *policy); int cpufreq_dbs_governor_start(struct cpufreq_policy *policy); diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_o= ndemand.c index 9942dbb38dae..7386d043c665 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -374,7 +374,10 @@ static struct od_ops od_ops =3D { =20 static struct dbs_governor od_dbs_gov =3D { .gov =3D CPUFREQ_DBS_GOVERNOR_INITIALIZER("ondemand"), - .kobj_type =3D { .default_groups =3D od_groups }, + .kobj_type =3D { + .release =3D cpufreq_dbs_data_release, + .default_groups =3D od_groups, + }, .gov_dbs_update =3D od_dbs_update, .alloc =3D od_alloc, .free =3D od_free, --=20 2.56.1.708.g77570a6a1d-goog From nobody Mon Nov 23 22:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1795116376; cv=none; d=zohomail.com; s=zohoarc; b=iK3+cVEbFAIQbmDtLNhec8PR89MyMmhzDUWfarHSpFGgobVcPgdqzakPCGA6EvzGOeJqvaH7cnd01QN0BlGyQ+dryAUrBJE+Ebsk2vHULN8c+IT1jBbcnNwAOcmL/DZq42ak3BJaG14eMgTtjtw4g5KD4BQM5P7/GhOyDnnWmM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795116376; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ohgce9vn+z31zJY1A4d/uIcUdw7UhPIFGYmbETxOr2U=; b=NmyiSrj7nEV/RkR4IoNVz0i8+oWVOPKOyCFNzGQXz6HY50DYvajA4igcvxnZF7ukUYOKG8Ee/g9+6VZmPs4CqjvddtTXiVCcC1fOC+A1P1usT/Ssdi6iaQHnRSsBndFeWcmGoiNx3o2HHWB3o/QetJED4aTTV/YK9zFT6bLGTV0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1795116376849873.3975260975793; Thu, 19 Nov 2026 11:26:16 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1496851.1695201 (Exim 4.92) (envelope-from ) id 1xU7ld-0003Wx-Qx; Thu, 19 Nov 2026 19:25:57 +0000 Received: by outflank-mailman (output) from mailman id 1496851.1695201; Thu, 19 Nov 2026 19:25:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xU7ld-0003Wk-NU; Thu, 19 Nov 2026 19:25:57 +0000 Received: by outflank-mailman (input) for mailman id 1496851; Thu, 19 Nov 2026 19:25:56 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from <3QU3_agcKCTgcliaYlmaiiafY.WigrYh-XYpYffcmnm.rYhjlidYWn.ila@flex--irogers.bounces.google.com>) id 1xU7lc-0003S8-94 for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 19:25:56 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xU7lb-009Gtq-Le for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 20:25:55 +0100 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from <3QU3_agcKCTgcliaYlmaiiafY.WigrYh-XYpYffcmnm.rYhjlidYWn.ila@flex--irogers.bounces.google.com>) id 6aff4d00-bab6-0a2a0a5309dd-0a2a4501bb7a-44 for ; Thu, 19 Nov 2026 20:25:55 +0100 Received: from [209.85.167.197] (helo=mail-oi1-f197.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from <3QU3_agcKCTgcliaYlmaiiafY.WigrYh-XYpYffcmnm.rYhjlidYWn.ila@flex--irogers.bounces.google.com>) id 6aff4d42-5bcc-0a2a45010019-d155a7c5a84e-3 for ; Thu, 19 Nov 2026 20:25:55 +0100 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-5713cd0fb42so1691302b6e.0 for ; Thu, 19 Nov 2026 11:25:55 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=google.com header.i="@google.com" header.h="Content-Type:Cc:To:From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795116354; x=1795721154; darn=lists.xenproject.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ohgce9vn+z31zJY1A4d/uIcUdw7UhPIFGYmbETxOr2U=; b=ExvQJ7nWUdCD3anPV0mnutgPMbpdFQUZTLZhCuOXimkTwgtKiiEiq5CjIGB/hyIsQb mvrp9cAHRc4HOXFS3fMcR34kuJDPE2Z+Vir1X7eAXGagTBVpfcW7bQ83HWJDL3ZhfN1l wtEdWv00Rk+x3qqdp1tvMOrieaoAgktagayWdIsc/9JgwU3x0limsT8opKWrw2V75Vrb 3ZD+Xz+lLrDziaoObi64ZPDQ4ejR2R3ipg1zgJRnpQNDYj3OP+PNp3nWYZ7LMDvACorM PHwQOotSJnHwKSXNvt0Yh+MWR6pMRcOnmeZus9tCth2WGvhyOInhtP/foK5fu4rIBCmH sYNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795116354; x=1795721154; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ohgce9vn+z31zJY1A4d/uIcUdw7UhPIFGYmbETxOr2U=; b=tCfJO/7aU+2P11UJ0DH5GtnMQICYfUiLGLm8UcRU+9Gla6JQbe/V/T4DdAlFqkRniu aH8bdlz34B9gxG6vLeePyoa5RQnjzxls6Ub7Zrp1dyjxeTMAETsVfXHv3+h+Z3GVu+ha w4mmuUttrl/UtMEi/9GUs2Ss5ezZDad9HNi6D9BWQz6YBweND8q3pIhIn4HHAdWRWNmO 3XL4wJgR5baQjl4PwFsIfp/urs2wJcXe1pt60+X0OPNZctMr1Svw3fXCSpnDWtmfSuDq nj6VB1UkLl332E/z9SWPDMFrWGcSUDdITQb68fYP7sHs5yFaxOMUBsL6TsTHoxf0HpdF vMfQ== X-Forwarded-Encrypted: i=1; AL+hErFjl/VeejIP8llULIUPlGdqImkOjem03ljsW1ibCMxAkikYXISWMAFl/x6g3O915+qp+F964o75zhs=@lists.xenproject.org X-Gm-Message-State: APuU4Z+3SxEz6MjHOpARVhGMO8nQB4VaePiItl9pts0yL1SO8ps5bf8Q aUOnhpQO+Beffl4HOBeQkHnhS4g4wuQ0z6axqMaHRGf7JBbo4qJJR6hi9+xBZVe9vwCG4c5LQ6R Eowv0x5vlIA== X-Received: from ilbdx27-n1.prod.google.com ([2002:a05:6e02:421b:10b0:547:8b66:16bf]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:2383:b0:572:f8ec:5340 with SMTP id 5614622812f47-5797dd97e12mr1569173b6e.40.1795116353256; Thu, 19 Nov 2026 11:25:53 -0800 (PST) Date: Thu, 19 Nov 2026 11:25:16 -0800 In-Reply-To: <20261119192520.1983406-1-irogers@google.com> Mime-Version: 1.0 References: <20261119192520.1983406-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.750.gf70dc682cf-goog Message-ID: <20261119192520.1983406-6-irogers@google.com> Subject: [PATCH v4 5/9] dlm: Wait for kobject release before freeing dlm_ls From: Ian Rogers To: Danilo Krummrich , Greg Kroah-Hartman , Kees Cook , Miguel Ojeda , "Rafael J . Wysocki" Cc: Madhavan Srinivasan , Srish Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Nayna Jain , Mimi Zohar , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Nathan Chancellor , Nick Desaulniers , Viresh Kumar , Zhongqiu Han , Alexander Aring , Felix Kuehling , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , Zhihao Cheng , Sumanth Korikkar , Bill Wendling , Justin Stitt , driver-core@lists.linux.dev, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-s390@vger.kernel.org, gfs2@lists.linux.dev, xen-devel@lists.xenproject.org, linux-mtd@lists.infradead.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ian Rogers X-purgate-ID: tlsNG-d62444/1795116355-BDAE85FD-05A1CE68/0/0 X-purgate-type: clean X-purgate-size: 4540 X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1795116377992158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" struct dlm_ls embeds a struct kobject (ls_kobj), but dlm_ktype lacked a .release callback and dlm freed the lockspace structure directly via kfree(ls). With CONFIG_DEBUG_KOBJECT_RELEASE=3Dy, freeing ls before the delayed kobject release runs causes a use-after-free, and unloading the module while the delayed release is pending results in an instruction page fault. Add a completion ls_kobj_done and dlm_ls_release() to complete it when the last kobject reference is dropped, waiting for it in free_lockspace() before kfree(ls) and in the new_lockspace() error path before module_put(). Also delete the kobject via kobject_del() before stopping dlm_recoverd to close the window where concurrent sysfs writes could wake the stopped recovery task. Fixes: 8a4cf500f1dd ("dlm: drop kobject release callback handling") Acked-by: Alexander Aring Signed-off-by: Ian Rogers --- fs/dlm/dlm_internal.h | 1 + fs/dlm/lockspace.c | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h index 74c2e77d1b55..95b3bff0cb57 100644 --- a/fs/dlm/dlm_internal.h +++ b/fs/dlm/dlm_internal.h @@ -576,6 +576,7 @@ struct dlm_ls { int ls_create_count; /* create/release refcount */ unsigned long ls_flags; /* LSFL_ */ struct kobject ls_kobj; + struct completion ls_kobj_done; =20 struct xarray ls_lkbxa; rwlock_t ls_lkbxa_lock; diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c index a9c98b4f378f..2dccd080a10f 100644 --- a/fs/dlm/lockspace.c +++ b/fs/dlm/lockspace.c @@ -179,7 +179,15 @@ static const struct sysfs_ops dlm_attr_ops =3D { .store =3D dlm_attr_store, }; =20 +static void dlm_ls_release(struct kobject *kobj) +{ + struct dlm_ls *ls =3D container_of(kobj, struct dlm_ls, ls_kobj); + + complete(&ls->ls_kobj_done); +} + static struct kobj_type dlm_ktype =3D { + .release =3D dlm_ls_release, .default_groups =3D dlm_groups, .sysfs_ops =3D &dlm_attr_ops, }; @@ -355,6 +363,8 @@ static void free_lockspace(struct work_struct *work) */ rhashtable_free_and_destroy(&ls->ls_rsbtbl, rhash_free_rsb, NULL); =20 + kobject_put(&ls->ls_kobj); + wait_for_completion(&ls->ls_kobj_done); kfree(ls); } =20 @@ -435,7 +445,10 @@ static int new_lockspace(const char *name, const char = *cluster, ls->ls_lvblen =3D lvblen; atomic_set(&ls->ls_count, 0); init_waitqueue_head(&ls->ls_count_wait); + init_completion(&ls->ls_kobj_done); ls->ls_flags =3D 0; + ls->ls_kobj.kset =3D dlm_kset; + kobject_init(&ls->ls_kobj, &dlm_ktype); =20 if (ops && dlm_config.ci_recover_callbacks) { ls->ls_ops =3D ops; @@ -567,9 +580,7 @@ static int new_lockspace(const char *name, const char *= cluster, wait_event(ls->ls_recover_lock_wait, test_bit(LSFL_RECOVER_LOCK, &ls->ls_flags)); =20 - ls->ls_kobj.kset =3D dlm_kset; - error =3D kobject_init_and_add(&ls->ls_kobj, &dlm_ktype, NULL, - "%s", ls->ls_name); + error =3D kobject_add(&ls->ls_kobj, NULL, "%s", ls->ls_name); if (error) goto out_recoverd; kobject_uevent(&ls->ls_kobj, KOBJ_ADD); @@ -582,7 +593,7 @@ static int new_lockspace(const char *name, const char *= cluster, =20 error =3D do_uevent(ls, 1, 0); if (error < 0) - goto out_recoverd; + goto out_kobj; =20 /* wait until recovery is successful or failed */ wait_for_completion(&ls->ls_recovery_done); @@ -600,6 +611,8 @@ static int new_lockspace(const char *name, const char *= cluster, do_uevent(ls, 0, 0); dlm_clear_members(ls); kfree(ls->ls_node_array); + out_kobj: + kobject_del(&ls->ls_kobj); out_recoverd: dlm_recoverd_stop(ls); out_callback: @@ -615,6 +628,7 @@ static int new_lockspace(const char *name, const char *= cluster, rhashtable_destroy(&ls->ls_rsbtbl); out_lsfree: kobject_put(&ls->ls_kobj); + wait_for_completion(&ls->ls_kobj_done); kfree(ls); out: module_put(THIS_MODULE); @@ -740,6 +754,8 @@ static int release_lockspace(struct dlm_ls *ls, unsigne= d int release_option) dlm_user_daemon_available()) do_uevent(ls, 0, (release_option =3D=3D DLM_RELEASE_RECOVER)); =20 + kobject_del(&ls->ls_kobj); + dlm_recoverd_stop(ls); =20 /* clear the LSFL_RUNNING flag to fast up @@ -759,8 +775,6 @@ static int release_lockspace(struct dlm_ls *ls, unsigne= d int release_option) =20 dlm_delete_debug_file(ls); =20 - kobject_put(&ls->ls_kobj); - xa_destroy(&ls->ls_recover_xa); kfree(ls->ls_recover_buf); =20 --=20 2.56.1.708.g77570a6a1d-goog From nobody Mon Nov 23 22:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1795116380; cv=none; d=zohomail.com; s=zohoarc; b=ipoW0E02cLtCcfJwyufRYNhnnoKhsujkR5M25oyWcaP1ZqCgLpgrGbPiRH2WNiCjUHSADVFIBHHrtxHKGKundYLx2abaXUJnOqNTmpNxkOzCotlf5FIGy8OJTz85zbTFnHZCcE2U5c+atXJQT889tWclB7toRC842WlEXkopxh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795116380; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MCKguj/vcFyjyUsBFpEVwvA/Ew8DwdobaKTpU+d8I2Y=; b=dWLQ1ypUyey6NKAQ2D1iLF7dx/h6/85R9BoFLzPvhfvPvNrvZqUvNk2MupxNXTE+4Lhus30nyNtbSz9qU8XbpE9kBpefv/Np3eCsQYc7cOumJuLq/1d7S+RN5SmwNBjXIhJ+E4BY/KzgP4NydPs+YuSDLiJdJ5T/aCPrCr/Qlm4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1795116380390680.2148792790192; Thu, 19 Nov 2026 11:26:20 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1496857.1695210 (Exim 4.92) (envelope-from ) id 1xU7lj-0003yS-32; Thu, 19 Nov 2026 19:26:03 +0000 Received: by outflank-mailman (output) from mailman id 1496857.1695210; Thu, 19 Nov 2026 19:26:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xU7li-0003y2-Ut; Thu, 19 Nov 2026 19:26:02 +0000 Received: by outflank-mailman (input) for mailman id 1496857; Thu, 19 Nov 2026 19:26:01 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from <3Rk3_agcKCT0hqnfdqrfnnfkd.bnlwdm-cdudkkhrsr.wdmoqnidbs.nqf@flex--irogers.bounces.google.com>) id 1xU7lh-0003rE-M5 for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 19:26:01 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xU7lh-009Gtq-2c for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 20:26:01 +0100 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from <3Rk3_agcKCT0hqnfdqrfnnfkd.bnlwdm-cdudkkhrsr.wdmoqnidbs.nqf@flex--irogers.bounces.google.com>) id 6aff4d00-bab6-0a2a0a5309dd-0a2a4501bb7a-46 for ; Thu, 19 Nov 2026 20:26:01 +0100 Received: from [209.85.210.199] (helo=mail-pf1-f199.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from <3Rk3_agcKCT0hqnfdqrfnnfkd.bnlwdm-cdudkkhrsr.wdmoqnidbs.nqf@flex--irogers.bounces.google.com>) id 6aff4d47-5bcc-0a2a45010019-d155d2c7ec54-3 for ; Thu, 19 Nov 2026 20:26:00 +0100 Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-8a0522cdaf3so128907b3a.0 for ; Thu, 19 Nov 2026 11:26:00 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=google.com header.i="@google.com" header.h="Content-Type:Cc:To:From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795116359; x=1795721159; darn=lists.xenproject.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MCKguj/vcFyjyUsBFpEVwvA/Ew8DwdobaKTpU+d8I2Y=; b=M8grnIPML6ii9Yu3gnxkle744qJYZfA598Iq4AswY5uJlNHpTTSaqO1cjcZiyunD8N nj8IWoBQYS7ajgPw1Q4VTUMbm2VdNpNpfQck+clmBQ+ctkkV1rlfpMwbd+bmWoVYL8eD 8JktL0BU70L6jIvQswEUJP/UfVuyqfyw/hvHlHDwnrtz/sUTEn7T8yehkgseYNEL2rkc 9LvM35wUZdTp5OoT7nm7yZQJYooh5wBxS0Tzqz/DBR9DwirYRC9MGT2ONikD0NgH1mr7 jM0VJCZNZXRJ4f5BG7ab99y2K67wAOlUhHzFGdX/1BeEAiCeJcteUgA+LUyz+bTnPrCH X71A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795116359; x=1795721159; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=MCKguj/vcFyjyUsBFpEVwvA/Ew8DwdobaKTpU+d8I2Y=; b=vLb/SpOUCDRrMIeOQL2pEw5WM138jcgq4nnaaosxWGLb/uv+6T4e7PjssnNPkDsc4V W7UN88Dk5jN6b/PQVjfYdx7DYqq1CBY3UiIY5jmrR4fVLuPdkO1S3OhO5DhwGq22u7io 358DS48GjtwkY7yiZJBmqJZyiAIVqtIvpgUhXA/i4Mq3i4GpzgYsjuLwB2alFlDC1H/r HjJX0Y/Z5AcNeLKxw4W7bpBjWTPJrfpCgjl8qqKUqTaFusrwd02KLszM7t+UVV7DEJdf ez94czSNRcjiDGRqg3K9o+hA3kiv5+sANjjFYZxa37smlxoIpaQShqGmgU3Gnf0UaAfB K3rA== X-Forwarded-Encrypted: i=1; AL+hErFuXJom9BMuct0lu2yscm3rvy2zaan+Og8fzlvGcjAq2QAt2mO1g6M1tnaLCWMXLMRpZ8zxmVbfK0o=@lists.xenproject.org X-Gm-Message-State: APuU4Z+kpEtcSiofFyH/9UTWGxB6xMACVRR2B/ZDDzEHRTjz9ttn0mYj HNTF3YPygBstn7b1M7H0aJSdzpdcWIZMDjok+ODXS1AKik7JizTdRm/U0FoKRbW1x2z/MSu+xiK AIqaueLe+qQ== X-Received: from pgjk11-n2.prod.google.com ([2002:a05:6a02:81cb:20b0:cd6:1fc4:6199]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:9191:b0:3fb:1bfb:ff29 with SMTP id adf61e73a8af0-4014e74d624mr589862637.69.1795116358583; Thu, 19 Nov 2026 11:25:58 -0800 (PST) Date: Thu, 19 Nov 2026 11:25:17 -0800 In-Reply-To: <20261119192520.1983406-1-irogers@google.com> Mime-Version: 1.0 References: <20261119192520.1983406-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.750.gf70dc682cf-goog Message-ID: <20261119192520.1983406-7-irogers@google.com> Subject: [PATCH v4 6/9] xen/sys-hypervisor: Add release callback to hyp_sysfs_kobj_type From: Ian Rogers To: Danilo Krummrich , Greg Kroah-Hartman , Kees Cook , Miguel Ojeda , "Rafael J . Wysocki" Cc: Madhavan Srinivasan , Srish Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Nayna Jain , Mimi Zohar , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Nathan Chancellor , Nick Desaulniers , Viresh Kumar , Zhongqiu Han , Alexander Aring , Felix Kuehling , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , Zhihao Cheng , Sumanth Korikkar , Bill Wendling , Justin Stitt , driver-core@lists.linux.dev, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-s390@vger.kernel.org, gfs2@lists.linux.dev, xen-devel@lists.xenproject.org, linux-mtd@lists.infradead.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ian Rogers X-purgate-ID: tlsNG-d62444/1795116361-4C5555FD-B969FD0E/0/0 X-purgate-type: clean X-purgate-size: 1202 X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1795116382000158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" hypervisor_init() in drivers/base/hypervisor.c creates hypervisor_kobj with kobject_create_and_add() (which allocates a dynamic kobject using dynamic_kobj_ktype), and hypervisor_subsys_init() in drivers/xen/sys-hypervisor.c then overwrites hypervisor_kobj->ktype with &hyp_sysfs_kobj_type, which had no .release callback. Add hyp_sysfs_release() calling kfree(kobj) to preserve the dynamic kobject release behavior. Fixes: cff7e81b3dd7 ("xen: add /sys/hypervisor support") Reviewed-by: Juergen Gross Signed-off-by: Ian Rogers --- drivers/xen/sys-hypervisor.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/xen/sys-hypervisor.c b/drivers/xen/sys-hypervisor.c index 91923242a5ae..0e8a2cd69fd6 100644 --- a/drivers/xen/sys-hypervisor.c +++ b/drivers/xen/sys-hypervisor.c @@ -659,7 +659,13 @@ static const struct sysfs_ops hyp_sysfs_ops =3D { .store =3D hyp_sysfs_store, }; =20 +static void hyp_sysfs_release(struct kobject *kobj) +{ + kfree(kobj); +} + static const struct kobj_type hyp_sysfs_kobj_type =3D { + .release =3D hyp_sysfs_release, .sysfs_ops =3D &hyp_sysfs_ops, }; =20 --=20 2.56.1.708.g77570a6a1d-goog From nobody Mon Nov 23 22:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1795116389; cv=none; d=zohomail.com; s=zohoarc; b=Ksm0qHkAKicJKX9SwFBGSPiUUcszArgfqDbKoTop7zFZ3n78UncJ2zmuTfkjZn7s8hoSTd7FQIG0c//AlZ+pXhZABma9rx3Hk8lq6yQHT+rbA0Q17cw8AKv7PgiuIlAYgk6CBT1wV06x9xjILJhg+BxAH+N770GHeZ5yESSes3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795116389; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CSDEU43/2Gwf+VbjlCClZWJ4rTvHhhRb4YqVFYZr7ik=; b=L8TBXsLAX+zU7hdN3HvAtYUtyZdYR2oMqams0qJRQcy8Qu5MS3VZAQ0g6vv43R3X2lNECTKd1EzL/LhAjNeeqt3zaNJHQUut8vQJaBuO57Nmu2B5CXd+MQGZrGTT3xXyDim37yUX8xRg0vaaLiZPFWeJnzW/PBdXishTd1YdqB4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1795116389693840.8713542057155; Thu, 19 Nov 2026 11:26:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1496873.1695218 (Exim 4.92) (envelope-from ) id 1xU7lo-0004Sn-En; Thu, 19 Nov 2026 19:26:08 +0000 Received: by outflank-mailman (output) from mailman id 1496873.1695218; Thu, 19 Nov 2026 19:26:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xU7lo-0004Sg-Be; Thu, 19 Nov 2026 19:26:08 +0000 Received: by outflank-mailman (input) for mailman id 1496873; Thu, 19 Nov 2026 19:26:08 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from <3TE3_agcKCUMnwtljwxlttlqj.htr2js-ij0jqqnxyx.2jsuwtojhy.twl@flex--irogers.bounces.google.com>) id 1xU7ln-0004QR-Tu for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 19:26:07 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xU7ln-00DAfz-AH for xen-devel@lists.xenproject.org; Thu, 19 Nov 2026 20:26:07 +0100 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from <3TE3_agcKCUMnwtljwxlttlqj.htr2js-ij0jqqnxyx.2jsuwtojhy.twl@flex--irogers.bounces.google.com>) id 6aff4d47-2eae-0a2a0a5409dd-0a2a4502db8e-20 for ; Thu, 19 Nov 2026 20:26:07 +0100 Received: from [209.85.216.69] (helo=mail-pj1-f69.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from <3TE3_agcKCUMnwtljwxlttlqj.htr2js-ij0jqqnxyx.2jsuwtojhy.twl@flex--irogers.bounces.google.com>) id 6aff4d4d-4900-0a2a45020019-d155d845b9ca-3 for ; Thu, 19 Nov 2026 20:26:07 +0100 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-3b41aa2b9a8so132471a91.3 for ; Thu, 19 Nov 2026 11:26:06 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=google.com header.i="@google.com" header.h="Content-Type:Cc:To:From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795116365; x=1795721165; darn=lists.xenproject.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=CSDEU43/2Gwf+VbjlCClZWJ4rTvHhhRb4YqVFYZr7ik=; b=Sp1rxLbhIVz2UV97jF+z1R9utMwB2pkeeErtrBUr74W0KSeC2RKsTuiE53nIi+j3Kf VeSDIKB1tXwKWXOXzn3aHS66O9/R9eu4KQD9MPO9W5V/zChESCL6l2+XTTD4pE+UCVc0 mHnbizIgNL08/dXdu/wNFWuUAvCgfJoEroZnCcYezvNNuSdKiGiCOgA2ostmgDkpGcVJ /wG+WorRRwDJnBJOCymBZKdUAw76ri1ZXSZSujrsgZmuxs4NIphqMrDzoOZsT/Ovo7lh AAaAK+TKjF8ZatEPqsKleKW/FYDuvUv7GOC8nsoVocpDCNQSCaoA6rivW2QOJW4XQy+/ H3hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795116365; x=1795721165; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=CSDEU43/2Gwf+VbjlCClZWJ4rTvHhhRb4YqVFYZr7ik=; b=wtuxAoj1rD46b/giKjmfoExfHBs5PTL3ojm6pdRYREr94bRzvXU4bnYW2x5MmivVT7 nqKNnm1YYIsjjwJlKvauRRbEXbyGrOaQxzlL8Iku948nahAkgxPrEHMV8uyU4w5+TIcy /TqLIYYTI13KIWUxFOJE12dvp22SaxU7u2zFPXXh0A5axAXzyA7nQvTOtPLSlgi3ZZLX 2l1J1+IrzdmEq9kcyk4pnN5O7A/m5wxZuajU6CzCHl4iKKjwmVDdlL4dGT8U/Qlx8Rnl 4O5HPWBty9cgDr6CnubRdbyQVenSlh1ilrWK8Cl9pc+qhATTkOqIqGavpjILpEwdkifQ Nl+A== X-Forwarded-Encrypted: i=1; AL+hErHIpX4h0qkp7H54kbJIgRp2zD0h/mayO1DWb2lnyFcwzVb+MVv0kfdJVVNd9ejC1pijLjtYJxAtiWE=@lists.xenproject.org X-Gm-Message-State: APuU4Z+ocxjTXhq/3KX8CYonVqqBCcyPdIAUPopzXCq++4Ycn1UmyaOX h6zuVFres7f6Jn8gnZfqIVnBv/xO3KUHLQxmvL8ycAXNQVwqbr3W84zY1HnFrhbapxJ0lHLIFco FjDe6a2oIyg== X-Received: from pjbsk16.prod.google.com ([2002:a17:90b:2dd0:b0:3b3:ada0:c008]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1c03:b0:3b4:1bf1:988f with SMTP id 98e67ed59e1d1-3b41cb138f0mr288962a91.54.1795116364835; Thu, 19 Nov 2026 11:26:04 -0800 (PST) Date: Thu, 19 Nov 2026 11:25:18 -0800 In-Reply-To: <20261119192520.1983406-1-irogers@google.com> Mime-Version: 1.0 References: <20261119192520.1983406-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.750.gf70dc682cf-goog Message-ID: <20261119192520.1983406-8-irogers@google.com> Subject: [PATCH v4 7/9] ubifs: sysfs: Use kset_create_and_add() for ubifs_kset From: Ian Rogers To: Danilo Krummrich , Greg Kroah-Hartman , Kees Cook , Miguel Ojeda , "Rafael J . Wysocki" Cc: Madhavan Srinivasan , Srish Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Nayna Jain , Mimi Zohar , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Nathan Chancellor , Nick Desaulniers , Viresh Kumar , Zhongqiu Han , Alexander Aring , Felix Kuehling , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , Zhihao Cheng , Sumanth Korikkar , Bill Wendling , Justin Stitt , driver-core@lists.linux.dev, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-s390@vger.kernel.org, gfs2@lists.linux.dev, xen-devel@lists.xenproject.org, linux-mtd@lists.infradead.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ian Rogers X-purgate-ID: tlsNG-720697/1795116367-32F916C6-5E433B28/0/0 X-purgate-type: clean X-purgate-size: 2049 X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1795116390039158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ubifs_kset was a static struct kset using a custom ubifs_ktype that had no default_groups and no .release callback. With CONFIG_DEBUG_KOBJECT_RELEASE=3Dy, unloading the ubifs module while delayed kobject release is pending causes a use-after-free on the static kset. Replace the static ubifs_kset and empty ubifs_ktype with a dynamically allocated kset via kset_create_and_add(). Fixes: 2e3cbf425804 ("ubifs: Export filesystem error counters") Tested-by: Zhihao Cheng Reviewed-by: Zhihao Cheng Signed-off-by: Ian Rogers --- fs/ubifs/sysfs.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/fs/ubifs/sysfs.c b/fs/ubifs/sysfs.c index dbf967dcf26e..e20931e3a62f 100644 --- a/fs/ubifs/sysfs.c +++ b/fs/ubifs/sysfs.c @@ -80,13 +80,7 @@ static const struct kobj_type ubifs_sb_ktype =3D { .release =3D ubifs_sb_release, }; =20 -static const struct kobj_type ubifs_ktype =3D { - .sysfs_ops =3D &ubifs_attr_ops, -}; - -static struct kset ubifs_kset =3D { - .kobj =3D {.ktype =3D &ubifs_ktype}, -}; +static struct kset *ubifs_kset; =20 int ubifs_sysfs_register(struct ubifs_info *c) { @@ -107,7 +101,7 @@ int ubifs_sysfs_register(struct ubifs_info *c) goto out_free; } =20 - c->kobj.kset =3D &ubifs_kset; + c->kobj.kset =3D ubifs_kset; init_completion(&c->kobj_unregister); =20 ret =3D kobject_init_and_add(&c->kobj, &ubifs_sb_ktype, NULL, @@ -139,18 +133,14 @@ void ubifs_sysfs_unregister(struct ubifs_info *c) =20 int __init ubifs_sysfs_init(void) { - int ret; + ubifs_kset =3D kset_create_and_add("ubifs", NULL, fs_kobj); + if (!ubifs_kset) + return -ENOMEM; =20 - kobject_set_name(&ubifs_kset.kobj, "ubifs"); - ubifs_kset.kobj.parent =3D fs_kobj; - ret =3D kset_register(&ubifs_kset); - if (ret) - kset_put(&ubifs_kset); - - return ret; + return 0; } =20 void ubifs_sysfs_exit(void) { - kset_unregister(&ubifs_kset); + kset_unregister(ubifs_kset); } --=20 2.56.1.708.g77570a6a1d-goog From nobody Mon Nov 23 22:28:33 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795116372; b=gGeagby5hCr0Dfh+RRZlnbygIIEP1EWq9pVbHsHp/cywAuCmc0b57ZQXTpqxSgN5C/ca aEOLs132IodfIQSuC/O8aefggbNtMJnkwmdG641FbTQWgNks2gtxEeXoRpGJRBmpmpJtg xOEgVJeR3HaER5ckotQ/ysden06Kn1zkMBwdnpUKZ7LjJH35MGaGEoQgYs567Su3lSbM/ NR4KKk0d4/oZbD0U6E/XjT6U9DIOSfQ3nfMIhMs8ScLEZKhhbWGPDKZN25qlpFa8qGsU6 N1VkEJGyzi7BP74353aaJ2j2V7Elst0QzSHOl2uVAOZIrcKJ/lpn6ELCa0f+QLeRsCw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795116372; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=ed6ZuPWwDHIYUoQ+FZI+Wi1n/4SIGbM4V5gI4MqacGo=; b=341HzzZciV2gSWU9xzJVycTI38fNa7/LyeFpHWsf4eA9NUtMJjTTqmfRSZejvKn/LR5j R8auaxbiuUeMM+kHynWFhlSzQ7sxm55/etF+cOaGusFpZQucvOMGSYjQL8ygG2Oyr1YPY MhWMEasXWN4w4BhiSiU5h0R9GCPFuZNnhBRSc8Ga2hmr+QPrd4BcAfWggLjh/hezfuz7O X0WVePiMxzyZRVu7zR9js85gQnSL3jIQqFTxL3YTTXK9zuFiEfmypdw+a5N8AJverH3wF LbqlRkp51biLycX429eBFIdU5TaHWHs3Ka0pTGmHc1+pXOZGfS6ohmaot5Rtx5dTebA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=kLKVMsB9; arc=none smtp.remote-ip=74.125.82.200 Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AD89606A32A for ; Thu, 19 Nov 2026 19:26:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5AD89606A32A 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.a=rsa-sha256 header.s=20260707 header.b=kLKVMsB9 Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-383f2d05c73so196799eec.0 for ; Thu, 19 Nov 2026 11:26:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795116371; x=1795721171; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ed6ZuPWwDHIYUoQ+FZI+Wi1n/4SIGbM4V5gI4MqacGo=; b=kLKVMsB9YDaG4K9j6iMehsycwJx0ij9U+zmFqOnRmYHu53t6nEiX3t8yU3HxVvB+b/ 6KyiT8DM3Qe/mOTjAtQojTdUiR3Z33rCCdl8HCeQIoVhmg5xeCyf1uUTKPgTB08m9y0W wh7Bmx0trBkjDpJikZ7sItLvMM5zb51kE7X5w2jxhGQpoWhxk7dPMrKtTAtkRESJSasl VT8nSjUna2MpBdK/el90bXgng+kJf0I/4O9/UiUly1YL2wWCJzd+BxjmU8W+0PGukBpd UFdMDTd7qYZhFtxn421uPMqlzEIuGiHyOF7/dHCv+cPKTMuu4RJNDBg/PJiY61zY2WF4 7jVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795116371; x=1795721171; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ed6ZuPWwDHIYUoQ+FZI+Wi1n/4SIGbM4V5gI4MqacGo=; b=Y6zGTMXP+mPSMyTBI7SEgLFRq5tVEwvbphk85z5H9axQfJKyGo3j0T8Y8UEdtXmZ4R 5Ju9ci2LrD5lN4cZs2wjK+97nCf55PnllbNO40WQalBe5lAqQXrqiCS4yNq331cSmKD2 IQbQWqOYJK0tMhhU2VMbHj1k/0IlSmT679UCUFTjl4w+4z6y/sS46jbpbK+zKxhHq2CB ABL28HGxXHbvcJ0FNpbUT+HkXAGfGweuKcjGPQeBGsk4OzwnztY5DZF3MMu8KZS4H/OG c3j+NELp/Zv1s9RgC1WXBkJqLxNU8XOzPch0XxnX/zd7L7hng4bdPlU0TxPoSuBRrU2k RMkw== X-Forwarded-Encrypted: i=1; AL+hErGeLX+HkRsGqft4ui10DkXRatOOK92CoO8jGdeQaIrXYc4KdFX4B6FdRee1+eocP7Y8Cfv0LYB/qo9UCdM=@vger.kernel.org X-Gm-Message-State: APuU4Z+1qBcfSeJ34kD8614ONq4xB+58kp5U7QTjr4q423yAf80bjVFM aqS920ri9O6xn14oYwnK+KVl1C3qtDd9eVDEy4JtvKJ99b37oJL51SsSrDrZpH3x5kdmnsb43Qh QMDoXwvCJqQ== X-Received: from dyhd22.prod.google.com ([2002:a05:7300:8296:b0:381:d3ca:9f05]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:6018:b0:381:9593:9984 with SMTP id 5a478bee46e88-3857151d6abmr284926eec.37.1795116370935; Thu, 19 Nov 2026 11:26:10 -0800 (PST) Date: Thu, 19 Nov 2026 11:25:19 -0800 In-Reply-To: <20261119192520.1983406-1-irogers@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261119192520.1983406-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.750.gf70dc682cf-goog Message-ID: <20261119192520.1983406-9-irogers@google.com> Subject: [PATCH v4 8/9] drm/amdkfd: Free queue in procfs_queue_type kobject release callback From: Ian Rogers To: Danilo Krummrich , Greg Kroah-Hartman , Kees Cook , Miguel Ojeda , "Rafael J . Wysocki" Cc: Madhavan Srinivasan , Srish Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Nayna Jain , Mimi Zohar , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Nathan Chancellor , Nick Desaulniers , Viresh Kumar , Zhongqiu Han , Alexander Aring , Felix Kuehling , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , Zhihao Cheng , Sumanth Korikkar , Bill Wendling , Justin Stitt , driver-core@lists.linux.dev, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-s390@vger.kernel.org, gfs2@lists.linux.dev, xen-devel@lists.xenproject.org, linux-mtd@lists.infradead.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" struct queue embeds a struct kobject (q->kobj) for procfs entries, but procfs_queue_type had no .release callback and uninit_queue() freed q immediately after kfd_procfs_del_queue() called kobject_put(&q->kobj). With CONFIG_DEBUG_KOBJECT_RELEASE=3Dy, this causes a use-after-free. Add kfd_procfs_queue_release() to free struct queue from the kobject release callback, change kfd_procfs_del_queue() to only remove the kobject from sysfs via kobject_del(), and drop the final reference in uninit_queue() via kobject_put(). Check q->kobj.state_in_sysfs before calling kobject_del() in kfd_procfs_del_queue() to avoid warnings if sysfs creation previously failed. Fixes: 6d220a7e7971 ("drm/amdkfd: Add queue information to sysfs") Reviewed-by: Felix Kuehling Signed-off-by: Ian Rogers --- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 12 +++++++++--- drivers/gpu/drm/amd/amdkfd/kfd_queue.c | 5 ++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd= /amdkfd/kfd_process.c index 6663718fb83c..b349e0d8d47b 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c @@ -512,7 +512,15 @@ static const struct sysfs_ops procfs_queue_ops =3D { .show =3D kfd_procfs_queue_show, }; =20 +static void kfd_procfs_queue_release(struct kobject *kobj) +{ + struct queue *q =3D container_of(kobj, struct queue, kobj); + + kfree(q); +} + static const struct kobj_type procfs_queue_type =3D { + .release =3D kfd_procfs_queue_release, .sysfs_ops =3D &procfs_queue_ops, .default_groups =3D procfs_queue_groups, }; @@ -552,7 +560,6 @@ int kfd_procfs_add_queue(struct queue *q) if (ret < 0) { pr_warn("Creating proc//queues/%u failed", q->properties.queue_id); - kobject_put(&q->kobj); return ret; } =20 @@ -697,11 +704,10 @@ static void kfd_procfs_add_sysfs_files(struct kfd_pro= cess *p) =20 void kfd_procfs_del_queue(struct queue *q) { - if (!q || !q->process->kobj) + if (!q || !q->process || !q->process->kobj || !q->kobj.state_in_sysfs) return; =20 kobject_del(&q->kobj); - kobject_put(&q->kobj); } =20 int kfd_process_create_wq(void) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_queue.c b/drivers/gpu/drm/amd/a= mdkfd/kfd_queue.c index cd41b10e0873..636cc894223d 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_queue.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_queue.c @@ -83,7 +83,10 @@ int init_queue(struct queue **q, const struct queue_prop= erties *properties) =20 void uninit_queue(struct queue *q) { - kfree(q); + if (q && q->kobj.state_initialized) + kobject_put(&q->kobj); + else + kfree(q); } =20 #if IS_ENABLED(CONFIG_HSA_AMD_SVM) --=20 2.56.1.708.g77570a6a1d-goog From nobody Mon Nov 23 22:28:33 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.198 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795116379; b=ABxTZEuwPU8uOMeTcW5ib1zXMNMuoEu5jBFhXIyBW3lTEqOqis9ty2zBcgndJcKntB2h Cqt66RN1YEsDImkyAG8x0d3x/Ufg6vLiz0E2JLwycAieOFCfQNhx/KOqvmHk5ePJXQDRI pm4Y7LwGey9A3jILnpjlQOnUWyGjGZtYgjy+hP5xeuEc4DjxM48X/qudcQP2KUqTyIx8J 0F/TTSNw4XP99O/FOIRNmoYiiecBL05sk/bdzITFdtsi8AnGW/wQPVCtZGfMmpPyZ21/m IwROlEAEPaegpP4ntfGIXLq0dH68kj4tFIXxQPxGZVARKfQrX40iGhpjZfVAY22kPAg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795116379; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=d2DVsEOIJmONwY68Fz20HCkoh5ZG0X1B/QknI6oOs3U=; b=TkHLcs64b3Sc7tcc7Yyr6kiAIgGdRjyfnTnKDgltUHAIljOBubIPrTmrQjsW76kH9QqL xe02xeVr+bTIDXlA+tG+lWoCLaNIRC0cfk+OhCIDlQlL0GXrqkgTv38McL5Nf+Y7K8DD7 EjMkV0po/7tr4+z4KOZR9mCVHEQNrphjF5EadRKxmjFu0XNmJA7cmhlWNIU/p5Lsu+EQp hIsesTMnm3jU1433KwxoOP1TN2nan26/U8bjQWfvMErSrrncdcG97wn5ICCyuhlb4IYp4 qSxrupgfJ/BqX07iyNzaanxUncCu0W+FUzFrz+03t2qAANN9xxhaV5elSlaNDV2JUMQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=levS3667; arc=none smtp.remote-ip=209.85.167.198 Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3E0860A261B for ; Thu, 19 Nov 2026 19:26:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E3E0860A261B 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.a=rsa-sha256 header.s=20260707 header.b=levS3667 Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-5727b04b81eso117394b6e.3 for ; Thu, 19 Nov 2026 11:26:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795116378; x=1795721178; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=d2DVsEOIJmONwY68Fz20HCkoh5ZG0X1B/QknI6oOs3U=; b=levS3667ihkpDSZGBZoTL8DB4CxLcn4v4iMxxr4UaPMr3s2xk5H4TeYZonGwE6R95d 5IIWRLUyEmU8irpDCOOB0avCAJgCqXnr5tqXMkYM1vC8KjrXU8vYZQj/yFa0N8Eg7PoL uSIOAYtghLq5K4g737oVLjq3MqXt29ODZMqKRByOSDM+2IYxO3NTRQEzmpQbUqMC9SOX qoDmO6SBrmQK/C4jLpvSEJRqYKd30MjKuAXeqfP5EW59dmOHXnWaGKK4O9y8kN5NZM3f w7vtlvGpTVFreZFwgreAvhZVFLRr5+nb0gLmdmYfUMTqpe2thObuHM0Twl7AKogmC+WM gMaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795116378; x=1795721178; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=d2DVsEOIJmONwY68Fz20HCkoh5ZG0X1B/QknI6oOs3U=; b=Tva0qrfc45oHNtYeqzr9tf+cUoNMXYfta/V36BLnuu9WY1zLtl4aoLYQc0oNjg/UKT uG0BfCKI+ybVMDbxC79V8hSEEEXb7OhldnzJAhECR4CyXW0O+clzdX0V37f1+q5StdjA ANjKZHf1FXyIc8J5DwuALkXf+IhrA07a6HDsEPtuWNk0S2QHdQXpVZWTe8pr0fkWPY75 Al4vRhQJvyLSQqkjmqNJIvSxtBY7JrkUO2jxLjKQHzacEgvZng366RM9IdUEatrb3oyk 108vxH0SL2KYmEbj0HNoDhsNJR8hxPo+dzKooyasaip10FuYuIvBGHCTPKM5YpF1m087 hzMA== X-Forwarded-Encrypted: i=1; AL+hErHcXWya9F/O37IfGzJz65hihd4EPF20d4E0wM+Mg42VkayKmigSYQOxjFuxdnxtET/ozqGr3ZNGlvPk050=@vger.kernel.org X-Gm-Message-State: APuU4Z9xowjT+qxGtjZpRB1J/V/bwp5+PnF5G97xXT9FCx12USIH6oG7 etmvKw+G7isSAB1UUJhwHUzhtPCUF0r8g+yvlM2k3gfPqgKJBq3dxWif68q3upfKgOfM8ejLhun aoeiEPVVoRQ== X-Received: from jaqb6.prod.google.com ([2002:a05:6638:1a6:b0:61f:e4cd:8716]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:c3eb:b0:4b9:e5fa:8a17 with SMTP id 5614622812f47-57a0a913526mr994137b6e.28.1795116377408; Thu, 19 Nov 2026 11:26:17 -0800 (PST) Date: Thu, 19 Nov 2026 11:25:20 -0800 In-Reply-To: <20261119192520.1983406-1-irogers@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261119192520.1983406-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.750.gf70dc682cf-goog Message-ID: <20261119192520.1983406-10-irogers@google.com> Subject: [PATCH v4 9/9] kobject: Require explicit initialization of struct kobj_type::release From: Ian Rogers To: Danilo Krummrich , Greg Kroah-Hartman , Kees Cook , Miguel Ojeda , "Rafael J . Wysocki" Cc: Madhavan Srinivasan , Srish Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Nayna Jain , Mimi Zohar , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Nathan Chancellor , Nick Desaulniers , Viresh Kumar , Zhongqiu Han , Alexander Aring , Felix Kuehling , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , Zhihao Cheng , Sumanth Korikkar , Bill Wendling , Justin Stitt , driver-core@lists.linux.dev, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-s390@vger.kernel.org, gfs2@lists.linux.dev, xen-devel@lists.xenproject.org, linux-mtd@lists.infradead.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Documentation/core-api/kobject.rst states: "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. Note that the kernel will warn you if you forget to provide a release() method. Do not try to get rid of this warning by providing an \"empty\" release function." Annotate struct kobj_type::release with __must_init so the compiler diagnoses any struct kobj_type initializer that omits .release. For the remaining legacy struct kobj_type definitions that still omit a release callback, explicitly initialize .release =3D NULL and document each site's lifetime status: - In built-in code where the backing storage is static, per-CPU, or allocated once at boot and never freed (arm64 cpuinfo, ACPI hotplug profiles, and s390 sclp_mem), note that omitting release() violates the kobject API contract while explaining what guarantees the storage outlives kobject cleanup. - In drivers and tristate modules with broken kobject lifetime management (where enclosing dynamic or devm allocations are freed or zeroed independently of kobject_put(), or where module unload unmaps static kobjects/ksets while final or CONFIG_DEBUG_KOBJECT_RELEASE delayed cleanup may still be pending), document the lifetime hazard with a FIXME comment for follow-up fixes. This change does not alter runtime behavior at these sites. Link: https://lpc.events/event/20/contributions/2392/ Signed-off-by: Ian Rogers --- arch/arm64/kernel/cpuinfo.c | 7 +++++++ drivers/acpi/sysfs.c | 7 +++++++ drivers/dma/ioat/sysfs.c | 8 +++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 8 +++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 17 +++++++++++++++ drivers/infiniband/hw/hfi1/sysfs.c | 7 +++++++ drivers/infiniband/hw/usnic/usnic_ib_sysfs.c | 7 +++++++ drivers/parisc/pdc_stable.c | 8 +++++++ drivers/power/supply/ab8500_fg.c | 8 +++++++ drivers/s390/char/sclp_mem.c | 6 ++++++ drivers/soc/hisilicon/kunpeng_hccs.c | 18 ++++++++++++++++ .../fbdev/omap2/omapfb/dss/display-sysfs.c | 7 +++++++ .../fbdev/omap2/omapfb/dss/manager-sysfs.c | 8 +++++++ .../fbdev/omap2/omapfb/dss/overlay-sysfs.c | 7 +++++++ fs/erofs/sysfs.c | 14 +++++++++++++ fs/f2fs/sysfs.c | 21 +++++++++++++++++++ fs/ocfs2/cluster/masklog.c | 7 +++++++ include/linux/kobject.h | 2 +- 18 files changed, 166 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 94e6cd211d70..7c374b8c25af 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -295,6 +295,13 @@ const struct seq_operations cpuinfo_op =3D { =20 =20 static const struct kobj_type cpuregs_kobj_type =3D { + /* + * Omitting release() violates the kobject API contract, but lifetime + * is safe: info->kobj is embedded in built-in static per-CPU cpu_data + * that is never freed or passed to kobject_put() (CPU hotplug only + * toggles sysfs visibility via kobject_add() and kobject_del()). + */ + .release =3D NULL, .sysfs_ops =3D &kobj_sysfs_ops, }; =20 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index a4534b3e3cfb..d435b565ad19 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c @@ -975,6 +975,13 @@ static struct attribute *hotplug_profile_attrs[] =3D { ATTRIBUTE_GROUPS(hotplug_profile); =20 static const struct kobj_type acpi_hotplug_profile_ktype =3D { + /* + * Omitting release() violates the kobject API contract, but lifetime + * is safe: hotplug->kobj is only embedded in static built-in + * struct acpi_scan_handler instances that are never unregistered or + * freed. + */ + .release =3D NULL, .sysfs_ops =3D &kobj_sysfs_ops, .default_groups =3D hotplug_profile_groups, }; diff --git a/drivers/dma/ioat/sysfs.c b/drivers/dma/ioat/sysfs.c index 976134df8108..ec5a90c7aded 100644 --- a/drivers/dma/ioat/sysfs.c +++ b/drivers/dma/ioat/sysfs.c @@ -167,6 +167,14 @@ static const struct attribute *const ioat_attrs[] =3D { ATTRIBUTE_GROUPS(ioat); =20 const struct kobj_type ioat_ktype =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): + * ioat_kobject_del() calls kobject_put(&ioat_chan->kobj) and + * release_ioatdma() frees ioat_chan via kfree() without waiting for + * final kobject cleanup (use-after-free if a sysfs reference is held + * or under CONFIG_DEBUG_KOBJECT_RELEASE). + */ + .release =3D NULL, .sysfs_ops =3D &ioat_sysfs_ops, .default_groups =3D ioat_groups, }; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/a= md/amdgpu/amdgpu_ualink.c index d025b4183b29..5aa90f1271e4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c @@ -892,6 +892,14 @@ static const struct attribute_group ualink_xcp_info_gr= oup =3D { }; =20 static const struct kobj_type ualink_xcp_info_ktype =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): + * xcp->ualink.kobj is embedded in adev->xcp_mgr; + * amdgpu_ualink_xcp_sysfs_remove() calls kobject_put() and + * amdgpu_device_fini_sw() later calls kfree(adev->xcp_mgr) without + * waiting for final kobject cleanup. + */ + .release =3D NULL, .sysfs_ops =3D &kobj_sysfs_ops }; =20 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_xcp.c index ab14079d1c42..8e21bf57596c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c @@ -797,6 +797,16 @@ static const struct sysfs_ops xcp_cfg_res_sysfs_ops = =3D { }; =20 static const struct kobj_type xcp_cfg_res_sysfs_ktype =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): xcp_res->kobj + * is embedded in struct amdgpu_xcp_cfg, freed by parent xcp_cfg->kobj's + * xcp_cfg_sysfs_release(). While an added child pins xcp_cfg->kobj + * until kobject_cleanup() finishes, if kobject_init_and_add() fails in + * amdgpu_xcp_cfg_sysfs_init() no parent reference is held and + * kfree(xcp_cfg) can race with delayed cleanup under + * CONFIG_DEBUG_KOBJECT_RELEASE. + */ + .release =3D NULL, .sysfs_ops =3D &xcp_cfg_res_sysfs_ops, .default_groups =3D xcp_cfg_res_sysfs_groups, }; @@ -1061,6 +1071,13 @@ static const struct attribute_group amdgpu_xcp_attrs= _group =3D { }; =20 static const struct kobj_type xcp_sysfs_ktype =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): xcp->kobj is + * embedded in adev->xcp_mgr; amdgpu_xcp_sysfs_entries_fini() calls + * kobject_put() and amdgpu_device_fini_sw() later calls + * kfree(adev->xcp_mgr) without waiting for final kobject cleanup. + */ + .release =3D NULL, .sysfs_ops =3D &kobj_sysfs_ops, }; =20 diff --git a/drivers/infiniband/hw/hfi1/sysfs.c b/drivers/infiniband/hw/hfi= 1/sysfs.c index 372cfd13dc61..dc6693822589 100644 --- a/drivers/infiniband/hw/hfi1/sysfs.c +++ b/drivers/infiniband/hw/hfi1/sysfs.c @@ -608,6 +608,13 @@ static const struct sysfs_ops sde_sysfs_ops =3D { }; =20 static struct kobj_type sde_ktype =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): + * hfi1_verbs_unregister_sysfs() calls kobject_put(&dd->per_sdma[i].kobj) + * and sdma_clean() frees dd->per_sdma via kfree() without waiting for + * final kobject cleanup. + */ + .release =3D NULL, .sysfs_ops =3D &sde_sysfs_ops, }; =20 diff --git a/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c b/drivers/infinib= and/hw/usnic/usnic_ib_sysfs.c index fdb63a8fb997..f6946524a562 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c +++ b/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c @@ -245,6 +245,13 @@ static struct attribute *usnic_ib_qpn_default_attrs[] = =3D { ATTRIBUTE_GROUPS(usnic_ib_qpn_default); =20 static struct kobj_type usnic_ib_qpn_type =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): + * usnic_ib_destroy_qp() calls kobject_put(&qp_grp->kobj) via + * usnic_ib_sysfs_qpn_remove() and RDMA core immediately frees qp_grp + * without waiting for final kobject cleanup. + */ + .release =3D NULL, .sysfs_ops =3D &usnic_ib_qpn_sysfs_ops, .default_groups =3D usnic_ib_qpn_default_groups, }; diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c index 6b567a74fc2c..1dc7d8ffdc73 100644 --- a/drivers/parisc/pdc_stable.c +++ b/drivers/parisc/pdc_stable.c @@ -484,6 +484,14 @@ ATTRIBUTE_GROUPS(paths_subsys); =20 /* Specific kobject type for our PDC paths */ static const struct kobj_type ktype_pdcspath =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): pdcspath_entry + * instances are static in tristate module pdc_stable, and + * pdc_stable_exit() calls kobject_put(&entry->kobj); unloading the + * module unmaps the static storage without waiting for final kobject + * cleanup. + */ + .release =3D NULL, .sysfs_ops =3D &pdcspath_attr_ops, .default_groups =3D paths_subsys_groups, }; diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500= _fg.c index eddd3e853106..f5a0bb821ee8 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -2539,6 +2539,14 @@ static struct attribute *ab8500_fg_attrs[] =3D { ATTRIBUTE_GROUPS(ab8500_fg); =20 static const struct kobj_type ab8500_fg_ktype =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): fg_kobject is + * embedded in devm-allocated struct ab8500_fg; ab8500_fg_sysfs_exit() + * only calls kobject_del() (never kobject_put()) before devm frees the + * struct on unbind, and on ab8500_fg_sysfs_init() failure kobject_put() + * races with devm freeing the struct on probe failure. + */ + .release =3D NULL, .sysfs_ops =3D &ab8500_fg_sysfs_ops, .default_groups =3D ab8500_fg_groups, }; diff --git a/drivers/s390/char/sclp_mem.c b/drivers/s390/char/sclp_mem.c index 6df1926d4c62..a46d27817281 100644 --- a/drivers/s390/char/sclp_mem.c +++ b/drivers/s390/char/sclp_mem.c @@ -305,6 +305,12 @@ static ssize_t sclp_memmap_on_memory_store(struct kobj= ect *kobj, struct kobj_att } =20 static const struct kobj_type ktype =3D { + /* + * Omitting release() violates the kobject API contract, but lifetime + * is safe: built-in sclp_init_mem() allocates sclp_mems once at boot + * and never calls kobject_put() or kfree() on it. + */ + .release =3D NULL, .sysfs_ops =3D &kobj_sysfs_ops, }; =20 diff --git a/drivers/soc/hisilicon/kunpeng_hccs.c b/drivers/soc/hisilicon/k= unpeng_hccs.c index 3b9fa3a74abd..bccd0ba95073 100644 --- a/drivers/soc/hisilicon/kunpeng_hccs.c +++ b/drivers/soc/hisilicon/kunpeng_hccs.c @@ -1038,6 +1038,12 @@ static struct attribute *hccs_port_default_attrs[] = =3D { ATTRIBUTE_GROUPS(hccs_port_default); =20 static const struct kobj_type hccs_port_type =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): hccs_port_info + * is allocated via devm_kzalloc(), and devm frees it on unbind or probe + * failure without waiting for kobject_put(&port->kobj) final cleanup. + */ + .release =3D NULL, .sysfs_ops =3D &hccs_comm_ops, .default_groups =3D hccs_port_default_groups, }; @@ -1110,6 +1116,12 @@ static struct attribute *hccs_die_default_attrs[] = =3D { ATTRIBUTE_GROUPS(hccs_die_default); =20 static const struct kobj_type hccs_die_type =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): hccs_die_info + * is allocated via devm_kzalloc(), and devm frees it on unbind or probe + * failure without waiting for kobject_put(&die->kobj) final cleanup. + */ + .release =3D NULL, .sysfs_ops =3D &hccs_comm_ops, .default_groups =3D hccs_die_default_groups, }; @@ -1213,6 +1225,12 @@ static struct attribute *hccs_chip_default_attrs[] = =3D { ATTRIBUTE_GROUPS(hccs_chip_default); =20 static const struct kobj_type hccs_chip_type =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): hccs_chip_info + * is allocated via devm_kzalloc(), and devm frees it on unbind or probe + * failure without waiting for kobject_put(&chip->kobj) final cleanup. + */ + .release =3D NULL, .sysfs_ops =3D &hccs_comm_ops, .default_groups =3D hccs_chip_default_groups, }; diff --git a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c b/drivers= /video/fbdev/omap2/omapfb/dss/display-sysfs.c index ae937854403b..436ec9c8591b 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c @@ -304,6 +304,13 @@ static const struct sysfs_ops display_sysfs_ops =3D { }; =20 static struct kobj_type display_ktype =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): + * display_uninit_sysfs() calls kobject_put(&dssdev->kobj) and + * immediately zeroes dssdev->kobj with memset(), corrupting any + * in-flight or delayed (CONFIG_DEBUG_KOBJECT_RELEASE) kobject cleanup. + */ + .release =3D NULL, .sysfs_ops =3D &display_sysfs_ops, .default_groups =3D display_sysfs_groups, }; diff --git a/drivers/video/fbdev/omap2/omapfb/dss/manager-sysfs.c b/drivers= /video/fbdev/omap2/omapfb/dss/manager-sysfs.c index 1b644be5fe2e..e4d61cf7e939 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/manager-sysfs.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/manager-sysfs.c @@ -496,6 +496,14 @@ static const struct sysfs_ops manager_sysfs_ops =3D { }; =20 static struct kobj_type manager_ktype =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): mgr->kobj is + * embedded in dynamically allocated managers[], zeroed in + * dss_manager_kobj_uninit() right after kobject_put(), and freed in + * dss_uninit_overlay_managers() without waiting for final kobject + * cleanup. + */ + .release =3D NULL, .sysfs_ops =3D &manager_sysfs_ops, .default_groups =3D manager_sysfs_groups, }; diff --git a/drivers/video/fbdev/omap2/omapfb/dss/overlay-sysfs.c b/drivers= /video/fbdev/omap2/omapfb/dss/overlay-sysfs.c index 1da4fb1c77b4..3960261cada0 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/overlay-sysfs.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/overlay-sysfs.c @@ -429,6 +429,13 @@ static const struct sysfs_ops overlay_sysfs_ops =3D { }; =20 static struct kobj_type overlay_ktype =3D { + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): ovl->kobj is + * embedded in dynamically allocated overlays[] and freed in + * dss_uninit_overlays() right after dss_overlay_kobj_uninit() calls + * kobject_put(), without waiting for final kobject cleanup. + */ + .release =3D NULL, .sysfs_ops =3D &overlay_sysfs_ops, .default_groups =3D overlay_sysfs_groups, }; diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c index dfcec9376cd5..3654a945b299 100644 --- a/fs/erofs/sysfs.c +++ b/fs/erofs/sysfs.c @@ -238,6 +238,13 @@ static const struct kobj_type erofs_sb_ktype =3D { static const struct kobj_type erofs_ktype =3D { .default_groups =3D erofs_groups, .sysfs_ops =3D &erofs_attr_ops, + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): erofs_root is + * a static struct kset in tristate module erofs, and erofs_exit_sysfs() + * calls kset_unregister(); unloading the module unmaps the static + * storage without waiting for final kobject cleanup. + */ + .release =3D NULL, }; =20 static struct kset erofs_root =3D { @@ -247,6 +254,13 @@ static struct kset erofs_root =3D { static const struct kobj_type erofs_feat_ktype =3D { .default_groups =3D erofs_feat_groups, .sysfs_ops =3D &erofs_attr_ops, + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): erofs_feat is + * a static struct kobject in tristate module erofs, and + * erofs_exit_sysfs() calls kobject_put(); unloading the module unmaps + * the static storage without waiting for final kobject cleanup. + */ + .release =3D NULL, }; =20 static struct kobject erofs_feat =3D { diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 430356e500af..770ceb12e178 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -1683,6 +1683,13 @@ static const struct kobj_type f2fs_sb_ktype =3D { =20 static const struct kobj_type f2fs_ktype =3D { .sysfs_ops =3D &f2fs_attr_ops, + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): f2fs_kset is + * a static struct kset in tristate module f2fs, and f2fs_exit_sysfs() + * calls kset_unregister(); unloading the module unmaps the static + * storage without waiting for final kobject cleanup. + */ + .release =3D NULL, }; =20 static struct kset f2fs_kset =3D { @@ -1697,6 +1704,13 @@ static const struct sysfs_ops f2fs_feat_attr_ops =3D= { static const struct kobj_type f2fs_feat_ktype =3D { .default_groups =3D f2fs_feat_groups, .sysfs_ops =3D &f2fs_feat_attr_ops, + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): f2fs_feat is + * a static struct kobject in tristate module f2fs, and + * f2fs_exit_sysfs() calls kobject_put(); unloading the module unmaps + * the static storage without waiting for final kobject cleanup. + */ + .release =3D NULL, }; =20 static struct kobject f2fs_feat =3D { @@ -1711,6 +1725,13 @@ static const struct sysfs_ops f2fs_tune_attr_ops =3D= { static const struct kobj_type f2fs_tune_ktype =3D { .default_groups =3D f2fs_tune_groups, .sysfs_ops =3D &f2fs_tune_attr_ops, + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): f2fs_tune is + * a static struct kobject in tristate module f2fs, and + * f2fs_exit_sysfs() calls kobject_put(); unloading the module unmaps + * the static storage without waiting for final kobject cleanup. + */ + .release =3D NULL, }; =20 static struct kobject f2fs_tune =3D { diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c index 563881ddbf00..5a30f73d8d67 100644 --- a/fs/ocfs2/cluster/masklog.c +++ b/fs/ocfs2/cluster/masklog.c @@ -147,6 +147,13 @@ static const struct sysfs_ops mlog_attr_ops =3D { static struct kobj_type mlog_ktype =3D { .default_groups =3D mlog_default_groups, .sysfs_ops =3D &mlog_attr_ops, + /* + * FIXME: Broken kobject lifetime (needs follow-up fix): mlog_kset is + * a static struct kset in tristate module ocfs2_nodemanager, and + * mlog_sys_shutdown() calls kset_unregister(); unloading the module + * unmaps the static storage without waiting for final kobject cleanup. + */ + .release =3D NULL, }; =20 static struct kset mlog_kset =3D { diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 55e37a5d405e..8a1332030884 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -114,7 +114,7 @@ void kobject_get_ownership(const struct kobject *kobj, = kuid_t *uid, kgid_t *gid) char *kobject_get_path(const struct kobject *kobj, gfp_t flag); =20 struct kobj_type { - void (*release)(struct kobject *kobj); + void (*release)(struct kobject *kobj) __must_init; const struct sysfs_ops *sysfs_ops; const struct attribute_group **default_groups; const struct kobj_ns_type_operations *(*child_ns_type)(const struct kobje= ct *kobj); --=20 2.56.1.708.g77570a6a1d-goog