From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795116366; b=eoO42pgciXyiuuD5UtJ105HZfLhjgkeUp6jKgSWIGKHB7SsddnteMCs45iPuYu61yrZF 5/pXbBcaHCcLy1Mxh90gp4C03oMD6/AYL8mPye0WohS4WAl+3gRvvpX03eVIgmsB5BQ3O 1410nfea6kQd+KgPGw2Mqh8ucAI2JSED91+l5zm1TWexVQhzk72J8X46oN1df1qNf6Hmv o88Y5kKXjQf26fD4p6/AmADePRcRp7Sk9mmelG42guP7v5uO/EvMukxAHZWHOmaNe2fem 9+RaYJyncyI3xfynO96ilnADpOhMwlPoPD9oRoA7LsBS6M2Ve/GBB2u3NvGodskUhbQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795116366; 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=CSDEU43/2Gwf+VbjlCClZWJ4rTvHhhRb4YqVFYZr7ik=; b=RImV+BGc7otActng0hQNFZgNWsRakPvwYJ1yR+bXsi4nJSnRuq8HO3HjXR1PTftzvL7/ NXTkSIxF7+Zz4igHmk2WMciGFVuwqMtOY1Z8GAywpIPPIpKC9XnC8LQjxnFrwFIkU6+YZ NVVOEgHtbzzP1nmLu4iDrwK/dzt6dnAmWEOAYTv5bA5STwRxLnymDOhRzRTljjE9yqw8l 3306//48CcGjkXMr9JIli2J5/4eBJbTnXDxwDHsWQyZGTVote0x+elvwASW1V/DMMM6/W IrcaeekrMg5/65rOSMYLXpTBWjUSfLP7tbBzcG8t8dICrCXF8VsTgmipTLLhEMTciwQ== 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=YBs2MILh; arc=none smtp.remote-ip=209.85.216.69 Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (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 BB8E060A2612 for ; Thu, 19 Nov 2026 19:26:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BB8E060A2612 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=YBs2MILh Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-3ae6fda7a00so149201a91.2 for ; Thu, 19 Nov 2026 11:26:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795116365; x=1795721165; 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=CSDEU43/2Gwf+VbjlCClZWJ4rTvHhhRb4YqVFYZr7ik=; b=YBs2MILhY55v/SQ9iMjVlWdkJSBzZbgx5TLpNUcSvwgq3Gdne+kN7UT++5xPGbIvcu zpAsOJF+l1PQ7rw6NT5HgqNxfyjPyVlFhUdCjzG7QGGL+uAb4ICaAwb5stgzbIeEfbLE 7cI61IS+kgKB1/2eFv5klLhq0pEGNxrWC9dgayA/cO0BJW6Sofi6OpF8HHlceAfJRokM +37qb2fcqv4ope/hJrwW8KDGoPrN74g1yYsMWOjugLtfhwQtS2IUt3wh8CmE9xrZUTGj 0+bYgRis47zEVPDEs08p12qXfrQFKibsGqHzmxJsIPEhMqyH3chzIPPz+w8KbBuqoUrZ /HmA== 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=F54QYF0Nqk5il9Ye0HrGSG5yX1qkSWcdNG0iEnWb3Ikj2FhciYA3EgWoFfeIY5V+Fk +Zsh65kJ4RSxJdHXaxlaQ3hl7EGBbEhd/sViDr0lHTuzwcuDmVfgEf7QHhN86+whOcue AkBSmx/uH0nlTau1rvhoJ9Y6+uYTA9INwiEELFyP7BRwVQoyMOw7+I6bS7hFuUt+M3I9 Y0k6CPqiAiR8/iXvUhEHSEH8/yGP8Jn8zctofx7p88p8CfC8iecNc1k8f13LQzdXafV0 tZYdxarYiS7KOTRblhZqhFNlriFKneYSra98p9aJpnpdqYSvxrm/6pfpOSwAxROD6s7N 6FXw== X-Forwarded-Encrypted: i=1; AL+hErHh2lKdcnw3G4puv4wQTCNMN21NFf6SAxv7qf45LYE1Eu4OUS2w1ZD7ATPZhccmS/VtaZKW+vJKuJgZ@vger.kernel.org X-Gm-Message-State: APuU4Z8MnPYoPpvwkSr3I/5qfu8d0YntZ/6pbWjDbDsJKxI40jXfPKMy H99FBgeZ9FihK4k/WenVn1Mgn92SAHiyYEymYE/hxlMYLaqUcQqjap/LqQqM8reTACoWwTIbdrA cM3JlXJFyXw== 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> X-Mailing-List: linux-s390@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-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 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: 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 = { .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.1.708.g77570a6a1d-goog