Re: [PATCH] exec: clarify reasoning for euid/egid reset

From: David Howells
Date: Tue Apr 12 2016 - 13:18:32 EST


Kees Cook <keescook@xxxxxxxxxxxx> wrote:

> - /* clear any previous set[ug]id data from a previous binary */
> + /*
> + * Since this can be called multiple times (via prepare_binprm),
> + * we must clear any previous work done when setting set[ug]id
> + * bits from any earlier bprm->file uses (for example when run
> + * first for a script then for its interpreter).
> + */
> bprm->cred->euid = current_euid();
> bprm->cred->egid = current_egid();

I would further add that this is where we deal with setuid scripts.

David