Action scripts should be invoked with normal signal behavior

Submitted by Nicolas Viennot on Oct. 24, 2019, 7:39 p.m.

Details

Message ID 7921bef6377c455c9b12a335863235ad@EXMBDFT10.ad.twosigma.com
State Accepted
Series "Action scripts should be invoked with normal signal behavior"
Commit ff97dde5e4e9951448c380dc3347b84130723db2
Headers show

Commit Message

Nicolas Viennot Oct. 24, 2019, 7:39 p.m.
Signal masks propagate through execve, so we need to clear them before
invoking the action scripts as it may want to handle SIGCHLD, or SIGSEGV.

Signed-off-by: Nicolas Viennot <nicolas.viennot@twosigma.com>
---
 criu/util.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/util.c b/criu/util.c
index 0761ec04..9c0653ed 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -558,7 +558,7 @@  int cr_system_userns(int in, int out, int err, char *cmd,
 	sigemptyset(&blockmask);
 	sigaddset(&blockmask, SIGCHLD);
 	if (sigprocmask(SIG_BLOCK, &blockmask, &oldmask) == -1) {
-		pr_perror("Can not set mask of blocked signals");
+		pr_perror("Cannot set mask of blocked signals");
 		return -1;
 	}
 
@@ -567,6 +567,12 @@  int cr_system_userns(int in, int out, int err, char *cmd,
 		pr_perror("fork() failed");
 		goto out;
 	} else if (pid == 0) {
+		sigemptyset(&blockmask);
+		if (sigprocmask(SIG_SETMASK, &blockmask, NULL) == -1) {
+			pr_perror("Cannot clear blocked signals");
+			goto out_chld;
+		}
+
 		if (userns_pid > 0) {
 			if (switch_ns(userns_pid, &user_ns_desc, NULL))
 				goto out_chld;

Comments

Andrei Vagin Oct. 30, 2019, 7:08 a.m.
Applied, thanks!

On Thu, Oct 24, 2019 at 07:39:39PM +0000, Nicolas Viennot wrote:
> Signal masks propagate through execve, so we need to clear them before
> invoking the action scripts as it may want to handle SIGCHLD, or SIGSEGV.
> 
> Signed-off-by: Nicolas Viennot <nicolas.viennot@twosigma.com>
> ---
>  criu/util.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/criu/util.c b/criu/util.c
> index 0761ec04..9c0653ed 100644
> --- a/criu/util.c
> +++ b/criu/util.c
> @@ -558,7 +558,7 @@ int cr_system_userns(int in, int out, int err, char *cmd,
>  	sigemptyset(&blockmask);
>  	sigaddset(&blockmask, SIGCHLD);
>  	if (sigprocmask(SIG_BLOCK, &blockmask, &oldmask) == -1) {
> -		pr_perror("Can not set mask of blocked signals");
> +		pr_perror("Cannot set mask of blocked signals");
>  		return -1;
>  	}
>  
> @@ -567,6 +567,12 @@ int cr_system_userns(int in, int out, int err, char *cmd,
>  		pr_perror("fork() failed");
>  		goto out;
>  	} else if (pid == 0) {
> +		sigemptyset(&blockmask);
> +		if (sigprocmask(SIG_SETMASK, &blockmask, NULL) == -1) {
> +			pr_perror("Cannot clear blocked signals");
> +			goto out_chld;
> +		}
> +
>  		if (userns_pid > 0) {
>  			if (switch_ns(userns_pid, &user_ns_desc, NULL))
>  				goto out_chld;
> -- 
> 2.19.1
> 
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu