Re: [PATCH v4 1/2] selinux_restorecon: Do not exit on directory cycles

Stephen Smalley <[email protected]> Tue, 28 Jul 2026 10:48:34 -0400
Newsgroups org.kernel.vger.selinux
Message-ID <CAEjxPJ4Q0Ki0sFWZKx78eSsjdOmTsECeFYNd4x++PLhL0473Sw@mail.gmail.com>
On Tue, Jul 28, 2026 at 3:06 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]>

Acked-by: Stephen Smalley <[email protected]>

> ---
>  libselinux/src/selinux_restorecon.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
> index 30f1b836..4233ba65 100644
> --- a/libselinux/src/selinux_restorecon.c
> +++ b/libselinux/src/selinux_restorecon.c
> @@ -1393,15 +1393,13 @@ 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;
> +                               prune_pathbuf(state);
> +                               continue;
>                         }
>
>                         if (state->sfsb.f_type == SYSFS_MAGIC &&
> --
> 2.55.0
>
>