Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3763425ybk; Tue, 19 May 2020 12:21:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEv0ElD+kw9nU1aM5amN6mzDAKpT3titbyFoc35qeIvoTYBffzDBQBcCiwVL/q3lBmS8T3 X-Received: by 2002:a05:6402:14d5:: with SMTP id f21mr361271edx.327.1589916099953; Tue, 19 May 2020 12:21:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589916099; cv=none; d=google.com; s=arc-20160816; b=zxiZMYbEtZE9mc2N1gmLMz+EBw7asQg6EWfE8WI4Z8VOGfgpinLOVvh+dJPb/c1ewZ WPPsRTDMdCS00ZcnpmEzeDuV0PReXn41qv5Bk6jmRiW9KSHH9FY9gz7SwiB+DIO65O3u y72QorLOJY1DsWFwVKHwUAOKrsSOqLrR4fpHqMQg9I0118y2sePZZPqJVPfvfdl46OVc cyGpiKKQ83v/V5B6rPxnh+dTvBmZwtOmuAHCMzXjnjW5h06l8/erxk2XMTrq/PDZlQbc XLnUNfkShX8U635G4VS7F5eo7UXYB8yyEZCIRgUjNfCnuXEm1MWbuEa8ZObToKu0hYSG vuZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=CsLYnYmAxC5Xy4I4JEJhi41vLOVU5Tcj0+at/iBshw8=; b=H1BIiModVXbL/6lRrN9H9jvAdqU8JYr3D52dLV0DVyxGqJNVuzUcu2DduRF1wfi9Fp TZPCagDLMvzJATclyaMUwlKMfCPRxI6m6wIaT8050z9oqTl944uoTmG8hdrQzEqDsKRe 3FAira8rxptcv7OC0jMF5WI5djUsYUtnU61FF36WCVI4NUwLxvh8N2mBDwlNrZeBkky3 KpoMl0zswiDjCMPzJAi1yrWlkxAzhqMRknmhPrYABbYs0H51v9J+rvtqzHgVowllzY19 WZAHXilQ2vvhctpP0kvxCSD9bFx0fKrXNu0r8PDHBXRlR0KGVuA+wd8muB7lgrSCxgGR qO6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=n3BbAEd8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n21si368382ejg.267.2020.05.19.12.21.17; Tue, 19 May 2020 12:21:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=n3BbAEd8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726861AbgESTRx (ORCPT + 99 others); Tue, 19 May 2020 15:17:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726783AbgESTRv (ORCPT ); Tue, 19 May 2020 15:17:51 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EA83C08C5C2 for ; Tue, 19 May 2020 12:17:50 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id q24so105733pjd.1 for ; Tue, 19 May 2020 12:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CsLYnYmAxC5Xy4I4JEJhi41vLOVU5Tcj0+at/iBshw8=; b=n3BbAEd80W8lORyrkRONNmSZiGMzOjpMD3ADndrO0zMLPlQydwwiQ8oXeCnDAn/Q4P 1Oc4ou7ylcYhsHVoqZs3gZJKLlWq46KsssfA98OM0KsdkN1X62LVSYwnxtMj7FXKmVpE dE/eaXUC1cT0/siXuAoodyKwNGf87YRwcGm7Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CsLYnYmAxC5Xy4I4JEJhi41vLOVU5Tcj0+at/iBshw8=; b=RR5LEm3UrAnk6Jxm6MNDlfcROT8Uiqnqfr1SgHheJ1Cyym1mp6KLa07u7cnVTOBeyi TopoQDmr29C+0F/5eNcDYWxzGzZQZWtp0LqE/CZVh7SjjOCRNFiOgF3hzzbMt6VJ6EZZ iYmBPIfPY2AuaSkqRPLL0Kj4BnMhBWjib86E58o37SsrAfNF8+/ILdo9SvVBfhN2djtW WBw7jHHKQxKKQay6L01pkLHnDUcUax9C9Eul3KiEbJbn62e3x9DguL619udioofhqPIE hZ8oG/EJFcYDZLwEMp5ZjeRJbGsTdO4YKBMwHmUbYhE6x2BXuWhxLFquhz6Yk3IplZl+ yfXg== X-Gm-Message-State: AOAM531pgwEIWi5XgYxZpALyVxhRUKubvDll7My2O/QsGJjM1hDggWge OXUn0wusHpgtFzIPbLvKqVGuA+aIZ+06PA== X-Received: by 2002:a17:902:c487:: with SMTP id n7mr912097plx.316.1589915869555; Tue, 19 May 2020 12:17:49 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id b137sm216926pfb.110.2020.05.19.12.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 12:17:48 -0700 (PDT) Date: Tue, 19 May 2020 12:17:47 -0700 From: Kees Cook To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Oleg Nesterov , Jann Horn , Greg Ungerer , Rob Landley , Bernd Edlinger , linux-fsdevel@vger.kernel.org, Al Viro , Alexey Dobriyan , Andrew Morton , Casey Schaufler , linux-security-module@vger.kernel.org, James Morris , "Serge E. Hallyn" , Andy Lutomirski Subject: Re: [PATCH v2 4/8] exec: Allow load_misc_binary to call prepare_binfmt unconditionally Message-ID: <202005191215.5411A2D1@keescook> References: <87h7wujhmz.fsf@x220.int.ebiederm.org> <87sgga6ze4.fsf@x220.int.ebiederm.org> <87v9l4zyla.fsf_-_@x220.int.ebiederm.org> <877dx822er.fsf_-_@x220.int.ebiederm.org> <87imgszrwo.fsf_-_@x220.int.ebiederm.org> <202005191122.0A1FD07@keescook> <87sgfvoi8d.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87sgfvoi8d.fsf@x220.int.ebiederm.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 19, 2020 at 02:08:34PM -0500, Eric W. Biederman wrote: > Kees Cook writes: > > > On Mon, May 18, 2020 at 07:31:51PM -0500, Eric W. Biederman wrote: > >> [...] > >> diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h > >> index 8605ab4a0f89..dbb5614d62a2 100644 > >> --- a/include/linux/binfmts.h > >> +++ b/include/linux/binfmts.h > >> @@ -26,6 +26,8 @@ struct linux_binprm { > >> unsigned long p; /* current top of mem */ > >> unsigned long argmin; /* rlimit marker for copy_strings() */ > >> unsigned int > >> + /* It is safe to use the creds of a script (see binfmt_misc) */ > >> + preserve_creds:1, > > > > How about: > > > > /* > > * A binfmt handler will set this to True before calling > > * prepare_binprm() if it is safe to reuse the previous > > * credentials, based on bprm->file (see binfmt_misc). > > */ > > I think that is more words saying less. > > While I agree it might be better. I don't see what your comment adds to > the understanding. What do you see my comment not saying that is important? I think your comment is aimed at the consumer of preserve_creds (i.e. the fs/exec.c code), whereas I think the comment should be directed at a binfmt author, who wants to answer the question "why would I set this flag?" Though I strongly hope we never have new binfmts. ;) -- Kees Cook