mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] sysfs: support SYSFS_GROUP_INVISIBLE for unnamed groups and ownership updates
@ 2026-11-16  9:42 Dmitry Torokhov
  2026-11-16  9:42 ` [PATCH 1/4] sysfs: check for SYSFS_GROUP_INVISIBLE using equality comparison Dmitry Torokhov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2026-11-16  9:42 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Johan Hovold, Jakub Kicinski, Fernando Fernandez Mancera
  Cc: driver-core, linux-kernel

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-16  9:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16  9:42 [PATCH 0/4] sysfs: support SYSFS_GROUP_INVISIBLE for unnamed groups and ownership updates Dmitry Torokhov
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

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®