Re: [PATCH] selinux_restorecon: Do not exit on directory cycles

Stephen Smalley <[email protected]> Tue, 21 Jul 2026 09:54:28 -0400
Newsgroups org.kernel.vger.selinux
Message-ID <CAEjxPJ7+=671kRb2fxSgZsyDuysDatMamUZT_vtFkug6_5x2nQ@mail.gmail.com>
On Tue, Jul 21, 2026 at 3:23 AM Johannes Segitz <[email protected]> wrote:
>
> All other failures are handled gracefully. Directory cycles can e.g.
> happen on BTRFS filesystems with subvolumes. Skip them and continue
> instead of exiting
>
> Signed-off-by: Johannes Segitz <[email protected]>

This doesn't apply on selinux/main.

> ---
>  libselinux/src/selinux_restorecon.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
> index 7ef2d45d..33d315a2 100644
> --- a/libselinux/src/selinux_restorecon.c
> +++ b/libselinux/src/selinux_restorecon.c
> @@ -883,13 +883,12 @@ loop_body:
>
>                 switch (ftsent->fts_info) {
>                 case FTS_DC:
> -                       selinux_log(SELINUX_ERROR,
> +                       selinux_log(SELINUX_WARNING,
>                                     "Directory cycle on %s.\n",
>                                     ftsent->fts_path);
>                         errno = ELOOP;
> -                       state->error = -1;
> -                       state->abort = true;
> -                       goto finish;
> +                       fts_set(fts, ftsent, FTS_SKIP);
> +                       continue;
>                 case FTS_DP:
>                         continue;
>                 case FTS_DNR:
> --
> 2.55.0