Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp553217ybk; Fri, 15 May 2020 07:39:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL542wRbaevReTNqHZ7ofKbqIci9xq+Ysqi1I4vJqElHVSydXFyJ5JF/Xgbnlg6Et/Xk0M X-Received: by 2002:a17:906:6841:: with SMTP id a1mr3200020ejs.271.1589553553425; Fri, 15 May 2020 07:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589553553; cv=none; d=google.com; s=arc-20160816; b=tBYiPwKXE9goLLgoL+kgALJmxlZs4Rxwi9CGM5wWlnaiOxSYMqrP/qFZv7f8ZMwKmV o37qMAJYP31AiSyQuYTmDjzCtjWlKPvtJ2V974P1tjMMsXv9xNa47X1mEaEojA+wWzzp 1yDwNla+nq0JcvuThzLVQcrOwaKvycPVSDPS1zKW4otqirEEL+jHd+viWVLnOYoBwSsk cqTmvU8LEIuP17wSx5MGRgSVX1dE+sBeNCSqWFTFlyvJbwT+8/0Oe75vkwwQbSMO9etR SGd9qqnV5/KDjUp3S8ptaR6sFDOfZRNMh69hyIW3Tob33UhkQ4+d+XEWSiyXGCS6bPv2 vZzg== 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=GkgSQWYyEHrVohFFMSyphZgO4DDabSVNfncbmH3+PSA=; b=gposSn2WDTRIpAL7Eq0c0kTOGYHcAeMCTnKgcNRbVNVkaFAlNQgsN+y1zPyeLaixsm 6ibkiIHM57P2aGE+VyhMsyOOWvWvxVJIACY2OPVyDOiozyBQS1CNDsYEBF2g0YpbqC0a WHY4lpbe2eL9+s9OYnL8Xcicj72wMRVzjWO3nSe1Bp/YmktAmTjyhYNHb3EWI8YT0sTw L13PNrB8Lb8tFxjmPfotBjP3s9/4n/OJN4S/9rJgiLKMhVtP0dlH4dG5XeWuic6v/YqQ DCxw9szkKlTkzRWJj54b9MgnC/GDwoUYADdBXbLe5x2YNdtNb53RJZWY/H0I6KQMvQEd BLgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=i7phLR6o; 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 d14si1397381edv.332.2020.05.15.07.38.51; Fri, 15 May 2020 07:39:13 -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=i7phLR6o; 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 S1726719AbgEOOhW (ORCPT + 99 others); Fri, 15 May 2020 10:37:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726718AbgEOOhT (ORCPT ); Fri, 15 May 2020 10:37:19 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D224C05BD0C for ; Fri, 15 May 2020 07:37:19 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id 145so1015395pfw.13 for ; Fri, 15 May 2020 07:37:19 -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=GkgSQWYyEHrVohFFMSyphZgO4DDabSVNfncbmH3+PSA=; b=i7phLR6oslO+nKsuBoJMm/9bH/JqIgx0izgjVqNpzYrr5so+8tSWN9Yf5iu61KRlBK Udu9CbA+KyxU6EBm8+gDNGEL/mh1EmL9zpEH2ZzYj91LqaHO8SRqBPJ4m+Ti1YEJzzGA jofFicakkW+mtqfl3m559FLv+sFicL0eDLX0k= 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=GkgSQWYyEHrVohFFMSyphZgO4DDabSVNfncbmH3+PSA=; b=HMVHoYALVqMBjVYamBbGW+lM+QZADgNt+7gNveJRrMzDqAa2oRzDi+ErnRTaDArZDA cxjte1WeI314pLKMUE27+hEqofQg/yKJlPo043WSyXKiy6/QH0ieOsOvhGhgS0uLBsfM oyTEVVCEch8/+HHqUrijQZ4vg1izJ0KPqDBx6eEHTJYYhu+4F76BRM2xRMKh6dvwPdyA gQmhTakZ8nyO5e8KwhASjIkId/GdxUHM3y1LVz3EgjGQnhthR/jiFCoSYUpMfpeqQ756 DSNB2yqKuPLqwWYp3NLL2cBsgfhqL4K1XZ9d+WUIJgNdB35jmPp3rojra89YVT9kTOMz 279w== X-Gm-Message-State: AOAM533gBFx8SHaRbw35LasgoaMGjnAQakRSCGKiQmAQgMJzK2CaN+Mp KwiiT2YhXfZYUEwZZmYDuJ7l+g== X-Received: by 2002:a62:18c1:: with SMTP id 184mr3649253pfy.277.1589553438673; Fri, 15 May 2020 07:37:18 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q134sm2132257pfc.143.2020.05.15.07.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 07:37:17 -0700 (PDT) Date: Fri, 15 May 2020 07:37:16 -0700 From: Kees Cook To: Florian Weimer Cc: =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= , Al Viro , Aleksa Sarai , Andy Lutomirski , Mimi Zohar , Stephen Smalley , Christian Heimes , Deven Bowers , Tetsuo Handa , John Johansen , Kentaro Takeda , "Lev R. Oshvang ." , Alexei Starovoitov , Daniel Borkmann , Eric Chiang , James Morris , Jan Kara , Jann Horn , Jonathan Corbet , Lakshmi Ramasubramanian , Matthew Garrett , Matthew Wilcox , Michael Kerrisk , =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= , Philippe =?iso-8859-1?Q?Tr=E9buchet?= , Scott Shell , Sean Christopherson , Shuah Khan , Steve Dower , Steve Grubb , Thibaut Sautereau , Vincent Strubel , linux-kernel , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-integrity@vger.kernel.org, LSM List , Linux FS Devel Subject: Re: How about just O_EXEC? (was Re: [PATCH v5 3/6] fs: Enable to enforce noexec mounts or file exec through O_MAYEXEC) Message-ID: <202005150732.17C5EE0@keescook> References: <20200505153156.925111-4-mic@digikod.net> <202005131525.D08BFB3@keescook> <202005132002.91B8B63@keescook> <202005140830.2475344F86@keescook> <202005142343.D580850@keescook> <87a729wpu1.fsf@oldenburg2.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87a729wpu1.fsf@oldenburg2.str.redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 15, 2020 at 10:43:34AM +0200, Florian Weimer wrote: > * Kees Cook: > > > Maybe I've missed some earlier discussion that ruled this out, but I > > couldn't find it: let's just add O_EXEC and be done with it. It actually > > makes the execve() path more like openat2() and is much cleaner after > > a little refactoring. Here are the results, though I haven't emailed it > > yet since I still want to do some more testing: > > https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=kspp/o_exec/v1 > > I think POSIX specifies O_EXEC in such a way that it does not confer > read permissions. This seems incompatible with what we are trying to > achieve here. I was trying to retain this behavior, since we already make this distinction between execve() and uselib() with the MAY_* flags: execve(): struct open_flags open_exec_flags = { .open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC, .acc_mode = MAY_EXEC, uselib(): static const struct open_flags uselib_flags = { .open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC, .acc_mode = MAY_READ | MAY_EXEC, I tried to retain this in my proposal, in the O_EXEC does not imply MAY_READ: + /* Should execution permissions be checked on open? */ + if (flags & O_EXEC) { + flags |= __FMODE_EXEC; + acc_mode |= MAY_EXEC; + } -- Kees Cook