Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1271426ybh; Thu, 16 Jul 2020 07:44:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztgUCds9CtKFilg0o3iHCKTJ4M0EsRSdStiye9g1di1lO4DXUQpsa1livEFCRRxsMKCS4t X-Received: by 2002:a17:906:7d9:: with SMTP id m25mr3945913ejc.25.1594910680219; Thu, 16 Jul 2020 07:44:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594910680; cv=none; d=google.com; s=arc-20160816; b=iov10Wra+Z2rsOLSYrsjWY6WY6xwoEN5PHONsJoQ4fVf0ijCikgr8C6H5C2px37xa6 rfsIsvsU6sSYXgLzOoI2hkltVH76dJNcG16w5afUowyLFrqOSnTrV5UZZriOJQl7wWTt O9fgM2pzSDbb3iQhLjTo3kmpxE+2KXU//TVfsZWO9Yahtv8hUpEgiLpGEHGCWUXukFVx LDDaxa/soTl3smtnQkQKaQEu0vlDvd4hA9QO41leRCYGnvXsLm326lsprB5GkS6kIGGR cir6CA32CW3fOXO/fWcTwB68LLOryNFfFM6QDmiA1auh/p2JrdI/+lWpSo2QZyAKm6Ml M4Vw== 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=ZpDuN8tyUC7GIYYZvGwk4YsRFDOt00g+gbJEk1sKQ1s=; b=GqpdTnsQ9o28iZJy/qFvj9VXyX9aUELdH/LvP4A6PnGi8Ckl/zXGwwDoWmiJ+HfVM+ zkI+U3ok6FdsOnOcmXvzh/6w3LDDVbdXcvrL5tO6nZyponnvEvL/XDPMxZFl0n2H0Wtd Mv9tDHCun3RxGhNeqnIAAaHGDaGmEC4KljvQGJ1JoCS1WeqIpu/V9td0w/AsDzAda4mj cGQxHxPvbMpcXCjg+GFzSk9WHifi4NH4PAZWtDlBxfhEclOuUwEarUQjEbxOuBjxkdvU ih0ZWRANeDeSVJDY40yVAXTJnZd5MJO4e6XJVRWzq1gxGj5emsX39RAcKrHRDaV5USnj n9OA== 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 e1si3308169ejb.286.2020.07.16.07.44.17; Thu, 16 Jul 2020 07:44:40 -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 S1728776AbgGPOle (ORCPT + 99 others); Thu, 16 Jul 2020 10:41:34 -0400 Received: from smtp-190a.mail.infomaniak.ch ([185.125.25.10]:55913 "EHLO smtp-190a.mail.infomaniak.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728316AbgGPOld (ORCPT ); Thu, 16 Jul 2020 10:41:33 -0400 Received: from smtp-2-0001.mail.infomaniak.ch (unknown [10.5.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4B6xl11VDMzlhbhx; Thu, 16 Jul 2020 16:41:01 +0200 (CEST) Received: from ns3096276.ip-94-23-54.eu (unknown [94.23.54.103]) by smtp-2-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4B6xkx3gxBzlh8TS; Thu, 16 Jul 2020 16:40:57 +0200 (CEST) Subject: Re: [PATCH v6 5/7] fs,doc: 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 , Andrew Morton , Andy Lutomirski , Christian Brauner , Christian Heimes , Daniel Borkmann , Deven Bowers , Dmitry Vyukov , Eric Biggers , 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 , Tetsuo Handa , 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: <20200714181638.45751-1-mic@digikod.net> <20200714181638.45751-6-mic@digikod.net> <038639b1-92da-13c1-b3e5-8f13639a815e@infradead.org> From: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= Message-ID: <67fe6c17-a0b3-5c7e-a7c8-4c2b6e0c0592@digikod.net> Date: Thu, 16 Jul 2020 16:40:56 +0200 User-Agent: MIME-Version: 1.0 In-Reply-To: <038639b1-92da-13c1-b3e5-8f13639a815e@infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: fr 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 14/07/2020 20:40, Randy Dunlap wrote: > Hi, > > On 7/14/20 11:16 AM, Mickaël Salaün wrote: > >> --- >> Documentation/admin-guide/sysctl/fs.rst | 45 +++++++++++++++++++++++++ >> fs/namei.c | 29 +++++++++++++--- >> include/linux/fs.h | 1 + >> kernel/sysctl.c | 12 +++++-- >> 4 files changed, 80 insertions(+), 7 deletions(-) >> >> diff --git a/Documentation/admin-guide/sysctl/fs.rst b/Documentation/admin-guide/sysctl/fs.rst >> index 2a45119e3331..02ec384b8bbf 100644 >> --- a/Documentation/admin-guide/sysctl/fs.rst >> +++ b/Documentation/admin-guide/sysctl/fs.rst > > Reviewed-by: Randy Dunlap > > with one tiny nit: > >> @@ -165,6 +166,50 @@ system needs to prune the inode list instead of allocating >> +The ability to restrict code execution must be thought as a system-wide policy, >> +which first starts by restricting mount points with the ``noexec`` option. >> +This option is also automatically applied to special filesystems such as /proc >> +. This prevents files on such mount points to be directly executed by the > > Can you move that period from the beginning of the line to the end of the > previous line? OK, done. Thanks! > >> +kernel or mapped as executable memory (e.g. libraries). With script >> +interpreters using the ``O_MAYEXEC`` flag, the executable permission can then >> +be checked before reading commands from files. This makes it possible to >> +enforce the ``noexec`` at the interpreter level, and thus propagates this >> +security policy to scripts. To be fully effective, these interpreters also >> +need to handle the other ways to execute code: command line parameters (e.g., >> +option ``-e`` for Perl), module loading (e.g., option ``-m`` for Python), >> +stdin, file sourcing, environment variables, configuration files, etc. >> +According to the threat model, it may be acceptable to allow some script >> +interpreters (e.g. Bash) to interpret commands from stdin, may it be a TTY or a >> +pipe, because it may not be enough to (directly) perform syscalls. > > thanks. >