From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0015568FA3 for ; Tue, 13 Oct 2026 22:40:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791931246; cv=none; b=K/rZsIvmG3AlHhg7hYC1IbR8pYcn0I9ECxDAiYuN6X1J/fM7PIPJB9beQcuaLp/HPibHEqV1FKkdmUOPs469xhBrNcMnM26cJ2Z10XkdlqmDFqXYbym/vu9vp8emtzoHJGcHmzTEuVONUve6BwWvfG4u2Hq2BgNS60mAHeyVeMo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791931246; c=relaxed/simple; bh=M3UPDkw20opO7U5j3HMFplWu3giCXTRo4JKyj8Xm00I=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Mrlb+MZHbPMf+mNuoJyUYLO8n1xTRJ52OqOhOKLgcX5MRHpw8YA4aAzOjazym8wg+Uo9BruGTrjtQSYsI+fJ4wAh/8/mel2PVGUXMYd9OraC+jzWLSzVwtA5Oox4zljSjLY8whjcx+wBA6tE9c3kjIZcDs3aHx9gZKi3OF9ROLc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=OfVm6YsG; arc=none smtp.client-ip=74.125.82.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="OfVm6YsG" Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-33713e5e6daso5245760eec.0 for ; Tue, 13 Oct 2026 15:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1791931236; x=1792536036; 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=gurzTkqqRagMZrBgJFBCVz7i93uSa3r8+lp0iuHqO9A=; b=OfVm6YsGpzxw31wkx3jEzigdWJ2dY+oGPG0qR/tyvngfOYUF9OIG/6QvZBbLDAW3YZ nWCi4CQzbXxFUXI54UgZL2weZ/i/95k3eAvIvrq9jg29Y7oSb4aI7UbuBzZjUgh8NutT i9HrtyHOtonclaOv2pEMQPkLEzW5qZK656u/i/aSUE2JsTLKcSqPKkHGV9cMqULWWU0Y EpBKtFNMENw9c6xs7xY8nRDBTq/wpRYlWanZyyola/wFeaUot7J3ovL658Oyf7Iv9Ngt HkAhb5avGnuxj0vVMv5d7V9935fBQMLi0XjxkzDNEWV7eBGr7Rt3pUoIi1fd5QFQEHjy GqjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791931236; x=1792536036; 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=gurzTkqqRagMZrBgJFBCVz7i93uSa3r8+lp0iuHqO9A=; b=OmtKHzafix2tzQN2nJ9Va+BWJM6c+b9M/ObsUckHCpH/YD0XBKHDLacUXmj4PWNUb4 Ob5xY9sfMHS1/4c9MofSZ6eRoqyHh4ZznDiUjWLd6SZiIa4tLIpS66iK4299etKdeEdw vbweg2NLdqzz1Gx7v2C0LPUBQ01IFY/2p54sTnuqX5JNueZ+eEwILs++ASt0uoHOKuNX tXLsbxnM+eZkjc4JQ9rwTqYAzfYAOvBcbjBwIk4MjmWSsBS6lmbvKButxdkw9GGvHmM8 xU0BDmpLZNZU4dCDHBCz1JEa2xnsEmhxm6DVwzQAeRrVQlSsCWxyPTYeDfcTPAiiIIUH of8A== X-Forwarded-Encrypted: i=1; AKwUvBz6w4pSubrw0afSBcpeL6b+QwbiYJGgqY/K4UK1q+v1oTwwN1cQ3rwJ39rP7VSKmSCZxHjAB3cot64=@vger.kernel.org X-Gm-Message-State: AFq9FYLdLcJRgPyRmWNT34tKZe6AQ7+2j4WkgXknxFEQnth/PJVI2lDQ FhebDpvNK7vQ4m46HbqF3I+cDctvYT6e/vt+v9sQktDCyCNOjcrEPmSfKQbNRI+vUdQjCPGeMIx rW8korlQRAQ== X-Received: from dleg6-n1.prod.google.com ([2002:a05:701b:4306:10b0:160:bb23:390d]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:4586:20b0:169:b1b1:1445 with SMTP id a92af1059eb24-16a5dbfe73dmr17947821c88.31.1791931232672; Tue, 13 Oct 2026 15:40:32 -0700 (PDT) Date: Tue, 13 Oct 2026 15:39:44 -0700 In-Reply-To: <20261013223946.1836757-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20261013223946.1836757-1-irogers@google.com> X-Mailer: git-send-email 2.56.0.385.gd3acb90ef8-goog Message-ID: <20261013223946.1836757-10-irogers@google.com> Subject: [PATCH 09/11] ubifs: sysfs: Use kset_create_and_add() for ubifs_kset From: Ian Rogers To: Greg Kroah-Hartman , "Rafael J . Wysocki" , Danilo Krummrich , Miguel Ojeda , Kees Cook , Nathan Chancellor Cc: Nick Desaulniers , Bill Wendling , Justin Stitt , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Nayna Jain , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Viresh Kumar , David Teigland , Alexander Aring , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Richard Weinberger , Zhihao Cheng , Felix Kuehling , Alex Deucher , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , driver-core@lists.linux.dev, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, gfs2@lists.linux.dev, xen-devel@lists.xenproject.org, linux-s390@vger.kernel.org, linux-mtd@lists.infradead.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ian Rogers Content-Type: text/plain; charset="UTF-8" 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=y, 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: 203a55f04f66 ("ubifs: Fix memory leak in ubifs_sysfs_init()") Assisted-by: Antigravity:gemini-3.1-pro 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 = { .release = ubifs_sb_release, }; -static const struct kobj_type ubifs_ktype = { - .sysfs_ops = &ubifs_attr_ops, -}; - -static struct kset ubifs_kset = { - .kobj = {.ktype = &ubifs_ktype}, -}; +static struct kset *ubifs_kset; int ubifs_sysfs_register(struct ubifs_info *c) { @@ -107,7 +101,7 @@ int ubifs_sysfs_register(struct ubifs_info *c) goto out_free; } - c->kobj.kset = &ubifs_kset; + c->kobj.kset = ubifs_kset; init_completion(&c->kobj_unregister); ret = kobject_init_and_add(&c->kobj, &ubifs_sb_ktype, NULL, @@ -139,18 +133,14 @@ void ubifs_sysfs_unregister(struct ubifs_info *c) int __init ubifs_sysfs_init(void) { - int ret; + ubifs_kset = kset_create_and_add("ubifs", NULL, fs_kobj); + if (!ubifs_kset) + return -ENOMEM; - kobject_set_name(&ubifs_kset.kobj, "ubifs"); - ubifs_kset.kobj.parent = fs_kobj; - ret = kset_register(&ubifs_kset); - if (ret) - kset_put(&ubifs_kset); - - return ret; + return 0; } void ubifs_sysfs_exit(void) { - kset_unregister(&ubifs_kset); + kset_unregister(ubifs_kset); } -- 2.56.0.385.gd3acb90ef8-goog