Re: [PATCH] Revert "exec: make de_thread() freezable (was: Re: Linux 4.20-rc4)

From: Linus Torvalds
Date: Tue Dec 04 2018 - 14:50:09 EST


On Tue, Dec 4, 2018 at 11:33 AM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> Looking at this, I'm agreeing that ot would be better to just try to
> narrow down the cred_guard_mutex use a lot.

Ho humm. This is a crazy idea, but I don't see why it wouldn't work.

How about we:

- stop holding on to cred_guard_mutex entirely in the exec path

and instead just do:

- prepare_bprm_creds takes a ref to our old creds, and saves it off in the bprm

- security_bprm_{committing,committed}_creds() can do it's "is this a
valid transition" using the saved-off old creds instead of the current
creds

because honestly, the *only* reason we hold on to that lock is for the
insane and not really interesting case of "somebody tried to use
ptrace to change the creds in-flight during the exec".

Or maybe we could just add a task state flag that says "in exec, you
can't modify the creds in this window, because we're about to switch
to new creds".

Again, no *normal* situation will even notice or care, I think. We
hold the cred lock purely to make sure that the sequence from
prepare_exec_creds -> install_exec_creds is "atomic" wrt credentials,
and it already is for all the normal cases since this is all inside a
single execve system call.

Linus