selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] setfiles: Add -A option to disable SELINUX_RESTORECON_ADD_ASSOC
@ 2025-09-01 14:31 Richard W.M. Jones
  2025-09-01 14:31 ` Richard W.M. Jones
  0 siblings, 1 reply; 7+ messages in thread
From: Richard W.M. Jones @ 2025-09-01 14:31 UTC (permalink / raw)
  To: selinux

SELINUX_RESTORECON_ADD_ASSOC tracks conflicts between inodes that have
differing contexts.  However doing this involves building a large
internal hashtable that stores the full path of every file examined by
setfiles.  For filesystems that have very large numbers of files or
long pathnames, this uses a lot of memory, which makes SELinux
relabelling in constrained memory environments infeasible.

This adds a new 'setfiles -A' option that disables this tracking.

For example, using setfiles to relabel a filesystem with 15 million
files took 3.7GB of RAM.  Using this option, the same filesystem can
be relabelled in 121MB (albeit with no warnings or errors possible for
conflicting labels, but for our use case we don't care about that.)

While this is quite niche, reducing the memory usage of setfiles
allows us to do offline SELinux relabelling without worrying about the
number of files in the filesystem.

Fixes: https://issues.redhat.com/browse/RHEL-111505

(I also posted it as a pull request here:
https://github.com/SELinuxProject/selinux/pull/490)


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

end of thread, other threads:[~2025-09-02 17:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-01 14:31 [PATCH] setfiles: Add -A option to disable SELINUX_RESTORECON_ADD_ASSOC Richard W.M. Jones
2025-09-01 14:31 ` Richard W.M. Jones
2025-09-02 15:46   ` Stephen Smalley
2025-09-02 16:12     ` Petr Lautrbach
2025-09-02 16:30       ` Stephen Smalley
2025-09-02 16:54       ` Richard W.M. Jones
2025-09-02 17:45         ` Stephen Smalley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).