Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933962AbcDLQzU (ORCPT ); Tue, 12 Apr 2016 12:55:20 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:48351 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933832AbcDLQzR (ORCPT ); Tue, 12 Apr 2016 12:55:17 -0400 Date: Tue, 12 Apr 2016 16:54:52 +0000 From: Serge Hallyn To: Kees Cook Cc: Linus Torvalds , David Howells , Willy Tarreau , Alexander Viro , linux-kernel@vger.kernel.org Subject: Re: [PATCH] exec: clarify reasoning for euid/egid reset Message-ID: <20160412165452.GC19101@ubuntumail> References: <20160412164428.GA1972@www.outflux.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160412164428.GA1972@www.outflux.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1111 Lines: 39 Quoting Kees Cook (keescook@chromium.org): > This section of code initially looks redundant, but is required. This > improves the comment to explain more clearly why the reset is needed. > > Signed-off-by: Kees Cook Thanks, Kees. Acked-by: Serge E. Hallyn > --- > fs/exec.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/fs/exec.c b/fs/exec.c > index c4010b8207a1..889221bbfdb3 100644 > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -1387,7 +1387,12 @@ static void bprm_fill_uid(struct linux_binprm *bprm) > kuid_t uid; > kgid_t gid; > > - /* 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(); > > -- > 2.6.3 > > > -- > Kees Cook > Chrome OS & Brillo Security