uterm: vt: fix race by blocking signals before setting them
We must block the signals before setting the signal handlers to avoid retrieving them asynchronously. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
616d5bbf6d
commit
4a4ccec363
@ -312,6 +312,16 @@ static int real_open(struct uterm_vt *vt, const char *vt_for_seat0)
|
||||
goto err_reset;
|
||||
}
|
||||
|
||||
sigemptyset(&mask);
|
||||
sigaddset(&mask, SIGUSR1);
|
||||
sigaddset(&mask, SIGUSR2);
|
||||
ret = sigprocmask(SIG_BLOCK, &mask, NULL);
|
||||
if (ret) {
|
||||
log_error("cannot block SIGUSR1/2 (%d): %m", errno);
|
||||
ret = -EFAULT;
|
||||
goto err_text;
|
||||
}
|
||||
|
||||
memset(&mode, 0, sizeof(mode));
|
||||
mode.mode = VT_PROCESS;
|
||||
mode.acqsig = SIGUSR1;
|
||||
@ -343,13 +353,6 @@ static int real_open(struct uterm_vt *vt, const char *vt_for_seat0)
|
||||
goto err_setmode;
|
||||
}
|
||||
|
||||
sigemptyset(&mask);
|
||||
sigaddset(&mask, SIGUSR1);
|
||||
sigaddset(&mask, SIGUSR2);
|
||||
ret = sigprocmask(SIG_BLOCK, &mask, NULL);
|
||||
if (ret)
|
||||
log_warning("cannot ignore SIGUSR1/2 (%d): %m", errno);
|
||||
|
||||
return 0;
|
||||
|
||||
err_setmode:
|
||||
|
Loading…
x
Reference in New Issue
Block a user