From: Christian Brauner <christian.brauner@ubuntu.com>
To: Florian Weimer <fweimer@redhat.com>,
Adhemerval Zanella <adhemerval.zanella@linaro.org>,
libc-alpha@sourceware.org
Subject: Re: [PATCH] [GLIBC RFC] clone3: add CLONE3_RESET_SIGHAND
Date: Tue, 08 Oct 2019 14:14:00 -0000 [thread overview]
Message-ID: <20191008141416.qnvy6yr3kei3u3la@wittgenstein> (raw)
In-Reply-To: <20191008134417.16113-1-christian.brauner@ubuntu.com>
On Tue, Oct 08, 2019 at 03:44:17PM +0200, Christian Brauner wrote:
> Reset all signal handlers of the child not set to SIG_IGN to SIG_DFL.
> Mutually exclusive with CLONE_SIGHAND to not disturb other threads
> signal handler.
>
> Questions for glibc before going to send this for review on lkml:
> - Is it sufficient for glibc to get EINVAL when CLONE3_RESET_SIGNALS is
> passed to determine kernel support for it?
> - Do you really want to have only those signals set to SIG_DFL which are
> not SIG_IGN or do you want to enforce _all_ signals are set to
> SIG_DFL even if they are SIG_IGN?
>
> Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
> ---
> include/uapi/linux/sched.h | 3 +++
> kernel/fork.c | 8 +++++++-
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/include/uapi/linux/sched.h b/include/uapi/linux/sched.h
> index 99335e1f4a27..e3bc43efbbba 100644
> --- a/include/uapi/linux/sched.h
> +++ b/include/uapi/linux/sched.h
> @@ -33,6 +33,9 @@
> #define CLONE_NEWNET 0x40000000 /* New network namespace */
> #define CLONE_IO 0x80000000 /* Clone io context */
>
> +/* Flags for the clone3() syscall */
> +#define CLONE3_RESET_SIGHAND 0x100000000ULL /* Reset any signal handler which is not SIG_IGN or SIG_DFL to SIG_DFL. */
> +
> #ifndef __ASSEMBLY__
> /**
> * struct clone_args - arguments for the clone3 syscall
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 1f6c45f6a734..3bced4a2931e 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -1516,6 +1516,9 @@ static int copy_sighand(unsigned long clone_flags, struct task_struct *tsk)
> refcount_set(&sig->count, 1);
> spin_lock_irq(¤t->sighand->siglock);
> memcpy(sig->action, current->sighand->action, sizeof(sig->action));
> + /* Reset all signal handler not set to SIG_IGN to SIG_DFL. */
> + if (clone_flags & CLONE3_RESET_SIGHAND)
> + flush_signal_handlers(tsk, 0);
> spin_unlock_irq(¤t->sighand->siglock);
> return 0;
> }
> @@ -2567,7 +2570,7 @@ static bool clone3_args_valid(const struct kernel_clone_args *kargs)
> * All lower bits of the flag word are taken.
> * Verify that no other unknown flags are passed along.
> */
> - if (kargs->flags & ~CLONE_LEGACY_FLAGS)
> + if (kargs->flags & ~(CLONE_LEGACY_FLAGS | CLONE3_RESET_SIGNALS))
> return false;
>
> /*
> @@ -2577,6 +2580,9 @@ static bool clone3_args_valid(const struct kernel_clone_args *kargs)
> if (kargs->flags & (CLONE_DETACHED | CSIGNAL))
> return false;
>
> + if (kargs->flags & (CLONE_SIGHAND | CLONE3_RESET_SIGHAND))
> + return false;
That obviously should've been:
if ((kargs->flags & (CLONE_SIGHAND | CLONE3_RESET_SIGHAND)) ==
(CLONE_SIGHAND | CLONE3_RESET_SIGHAND))
return false;
but you get the gist.
Thanks!
Christian
next prev parent reply other threads:[~2019-10-08 14:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-08 13:44 Christian Brauner
2019-10-08 14:14 ` Christian Brauner [this message]
2019-10-08 14:20 ` Adhemerval Zanella
2019-10-09 10:48 ` Christian Brauner
2019-10-09 11:04 ` Florian Weimer
2019-10-09 11:12 ` Christian Brauner
2019-10-09 11:56 ` Florian Weimer
2019-10-09 11:58 ` Christian Brauner
2019-10-09 12:01 ` Florian Weimer
2019-10-09 13:33 ` Christian Brauner
2019-10-10 10:51 ` Christian Brauner
2019-10-10 14:49 ` Florian Weimer
2019-10-11 10:47 ` Christian Brauner
2019-10-09 11:14 ` Dmitry V. Levin
2019-12-04 13:16 ` clone3: CLONE_CLEAR_SIGHAND v5.5 Christian Brauner
2019-12-04 13:45 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191008141416.qnvy6yr3kei3u3la@wittgenstein \
--to=christian.brauner@ubuntu.com \
--cc=adhemerval.zanella@linaro.org \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).