Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp759687ybg; Sun, 26 Jul 2020 21:21:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwKgiphfBynPTxftpYblHmtJRRJ3k5fZkPPJuwFoB3myK5C251AVHB+rD+2CoF5MhAkh4l X-Received: by 2002:a17:906:aac6:: with SMTP id kt6mr992084ejb.475.1595823711757; Sun, 26 Jul 2020 21:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595823711; cv=none; d=google.com; s=arc-20160816; b=ITRptX+GBHD3/Z1MP2j22pMSRR74DwYYCAoaRfivs4cSVroHpcw7KK8u3BWTvPH8fZ krnRV0FW6RSzvo/8/UPJ0+PS+4mc8vVJ3TE8/wcFul2LVacVodo9Koz+dVejytJ7TcST iahdi6HQaLKHRYlTp+sceGgLcMzD/dmmfwIGuVAluGvb3+GK+/CoKYFdMH6qFSk9Nvbr 7/UCeusI/GMtzvSMLFOfUnWFuinJmYCrX00ZqvYr65n+gJMTmas1ORqDAGQFZzMgYBn5 yhNZWllrk1I5zVv9rbuukSd5KpppzqfGQq0NpfYuCFgg1Y8KhaO0rU43wLQs6Sdairde OwgQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=BXAY40cNCQtxOXLtb8ck0bvh3UlJ0kwcSOOgG9LRRSg=; b=ymnxAKS5cNbBBzUlarolYQt/IZmCOLD4pyuUBZ+bkNIM7Hpm9jPQINPnhdDiPbqaEY GYmVc9N5yjv/42lr/wM7U5bJryAiNgdZsmrYLIZtC4w74JTH8Z3wNodMFSBxIUJ4pqXE jixVmTToHE8xY9mTIPkLkU1c1TeOawCowv9FEuy7goLWOnE9JogELNVc0wzvnYq0zX9G /f4WVqbqo+IxKyULIHpNCWGgH4hZDkz8C86uOAcFLJ1qtw00XsO6/eCYEZjnBfYi2TZQ NjjtnJHQ7CN5MG7Uer7RwZFMCmoKlpFosjwAWCemncACqA1KQH8b7hSukS3RHVbSFSmX asZw== 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 i8si4766762edx.405.2020.07.26.21.21.30; Sun, 26 Jul 2020 21:21:51 -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 S1726263AbgG0EVW (ORCPT + 99 others); Mon, 27 Jul 2020 00:21:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725787AbgG0EVW (ORCPT ); Mon, 27 Jul 2020 00:21:22 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50244C0619D2; Sun, 26 Jul 2020 21:21:22 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jzudO-003Pp0-V8; Mon, 27 Jul 2020 04:21:07 +0000 Date: Mon, 27 Jul 2020 05:21:06 +0100 From: Al Viro To: =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= Cc: linux-kernel@vger.kernel.org, Aleksa Sarai , Alexei Starovoitov , 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 , Mimi Zohar , Philippe =?iso-8859-1?Q?Tr=E9buchet?= , 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, Thibaut Sautereau Subject: Re: [PATCH v7 4/7] fs: Introduce O_MAYEXEC flag for openat2(2) Message-ID: <20200727042106.GB794331@ZenIV.linux.org.uk> References: <20200723171227.446711-1-mic@digikod.net> <20200723171227.446711-5-mic@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200723171227.446711-5-mic@digikod.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 23, 2020 at 07:12:24PM +0200, Micka?l Sala?n wrote: > When the O_MAYEXEC flag is passed, openat2(2) may be subject to > additional restrictions depending on a security policy managed by the > kernel through a sysctl or implemented by an LSM thanks to the > inode_permission hook. This new flag is ignored by open(2) and > openat(2) because of their unspecified flags handling. When used with > openat2(2), the default behavior is only to forbid to open a directory. Correct me if I'm wrong, but it looks like you are introducing a magical flag that would mean "let the Linux S&M take an extra special whip for this open()". Why is it done during open? If the caller is passing it deliberately, why not have an explicit request to apply given torture device to an already opened file? Why not sys_masochism(int fd, char *hurt_flavour), for that matter?