🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13224

Re: [PATCH net-next 1/2] sysfs: facilitate creating an empty directory

#13224
From: netdev-bot+sashiko
Date: Mon, 09 Nov 2026 13:48
122 lines
12879 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] This patch silently reverses the semantics that commit
  a91845b9a872 ("sysfs: Skip empty folders creation") set up on purpose…
- [Low] The kernel-doc for struct attribute_group in
  include/linux/sysfs.h (lines 101-103) still says "@bin_attrs: ...…
- [Low] The comment and debug message on the rewritten check in
  internal_create_group() (fs/sysfs/group.c:144-147) are misleading.

--

sysfs: facilitate creating an empty directory

This patch changes the early return in internal_create_group() so that it
only skips groups with no name and no attrs or bin_attrs. A named group with
both arrays NULL now gets an empty sysfs directory. Callers no longer need an
attribute list that holds only the sentinel entry.

> diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
> index 4e1e4f18a1669..031cb6f36b5b0 100644
> --- a/fs/sysfs/group.c
> +++ b/fs/sysfs/group.c
> @@ -141,9 +141,10 @@ static int internal_create_group(struct kobject *kobj, int update,
>  	if (unlikely(update && !kobj->sd))
>  		return -EINVAL;
>  
> -	if (!grp->attrs && !grp->bin_attrs) {
> -		pr_debug("sysfs: (bin_)attrs not set by subsystem for group: %s/%s, skipping\n",
> -			 kobj->name, grp->name ?: "");
> +	/* If name is set w/o attributes, create an empty directory */
> +	if (!grp->name && !grp->attrs && !grp->bin_attrs) {

[Severity: Medium]
This reverses behaviour that commit a91845b9a872 ("sysfs: Skip empty
folders creation") added on purpose. Was that intended?

That commit's message covers a group "with a name and without .[bin_]attrs
members". It says sysfs should "just skip the attribute group creation". It
also calls an empty sysfs folder "disturbing".

After this change, a named group with attrs and bin_attrs both NULL always
gets a directory. That applies to sysfs_create_group(), sysfs_create_groups()
and device_add_group(). It also applies to sysfs_update_group() when the
directory doesn't exist yet.

__first_visible() returns 0 when both arrays are NULL. So mode becomes
S_IRWXU | S_IRUGO | S_IXUGO and the code reaches:

    kn = kernfs_create_dir_ns(kobj->sd, grp->name, mode,
                              uid, gid, kobj, NULL);
    if (IS_ERR(kn)) {
        if (PTR_ERR(kn) == -EEXIST)
            sysfs_warn_dup(kobj->sd, grp->name);
        return PTR_ERR(kn);
    }

A name clash used to return 0 quietly. It now returns -EEXIST and calls
sysfs_warn_dup(), and internal_create_groups() then rolls back the whole
group list.

Some named groups are declared with NULL attrs and filled in at run time.
One example is x86_pmu_format_group in arch/x86/events/core.c:

    static struct attribute_group x86_pmu_format_group __ro_after_init = {
        .name = "format",
        .attrs = NULL,
    };

I couldn't find an in-tree user that registers such a group with the arrays
still NULL. The x86 pmu, s390 PAI, amdgpu, i915, arm-cci and
nvmem_populate_sysfs_cells() users all fill the arrays or bail out first.
Even so, the commit message describes this only as changing one check.

Could the commit message reference a91845b9a872 and explain why skipping
empty named groups is no longer wanted? Could it also say whether existing
named groups with runtime-filled attrs were checked?

[Severity: Low]
A named group with both arrays NULL is now a supported construct. However,
the kernel-doc for struct attribute_group in include/linux/sysfs.h still
says:

 * @attrs:	Pointer to NULL terminated list of attributes.
 * @bin_attrs:	Pointer to NULL terminated list of binary attributes.
 *		Either attrs or bin_attrs or both must be provided.

Should this be updated too? It could say that a named group with neither
array creates an empty directory, and only an unnamed one is skipped.

The follow-up change for wireless_group in net/core/net-sysfs.c depends on
this, and it doesn't touch the header either.

> +		pr_debug("sysfs: (bin_)attrs not set by subsystem for group: %s, skipping\n",
> +			 kobj->name);

[Severity: Low]
This isn't a bug, but the new comment describes what happens when the
condition is false. The block below it actually skips an unnamed group that
has no attributes.

The pr_debug() also prints kobj->name after "for group:". grp->name is
always NULL in this branch, so the printed value is the kobject name, not a
group name. The old "%s/%s" format kept the two separate.

There is also a typo in the commit message: "sentinal" should be "sentinel".

>  		return 0;
>  	}
>

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/0a0a7987-abb2-49c8-bc16-3938233ae9c5%40gmail.com
Technical Details
Message-ID: <179423212274.994134.387871053470036049@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359340-linux-kernel-netdev=dewy.ru
References: <340683d8-83f5-415b-b54c-b2916817f860@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359340-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 1/2] sysfs: facilitate creating an empty directory
Date: Mon, 09 Nov 2026 13:48:42 +0000
Organization: Usenet Network
Message-ID: <179423212274.994134.387871053470036049@kernel.org>
References: <340683d8-83f5-415b-b54c-b2916817f860@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="371051"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:5cToxqEQTQ2nO4zVwXemRgo5LLc= sha256:nXAM3UqoQXeRdFmQrCF4nT+Kdw7tr4b5h3pBnOstzkw=
	sha1:amtyHfLYgxjcm5Bc6vpcm/shJIM= sha256:DRG2WE/HzAI2f2YAIx/9Gs/trW7T7LUZPrDm+Ryw1dg=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id B980E113810; Mon,  9 Nov 2026 16:56:12 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 4UdZ9kMCWuWw;
	Mon,  9 Nov 2026 16:56:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-359340-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 0444511380F; Mon,  9 Nov 2026 16:55:58 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id AE77D87CE9; Mon,  9 Nov 2026 13:49:01 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794232125;
	b=taNWL9GPBbNDhRgadZW+/eHN+8mXf94t2zV1h/aaylYVVmVfcxaE0TN+IdsodKrPzHaO
	 C/3GJFoq7M99+C5EtZ9PR8Z+9dRRxPJneKm7oekuHgQG0NWRhpSgqo4Q8bdmT0U4BA8Bf
	 w/LtWtvI5SdUIawatxPR82SAyiJG6Z7Tp/Jx4OJyKKMNgiugk+LumRvIeXZzOy+o3NYN4
	 OQCoJyYvVD+WoBdpxEVMI3Uwv1NAZrUQS0/YS8sQcAMQ+5bzr+7QkyEe504i4b6pLpGw8
	 iDtygSAXgzEdfcvbngp7Pil0EzggPKnRMFMes7yrKiaBTftwWI93wKEx9JqEBsOyaag==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794232125;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=nYjIdwe6nVNUiJwfrKE7/ebvVRpi8vNOI6DfZKYgfPE=;
	b=npHYef/Eg6zIfCrgS41CqyYVO3wpDwWOdfhpXrtLY5BOJTfr9Qkcfod5B6h3joR18ibb
	 xyTGnUHw6Fo3/PnrKa4RhkimRXsZL8SWTgJNYRprbvl/dReBZycSeJRE/+Fd7XOoeYsEO
	 +b9ETcXzv1Fo6/hL8UnhfSZ6k3Khvk1auGZNg4D469r4QAoOc7p2RCQFw2w4L6YVTxvDp
	 JLzmW7DsFpYkyA/nhh2KmA8r58Kftkz4igLR0htCx55mwM6M3A+PTZfElv3F+r+ltPdLc
	 hnmzb80MQkOXpBHdb1A5ZHoX2OyAqrVlSH20n15X7zwH6Y0IRrEO4wdCC7uXaECPyAg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=U+RRBDq1;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id B8D47606A33C;
	Mon,  9 Nov 2026 13:48:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=U+RRBDq1
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794232124;
	b=g7Ahi3ocjPw5TAX/PCJVa7+hgJxDhsPELLs1DszmBp6hrHt5+16NibDGQfZnakg4Gk8K
	 PYWSxGJ7ZQ1FkVPmrrM5jEcc5DrpULIg0adepYVm31ndyv7NQGXFAls2JWlrmtY2n6OKN
	 efyuCeG0PKR2xap0WCL5T0B8AJheb5VcHjp6R/pbzaeZLDwbBdYK+2U9G5hCKCRtKLsdp
	 vRdCD/qfAiqGl01F7AAicLhUQbEaLFUfSCIwB05oXb9711/4Er/DK1bnNIdcGlil09QNV
	 RcjbrTUsjZPZ1DgQYnI7wYx6XVinea9uYbhS+3fcTOPTPn3xuBAY8v1LP7dFvEezbWg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794232124;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=nYjIdwe6nVNUiJwfrKE7/ebvVRpi8vNOI6DfZKYgfPE=;
	b=pXGk/ReZIyGsZzzFXdCYENHPW/arzQx+4+qxerScMMV0yjTNZHpu6So5q4/2+WhBT8Qo
	 rNu7xD0P/BpyRmGByUtqFaOOlqThtOGy/EAoMbSTWDWIoXUYUEgPO8Q09ncXkI15B6o3s
	 oY7XW4A/ZA1aL/Tb2Nbs3CVSYWv81usSrhABvrGk6GOos7+2z9oUQETY/r2/5KYE0D63s
	 selwwZNbHPnTcmpSPNSeqUz3HjRPTV0vMPCKeBBH1NJVMi53T5/ciCaf1GT1ZnhQ6e2Pl
	 GFCK4qA1fjyPUzOU5aXcZageE7467bqiqKAmMxbT5Sy/s/TcVdEZjZBjX9w98HefjAA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=U+RRBDq1;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9732F606A331;
	Mon,  9 Nov 2026 13:48:44 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 424651F0089F;
	Mon,  9 Nov 2026 13:48:43 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794232124;
	bh=nYjIdwe6nVNUiJwfrKE7/ebvVRpi8vNOI6DfZKYgfPE=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=U+RRBDq1BB7ys6OzHXrJyADjRINtHDgyfy1yrDb/B8T68gpn8MYKosyWrlZS531VX
	 02AjzpZ53fL9iO7lH9QkXNTfgl3fV9qqSVm5jHKoryO88788nQ360jXl8hxgh36had
	 H4v7RsQdzVWlykG0i51gK1vfiiI1VtYqd3of/dXFGwFOKXhoUMTGSnhjhr1S2FQkVE
	 Br1hYDWuGel7Wu/3sYqgKOi8X9IkhdmLH7vqFp/1NsOsOY/DnZ/5uQ1GCfXzAi3rmO
	 +lxnfVJqdudQ4nkvKZELpS113kqd4z6RFaPsdfkb/wPPHbkrE4oMJXEsbtRdJDONBm
	 ZH/+CP1yL8XdQ==
X-Cc: davem@davemloft.net, andrew+netdev@lunn.ch, edumazet@google.com,
 kuba@kernel.org, horms@kernel.org, gregkh@linuxfoundation.org,
 rafael@kernel.org, dakr@kernel.org, johan@kernel.org, pabeni@redhat.com,
 netdev@vger.kernel.org, driver-core@lists.linux.dev
X-In-Reply-To: <340683d8-83f5-415b-b54c-b2916817f860@gmail.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list