From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Johan Hovold <johan@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Fernando Fernandez Mancera <fmancera@suse.de>
Cc: driver-core@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH 0/4] sysfs: support SYSFS_GROUP_INVISIBLE for unnamed groups and ownership updates
Date: Mon, 16 Nov 2026 01:42:52 -0800 [thread overview]
Message-ID: <20261116-sysfs-group-invisible-v1-0-94cd173a7d9a@gmail.com> (raw)
DEFINE_SYSFS_GROUP_VISIBLE() and DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE()
evaluate the group visibility callback only for the first attribute and
return SYSFS_GROUP_INVISIBLE when the entire group should be hidden.
While internal_create_group() checks for this return value before
creating or updating a named group's subdirectory, it skips that check
for unnamed attribute groups and proceeds directly to create_files(). As
a result, returning SYSFS_GROUP_INVISIBLE for an unnamed group only
skips the first attribute while still creating all remaining regular and
binary attributes, and leaves them behind on sysfs_update_group().
In addition, sysfs_group_change_owner() checks SYSFS_GROUP_INVISIBLE too
late inside sysfs_group_attrs_change_owner(), failing with -ENOENT when
looking up the nonexistent subdirectory of a hidden named group and
falling through to binary attributes when breaking out of the regular
attributes loop. Furthermore, SYSFS_GROUP_INVISIBLE is currently tested
and masked with bitwise operations even though it is a standalone
sentinel value rather than a permission bit.
Switch SYSFS_GROUP_INVISIBLE checks to equality comparisons, and check
group visibility upfront in both sysfs_group_change_owner() and
internal_create_group() for named and unnamed groups alike. Drop the
now-redundant SYSFS_GROUP_INVISIBLE checks from create_files() so that
returning it for attributes after the first one triggers the
invalid-permissions warning, and simplify error cleanup in
create_files().
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Dmitry Torokhov (4):
sysfs: check for SYSFS_GROUP_INVISIBLE using equality comparison
sysfs: check group visibility upfront in sysfs_group_change_owner()
sysfs: support SYSFS_GROUP_INVISIBLE for unnamed attribute groups
sysfs: simplify error handling in create_files()
fs/sysfs/group.c | 93 ++++++++++++++++++++++++++++-----------------------
include/linux/sysfs.h | 52 ++++++++++++++++------------
2 files changed, 81 insertions(+), 64 deletions(-)
---
base-commit: 84abb955b1015477aa11a96e2f3ac1b938b77f48
change-id: 20261115-sysfs-group-invisible-443ba270fd0a
Thanks.
--
Dmitry
next reply other threads:[~2026-11-16 9:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 9:42 Dmitry Torokhov [this message]
2026-11-16 9:42 ` [PATCH 1/4] sysfs: check for SYSFS_GROUP_INVISIBLE using equality comparison Dmitry Torokhov
2026-11-16 9:42 ` [PATCH 2/4] sysfs: check group visibility upfront in sysfs_group_change_owner() Dmitry Torokhov
2026-11-16 9:42 ` [PATCH 3/4] sysfs: support SYSFS_GROUP_INVISIBLE for unnamed attribute groups Dmitry Torokhov
2026-11-16 9:42 ` [PATCH 4/4] sysfs: simplify error handling in create_files() Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116-sysfs-group-invisible-v1-0-94cd173a7d9a@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=fmancera@suse.de \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®