SELinux Security Module development
 help / color / mirror / Atom feed
From: Johannes Segitz <jsegitz@suse.de>
To: selinux@vger.kernel.org
Subject: [PATCH] selinux_restorecon: Do not exit on directory cycles
Date: Thu, 23 Jul 2026 10:55:21 +0200	[thread overview]
Message-ID: <amHW-fFHM3pw-g3y@suse.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1553 bytes --]

All other failures are handled gracefully. Directory cycles can e.g.
happen on BTRFS filesystems with subvolumes. Skip them and continue
instead of exiting
---
 libselinux/src/selinux_restorecon.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
index 30f1b836..fdefc92c 100644
--- a/libselinux/src/selinux_restorecon.c
+++ b/libselinux/src/selinux_restorecon.c
@@ -1393,15 +1393,14 @@ static void *selinux_restorecon_thread(void *arg)
                if (is_dir) {
                        if (descend && walk_is_cycle(state, ent_sb.st_dev,
                                                     ent_sb.st_ino)) {
-                               selinux_log(SELINUX_ERROR,
+                               selinux_log(SELINUX_WARNING,
                                            "Directory cycle on %s.\n",
                                            ent_path);
                                close(ent_fd);
-                               close(rd_fd);
-                               errno = ELOOP;
-                               state->error = -1;
-                               state->abort = true;
-                               goto finish;
+                               if (rd_fd >= 0)
+                                       close(rd_fd);
+                               prune_pathbuf(state);
+                               continue;
                        }

                        if (state->sfsb.f_type == SYSFS_MAGIC &&
--
2.55.0

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 870 bytes --]

             reply	other threads:[~2026-07-23  8:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  8:55 Johannes Segitz [this message]
2026-07-23 14:55 ` [PATCH] selinux_restorecon: Do not exit on directory cycles Stephen Smalley
2026-07-23 15:21   ` Johannes Segitz
2026-07-23 15:38     ` Stephen Smalley
2026-07-23 15:42       ` Johannes Segitz
2026-07-24 15:29         ` Stephen Smalley
  -- strict thread matches above, loose matches on Subject: below --
2026-07-21  7:17 Johannes Segitz
2026-07-21 13:54 ` Stephen Smalley
2026-07-21 15:15   ` Johannes Segitz

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=amHW-fFHM3pw-g3y@suse.com \
    --to=jsegitz@suse.de \
    --cc=selinux@vger.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