Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp936892ybj; Tue, 5 May 2020 10:00:07 -0700 (PDT) X-Google-Smtp-Source: APiQypKoLTVw4EWo1scRELAc8UL99AMA/uFQ+JOYbAwX74hs57I/Lg8n3o81wuY0oyMzzly67gW1 X-Received: by 2002:a17:907:435d:: with SMTP id oc21mr3753841ejb.100.1588698007036; Tue, 05 May 2020 10:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588698007; cv=none; d=google.com; s=arc-20160816; b=Dho/1/e5wsVlNtJfrXD75zbby3TNQKp0oPYmG70PhDKZQF07eBbyUXCR/2HOvjnYOl 99LKknC6ABDM2beyuhYbQNOY6VCmzjENTOFg7RA1l4DZa3bLqo5xm0ekui7aLRxoKiel fT1JcCLN5lhP1J8Sum0tBkg3OEh9zpIJVECF+5s2O3laZrTm35fryrKq4PBfAUXt9Rd2 oVvhCPT02t79sAGgxfeadl2ul+8jpgeJI+K8iSd34+XPMeF2EtK2Y0Ztip0DvYYUxugY Ez4ql5OoC0uohQiC1ia/ADziyBpFHF7Tgyy4vx3idDytOL3tWubCTPHj5gEE7hsAZFDH muTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=cFL1pKRiQk60IR+shCxJTOhh/Dg75YGEv24ZE2AtSaI=; b=kLlwTNeaSGbg0wa5pCIBYKyDYBXCQxOCwsDOGZgsLHL+H1SSWIj3/hZGlrEa5AzKvf KZw0f20cfDb/dx+5cZcCG5748D7/1uEEGFH0fBWGKVx6yQPvo88a0aJWnBoNHBgwht6Y i2eVykWtBRTLXEMED/FefvhuawCbXP8GMFRnjZbjgXLA3xfwv6Epy02PdpOdPIAo686L 9/1mmxArkebzW+ms0mx9Si75SUTCTduxncSyKu5cUWQg5ciwl69fOu8xfF4I44O5HbEy KcDhaAozG8dkVsPAPWJySj/6fubPHnOm2lfl4evpTXgq5kBrLnj06cQ+In9XNJP0sqqg cxgQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a17si1749494edb.590.2020.05.05.09.59.42; Tue, 05 May 2020 10:00:07 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729987AbgEEQ4I (ORCPT + 99 others); Tue, 5 May 2020 12:56:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729483AbgEEQ4F (ORCPT ); Tue, 5 May 2020 12:56:05 -0400 Received: from smtp-bc0d.mail.infomaniak.ch (smtp-bc0d.mail.infomaniak.ch [IPv6:2001:1600:3:17::bc0d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95A5AC061A10 for ; Tue, 5 May 2020 09:56:05 -0700 (PDT) Received: from smtp-2-0000.mail.infomaniak.ch (unknown [10.5.36.107]) by smtp-2-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 49Gm823TvXzlhlsl; Tue, 5 May 2020 18:56:02 +0200 (CEST) Received: from ns3096276.ip-94-23-54.eu (unknown [94.23.54.103]) by smtp-2-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 49Gm7z59gRzlq4RT; Tue, 5 May 2020 18:55:59 +0200 (CEST) Subject: Re: [PATCH v5 3/6] fs: Enable to enforce noexec mounts or file exec through O_MAYEXEC To: Randy Dunlap , linux-kernel@vger.kernel.org Cc: Aleksa Sarai , Alexei Starovoitov , Al Viro , Andy Lutomirski , Christian Heimes , Daniel Borkmann , Deven Bowers , Eric Chiang , Florian Weimer , James Morris , Jan Kara , Jann Horn , Jonathan Corbet , Kees Cook , Lakshmi Ramasubramanian , Matthew Garrett , Matthew Wilcox , Michael Kerrisk , =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= , Mimi Zohar , =?UTF-8?Q?Philippe_Tr=c3=a9buchet?= , Scott Shell , Sean Christopherson , Shuah Khan , Steve Dower , Steve Grubb , Thibaut Sautereau , Vincent Strubel , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org References: <20200505153156.925111-1-mic@digikod.net> <20200505153156.925111-4-mic@digikod.net> From: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= Message-ID: <3555aab7-f4e0-80eb-0dfc-a87cfcba5e68@digikod.net> Date: Tue, 5 May 2020 18:55:59 +0200 User-Agent: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Antivirus: Dr.Web (R) for Unix mail servers drweb plugin ver.6.0.2.8 X-Antivirus-Code: 0x100000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/05/2020 17:44, Randy Dunlap wrote: > On 5/5/20 8:31 AM, Mickaël Salaün wrote: >> diff --git a/security/Kconfig b/security/Kconfig >> index cd3cc7da3a55..d8fac9240d14 100644 >> --- a/security/Kconfig >> +++ b/security/Kconfig >> @@ -230,6 +230,32 @@ config STATIC_USERMODEHELPER_PATH >> If you wish for all usermode helper programs to be disabled, >> specify an empty string here (i.e. ""). >> >> +menuconfig OMAYEXEC_STATIC >> + tristate "Configure O_MAYEXEC behavior at build time" >> + ---help--- >> + Enable to enforce O_MAYEXEC at build time, and disable the dedicated >> + fs.open_mayexec_enforce sysctl. > > That help message is a bit confusing IMO. Does setting/enabling OMAYEXEC_STATIC > both enforce O_MAYEXEC at build time and also disable the dedicated sysctl? Yes. What about this? "Define the O_MAYEXEC policy at build time only. As a side effect, this also disables the fs.open_mayexec_enforce sysctl." > > Or are these meant to be alternatives, one for what Enabling this kconfig symbol > does and the other for what Disabling this symbol does? If so, it doesn't > say that. > >> + >> + See Documentation/admin-guide/sysctl/fs.rst for more details. >> + >> +if OMAYEXEC_STATIC >> + >> +config OMAYEXEC_ENFORCE_MOUNT >> + bool "Mount restriction" >> + default y >> + ---help--- >> + Forbid opening files with the O_MAYEXEC option if their underlying VFS is >> + mounted with the noexec option or if their superblock forbids execution >> + of its content (e.g., /proc). >> + >> +config OMAYEXEC_ENFORCE_FILE >> + bool "File permission restriction" >> + ---help--- >> + Forbid opening files with the O_MAYEXEC option if they are not marked as >> + executable for the current process (e.g., POSIX permissions). >> + >> +endif # OMAYEXEC_STATIC >> + >> source "security/selinux/Kconfig" >> source "security/smack/Kconfig" >> source "security/tomoyo/Kconfig" > >