🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
11 messages
11 total messages Started by Heiner Kallweit Sun, 08 Nov 2026 13:44
[PATCH net-next 0/2] sysfs: facilitate creating an empty directory
#12753
Author: Heiner Kallweit
Date: Sun, 08 Nov 2026 13:44
18 lines
11319 bytes
We have use cases where an empty sysfs directory is created.
This requires an attribute list consisting of only the sentinal entry.
It takes only to modify one check to enable creating an empty directory
with a NULL attribute list. Use the new feature in net sysfs.

Proposal: Apply through netdev tree, w/ ACK from sysfs core.

Heiner Kallweit (2):
  sysfs: facilitate creating an empty directory
  net sysfs: simplify creating empty wireless directory

 fs/sysfs/group.c     | 7 ++++---
 net/core/net-sysfs.c | 5 -----
 2 files changed, 4 insertions(+), 8 deletions(-)

-- 
2.56.0
[PATCH net-next 1/2] sysfs: facilitate creating an empty directory
#12752
Author: Heiner Kallweit
Date: Sun, 08 Nov 2026 13:45
31 lines
12035 bytes
We have use cases where an empty sysfs directory is created.
This requires an attribute list consisting of only the sentinal entry.
It takes only to modify one check to enable creating an empty directory
with a NULL attribute list.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 fs/sysfs/group.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 4e1e4f18a16..031cb6f36b5 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) {
+		pr_debug("sysfs: (bin_)attrs not set by subsystem for group: %s, skipping\n",
+			 kobj->name);
 		return 0;
 	}
 
-- 
2.56.0
[PATCH net-next 2/2] net sysfs: simplify creating empty wireless directory
#12754
Author: Heiner Kallweit
Date: Sun, 08 Nov 2026 13:46
29 lines
11742 bytes
Now that an empty directory can be created with attrs being NULL,
make use of this new functionality and remove the dummy attribute list.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 net/core/net-sysfs.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 5c0402389c6..f58b59e1126 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -910,13 +910,8 @@ static const struct attribute_group netstat_group = {
 	.attrs  = netstat_attrs,
 };
 
-static struct attribute *wireless_attrs[] = {
-	NULL
-};
-
 static const struct attribute_group wireless_group = {
 	.name = "wireless",
-	.attrs = wireless_attrs,
 };
 
 static bool wireless_group_needed(struct net_device *ndev)
-- 
2.56.0
Re: [PATCH net-next 1/2] sysfs: facilitate creating an empty directory
#12755
Author: Greg Kroah-Hartman
Date: Sun, 08 Nov 2026 14:06
36 lines
9109 bytes
On Sun, Nov 08, 2026 at 02:45:05PM +0100, Heiner Kallweit wrote:
> We have use cases where an empty sysfs directory is created.
> This requires an attribute list consisting of only the sentinal entry.
> It takes only to modify one check to enable creating an empty directory
> with a NULL attribute list.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  fs/sysfs/group.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
> index 4e1e4f18a16..031cb6f36b5 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) {
> +		pr_debug("sysfs: (bin_)attrs not set by subsystem for group: %s, skipping\n",
> +			 kobj->name);

Where is this now documented?

And why would you ever want to make a directory with nothing in it?
That is not how sysfs should be working.

thanks,

greg k-h
Re: [PATCH net-next 2/2] net sysfs: simplify creating empty wireless directory
#12756
Author: Greg Kroah-Hartman
Date: Sun, 08 Nov 2026 14:06
32 lines
8721 bytes
On Sun, Nov 08, 2026 at 02:46:03PM +0100, Heiner Kallweit wrote:
> Now that an empty directory can be created with attrs being NULL,
> make use of this new functionality and remove the dummy attribute list.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  net/core/net-sysfs.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 5c0402389c6..f58b59e1126 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -910,13 +910,8 @@ static const struct attribute_group netstat_group = {
>  	.attrs  = netstat_attrs,
>  };
>  
> -static struct attribute *wireless_attrs[] = {
> -	NULL
> -};
> -
>  static const struct attribute_group wireless_group = {
>  	.name = "wireless",
> -	.attrs = wireless_attrs,

Why does this want to create an empty directory?  Surely you aren't
adding attributes later to it, right?  If so, that's not ok either...

thanks,

greg k-h
Re: [PATCH net-next 2/2] net sysfs: simplify creating empty wireless directory
#12757
Author: Heiner Kallweit
Date: Sun, 08 Nov 2026 14:12
36 lines
12712 bytes
On 08.11.2026 15:06, Greg Kroah-Hartman wrote:
> On Sun, Nov 08, 2026 at 02:46:03PM +0100, Heiner Kallweit wrote:
>> Now that an empty directory can be created with attrs being NULL,
>> make use of this new functionality and remove the dummy attribute list.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>>  net/core/net-sysfs.c | 5 -----
>>  1 file changed, 5 deletions(-)
>>
>> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
>> index 5c0402389c6..f58b59e1126 100644
>> --- a/net/core/net-sysfs.c
>> +++ b/net/core/net-sysfs.c
>> @@ -910,13 +910,8 @@ static const struct attribute_group netstat_group = {
>>  	.attrs  = netstat_attrs,
>>  };
>>  
>> -static struct attribute *wireless_attrs[] = {
>> -	NULL
>> -};
>> -
>>  static const struct attribute_group wireless_group = {
>>  	.name = "wireless",
>> -	.attrs = wireless_attrs,
> 
> Why does this want to create an empty directory?  Surely you aren't
> adding attributes later to it, right?  If so, that's not ok either...
> 

For compatibility reasons. See 38c1a01cf10c ("wireless: add back sysfs directory")

> thanks,
> 
> greg k-h
Re: [PATCH net-next 2/2] net sysfs: simplify creating empty wireless directory
#12761
Author: Greg Kroah-Hartman
Date: Sun, 08 Nov 2026 14:21
42 lines
9434 bytes
On Sun, Nov 08, 2026 at 03:12:04PM +0100, Heiner Kallweit wrote:
> On 08.11.2026 15:06, Greg Kroah-Hartman wrote:
> > On Sun, Nov 08, 2026 at 02:46:03PM +0100, Heiner Kallweit wrote:
> >> Now that an empty directory can be created with attrs being NULL,
> >> make use of this new functionality and remove the dummy attribute list.
> >>
> >> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> >> ---
> >>  net/core/net-sysfs.c | 5 -----
> >>  1 file changed, 5 deletions(-)
> >>
> >> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> >> index 5c0402389c6..f58b59e1126 100644
> >> --- a/net/core/net-sysfs.c
> >> +++ b/net/core/net-sysfs.c
> >> @@ -910,13 +910,8 @@ static const struct attribute_group netstat_group = {
> >>  	.attrs  = netstat_attrs,
> >>  };
> >>  
> >> -static struct attribute *wireless_attrs[] = {
> >> -	NULL
> >> -};
> >> -
> >>  static const struct attribute_group wireless_group = {
> >>  	.name = "wireless",
> >> -	.attrs = wireless_attrs,
> > 
> > Why does this want to create an empty directory?  Surely you aren't
> > adding attributes later to it, right?  If so, that's not ok either...
> > 
> 
> For compatibility reasons. See 38c1a01cf10c ("wireless: add back sysfs directory")

How long do we have to keep that?  That was a very long time ago, 2012,
why not just remove it entirely now?  And if the sysfs core hasn't
needed this since then, why give other people the opportunity to abuse
it this way as well?  That doesn't feel like a good idea to me.

thanks,

greg k-h
Re: [PATCH net-next 2/2] net sysfs: simplify creating empty wireless directory
#12795
Author: Heiner Kallweit
Date: Sun, 08 Nov 2026 16:02
48 lines
13546 bytes
On 08.11.2026 15:21, Greg Kroah-Hartman wrote:
> On Sun, Nov 08, 2026 at 03:12:04PM +0100, Heiner Kallweit wrote:
>> On 08.11.2026 15:06, Greg Kroah-Hartman wrote:
>>> On Sun, Nov 08, 2026 at 02:46:03PM +0100, Heiner Kallweit wrote:
>>>> Now that an empty directory can be created with attrs being NULL,
>>>> make use of this new functionality and remove the dummy attribute list.
>>>>
>>>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>>>> ---
>>>>  net/core/net-sysfs.c | 5 -----
>>>>  1 file changed, 5 deletions(-)
>>>>
>>>> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
>>>> index 5c0402389c6..f58b59e1126 100644
>>>> --- a/net/core/net-sysfs.c
>>>> +++ b/net/core/net-sysfs.c
>>>> @@ -910,13 +910,8 @@ static const struct attribute_group netstat_group = {
>>>>  	.attrs  = netstat_attrs,
>>>>  };
>>>>  
>>>> -static struct attribute *wireless_attrs[] = {
>>>> -	NULL
>>>> -};
>>>> -
>>>>  static const struct attribute_group wireless_group = {
>>>>  	.name = "wireless",
>>>> -	.attrs = wireless_attrs,
>>>
>>> Why does this want to create an empty directory?  Surely you aren't
>>> adding attributes later to it, right?  If so, that's not ok either...
>>>
>>
>> For compatibility reasons. See 38c1a01cf10c ("wireless: add back sysfs directory")
> 
> How long do we have to keep that?  That was a very long time ago, 2012,
> why not just remove it entirely now?  And if the sysfs core hasn't
> needed this since then, why give other people the opportunity to abuse
> it this way as well?  That doesn't feel like a good idea to me.
> 

Seems Fedora learnt at the same time (end of 2012) to live w/o the compat wireless directory.
https://github.com/fedora-sysv/initscripts/commit/4e96fcecee7ab70295a5f2c52748cd57cbab60bb
So it should be time now to remove it. I'll submit a patch for it.

> thanks,
> 
> greg k-h
Re: [PATCH net-next 0/2] sysfs: facilitate creating an empty directory
#12796
Author: Heiner Kallweit
Date: Sun, 08 Nov 2026 16:12
21 lines
11707 bytes
On 08.11.2026 14:44, Heiner Kallweit wrote:
> We have use cases where an empty sysfs directory is created.
> This requires an attribute list consisting of only the sentinal entry.
> It takes only to modify one check to enable creating an empty directory
> with a NULL attribute list. Use the new feature in net sysfs.
> 
> Proposal: Apply through netdev tree, w/ ACK from sysfs core.
> 
> Heiner Kallweit (2):
>   sysfs: facilitate creating an empty directory
>   net sysfs: simplify creating empty wireless directory
> 
>  fs/sysfs/group.c     | 7 ++++---
>  net/core/net-sysfs.c | 5 -----
>  2 files changed, 4 insertions(+), 8 deletions(-)
> 

Will be replaced with patch to remove the deprecated wireless directory.
--
pw-bot: cr
Re: [PATCH net-next 1/2] sysfs: facilitate creating an empty directory
#13224
Author: 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
Re: [PATCH net-next 2/2] net sysfs: simplify creating empty wireless directory
#13230
Author: netdev-bot+sashiko
Date: Mon, 09 Nov 2026 13:48
72 lines
10547 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The kernel-doc for struct attribute_group in
  include/linux/sysfs.h (line 103) still says "@bin_attrs: ... Either…

--

net sysfs: simplify creating empty wireless directory

The patch removes the dummy wireless_attrs[] list from wireless_group in
net/core/net-sysfs.c. It relies on the earlier sysfs change that lets a
named attribute group with NULL attrs create an empty directory.

> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 5c0402389c6d1..f58b59e112620 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -910,13 +910,8 @@ static const struct attribute_group netstat_group = {
>  	.attrs  = netstat_attrs,
>  };
>  
> -static struct attribute *wireless_attrs[] = {
> -	NULL
> -};
> -
>  static const struct attribute_group wireless_group = {
>  	.name = "wireless",
> -	.attrs = wireless_attrs,
>  };

[Severity: Low]
This isn't a bug, but should the kernel-doc for struct attribute_group be
updated along with this change?

After this patch, wireless_group has both .attrs and .bin_attrs set to NULL.
The comment above 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.

The new behaviour is only described by an inline comment in
internal_create_group() in fs/sysfs/group.c:

	/* If name is set w/o attributes, create an empty directory */
	if (!grp->name && !grp->attrs && !grp->bin_attrs) {

The paths wireless_group actually goes through (create_files(),
remove_files(), sysfs_group_attrs_change_owner()) all check for NULL attrs
and bin_attrs, so nothing goes wrong at runtime here. Other helpers do not
tolerate NULL attrs, though. For example, sysfs_merge_group() dereferences
grp->attrs without a NULL check:

	for ((i = 0, attr = grp->attrs); *attr && !error; (++i, ++attr))

The same applies to sysfs_unmerge_group().

Could the @attrs/@bin_attrs kernel-doc be changed to say that a named group
may leave both NULL to get an empty directory? Could it also say which
helpers still require attrs to be set? Neither this patch nor the earlier
"sysfs: facilitate creating an empty directory" patch updates the
documentation, and this patch is the first in-tree user of the new
behaviour.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/0a0a7987-abb2-49c8-bc16-3938233ae9c5%40gmail.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads