Re: [PATCH 1/4] restorecond: switch terminate to sig_atomic_t for async-signal-safety

Stephen Smalley <[email protected]> Tue, 21 Jul 2026 08:53:30 -0400
Newsgroups org.kernel.vger.selinux
Message-ID <CAEjxPJ7aXzN_A2+Lq_098q0WpceyhCgeuEQjrwrCkqkGSxA20A@mail.gmail.com>
On Thu, Jul 16, 2026 at 3:37 PM Stephen Smalley
<[email protected]> wrote:
>
> The terminate flag is written from a signal handler so switch it to
> volatile sig_atomic_t for async-signal-safety.
>
> Signed-off-by: Stephen Smalley <[email protected]>

This series has been merged.

> ---
>  restorecond/restorecond.c | 2 +-
>  restorecond/restorecond.h | 4 +++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/restorecond/restorecond.c b/restorecond/restorecond.c
> index b8ca4b21..0e973d83 100644
> --- a/restorecond/restorecond.c
> +++ b/restorecond/restorecond.c
> @@ -73,7 +73,7 @@ struct restore_opts r_opts;
>  #include <selinux/selinux.h>
>
>  int debug_mode = 0;
> -int terminate = 0;
> +volatile sig_atomic_t terminate = 0;
>  int master_wd = -1;
>  int run_as_user = 0;
>  int foreground_mode = 0;
> diff --git a/restorecond/restorecond.h b/restorecond/restorecond.h
> index 9fb5c5d5..7e209226 100644
> --- a/restorecond/restorecond.h
> +++ b/restorecond/restorecond.h
> @@ -24,9 +24,11 @@
>  #ifndef RESTORED_CONFIG_H
>  #define RESTORED_CONFIG_H
>
> +#include <signal.h>
> +
>  extern int debug_mode;
>  extern const char *homedir;
> -extern int terminate;
> +extern volatile sig_atomic_t terminate;
>  extern int master_wd;
>  extern int run_as_user;
>
> --
> 2.55.0
>