Re: [PATCH 20/20] signal: Don't restart fork when signals come in.

From: Linus Torvalds
Date: Tue Jul 24 2018 - 14:29:53 EST


On Tue, Jul 24, 2018 at 10:58 AM Eric W. Biederman
<ebiederm@xxxxxxxxxxxx> wrote:
>
> Yes you are quite right. Easy enough to fix, but it definitely needs
> to be fixed.
>
> I will respin.

Would you mind trying a slightly different approach for this?

How about moving the "copy_signal()" and "copy_sighandler()" cases up
to fairly early in the "copy_process()" function (and clean up late,
obviously).

Then, instead of that "struct multiprocess_signals" thing, just add a
"struct hlist_node node" to "struct signal" itself, and add it to the
multiprocess hlist there.

And then you can just remove it in bad_fork_cleanup_signal.

Does this make "struct signal" a bit larger? Yes, but it's not a huge
deal. We *could* make is some union with existing fields if we cared.

But I think it would make the code *much* more understandable, and it
would allow us to not have that "sigpending" copy, because you can
just populate the final "signal->shared_pending" directly.

Hmm?

Linus