Re: [RESEND PATCH] prctl: add PR_[GS]ET_PDEATHSIG_PROC

Eric W. Biederman
2017-10-03T16:36:45Z

Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Tue, Oct 3, 2017 at 7:46 AM, Eric W. Biederman <ebiederm@xmission.com> wrote:
>>
>> The process that requests the signal be sent is the process that is
>> receiving the signal. I can see a theoretical need for a permission
>> check in there somewhere (especially as this persists over fork).
>
> Note that it also persists over not just fork, but execve() too.
>
> Yes, the signal is cleared if the e[ug]id/fs[ug]id is changed by exec,
> but not (for example) if just uid is changed.

*Scratches head*
pdeath_signal is cleared during exec if bprm->cap_elevated.

bprm->cap_elevated is set if we are not root and we gain caps during the exec.
bprm->cap_elevated is set if is_setid is true.
is_setid is set if the uid != eid or gid != egid.

So looking at that I am not exactly wild about the name cap_elevated,
but it seems to clear pdeath_signal if the jus the uid is changed during
exec.

> Does that matter? Probably not. But signal handling does actually
> check uid, so it does actually affect signal permission checks across
> execve.

I don't think there is anything in exec in this case to worry about.

Of course there is the completely bizarre case that if the parent execs
or calls setresuid it is possible that the signal won't send because it
is the parent's permission that are checked. I think that is probably
a bug.

I can understand not sending to our future self if our future self has
different credentials than our present self. But not sending to our
future self because someone else changed seems completely bizarre to me.

Eric