This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] pt_chown: Clear any signal mask inherited from the parent process.
- From: Geoffrey Thomas <geofft at ldpreload dot com>
- To: libc-alpha at sourceware dot org
- Date: Sun, 17 May 2015 16:02:16 -0400 (EDT)
- Subject: [PATCH] pt_chown: Clear any signal mask inherited from the parent process.
- Authentication-results: sourceware.org; auth=none
If grantpt() is called from a thread that is masking signals (for
instance, from a program using signalfd or using a dedicated
signal-handling thread), then thas mask will get inherited to pt_chown.
This means that signals like SIGINT will not interrupt grantpt(), so if it
hangs (e.g., because getgrnam("tty") hangs on a remote name service),
Ctrl-C will terminate the parent process but leave grantpt() around. Since
it's setuid, it's hard to kill any other way.
---
login/programs/pt_chown.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/login/programs/pt_chown.c b/login/programs/pt_chown.c
index e8d4716..ec78538 100644
--- a/login/programs/pt_chown.c
+++ b/login/programs/pt_chown.c
@@ -23,6 +23,7 @@
#include <grp.h>
#include <libintl.h>
#include <locale.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -148,6 +149,11 @@ main (int argc, char *argv[])
uid_t euid = geteuid ();
uid_t uid = getuid ();
int remaining;
+ sigset_t sigset;
+
+ /* Clear any signal mask from the parent process. */
+ sigemptyset(&sigset);
+ sigprocmask(SIG_SETMASK, &sigset, NULL);
if (argc == 1 && euid == 0)
{
--
1.9.1