Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966064AbcDLRS3 (ORCPT ); Tue, 12 Apr 2016 13:18:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36870 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964888AbcDLRS2 (ORCPT ); Tue, 12 Apr 2016 13:18:28 -0400 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20160412164428.GA1972@www.outflux.net> References: <20160412164428.GA1972@www.outflux.net> To: Kees Cook Cc: dhowells@redhat.com, Linus Torvalds , Serge Hallyn , Willy Tarreau , Alexander Viro , linux-kernel@vger.kernel.org Subject: Re: [PATCH] exec: clarify reasoning for euid/egid reset MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28637.1460481505.1@warthog.procyon.org.uk> Date: Tue, 12 Apr 2016 18:18:25 +0100 Message-ID: <28638.1460481505@warthog.procyon.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 534 Lines: 15 Kees Cook 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