Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4055346pxk; Tue, 8 Sep 2020 09:31:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzihbFwT+Tp4/rEVtD7H1MX8IP6SX2DYhLuQmRejwrcnat6vjTmKmM8Xk1zIziCVJOi86ON X-Received: by 2002:a17:906:b090:: with SMTP id x16mr26546019ejy.46.1599582689148; Tue, 08 Sep 2020 09:31:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599582689; cv=none; d=google.com; s=arc-20160816; b=tFxeTDxcHPtaFIyszf7eJpkBCtNiYal5s1GF+p6mitShdnO4S8oIRiZfWOjB6G81Lu hl1MovqZvQvs4EAvhHJzknY2Mo9Fzune/WY3/ve720LOAxVjvuBB5UOWZRGw+fZy5Syt ih9w/nGcFGd/AnWdC1CJYgamrZufeJJ2Zj+J+uKGzQACHKst500Z0okOSAdAswb82ly7 5y6C+MoOWaOUiKbvz2YPc2lcm7wLSYOK1bwn+kB3dyHJdaM+F/7NLi7LMOUI1wecjjN/ /gWoALINS1TUE/gLJgPGaXBfdbK51zK6D0wfmnoEYvVL65ewlX702GkWoK8aQFq29ySx zI0w== 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=8hati0hj0DwyVl1l09gszaqlVX4I6lELnUlZnWa/Srk=; b=XskfOtWxxF6Fdiq8I9VjH/TIXY/rroAwjP97cJngg6Fg+xSpu+glrTQeFcleLUxxiD 1CQ02HT/vqrC4eV/08DDP2dWskEo1npTuzzEeDWYiiiKXhkXEV+KvzvMltdrUqDhbhKR Pd0+VJ0sqOOTRXELsbOr56ra99ixoaNIY2gosYEsDP8Z7/jQfuItQylSBtnyUvDm/xl1 XZvUIB+8IGv/PZQz2nTJGGL5tF+bLeivqyEfEWlHPN4PXkDDZRdVoahMF58OalXqLlqG QbhMDG2rjXEzFaKYhb47SovWO7f0zJqUTauUUzVtgzD06TrPVL0LoPXh6cYmrQgKj7Jc kgXg== 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 h23si12365077ejt.510.2020.09.08.09.31.06; Tue, 08 Sep 2020 09:31:29 -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 S1731581AbgIHQaO (ORCPT + 99 others); Tue, 8 Sep 2020 12:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731929AbgIHQ1O (ORCPT ); Tue, 8 Sep 2020 12:27:14 -0400 Received: from smtp-190f.mail.infomaniak.ch (smtp-190f.mail.infomaniak.ch [IPv6:2001:1600:3:17::190f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0D25C0610EA for ; Tue, 8 Sep 2020 07:14:47 -0700 (PDT) Received: from smtp-3-0000.mail.infomaniak.ch (unknown [10.4.36.107]) by smtp-2-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4Bm6bc3HDJzlhTgZ; Tue, 8 Sep 2020 16:14:36 +0200 (CEST) Received: from ns3096276.ip-94-23-54.eu (unknown [94.23.54.103]) by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4Bm6bY253dzlh8TH; Tue, 8 Sep 2020 16:14:33 +0200 (CEST) Subject: Re: [RFC PATCH v8 1/3] fs: Introduce AT_INTERPRETED flag for faccessat2(2) To: Stephen Smalley , Mimi Zohar Cc: linux-kernel , 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 , Miklos Szeredi , =?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, LSM List , Linux FS Devel , Thibaut Sautereau , =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= , John Johansen References: <20200908075956.1069018-1-mic@digikod.net> <20200908075956.1069018-2-mic@digikod.net> <75451684-58f3-b946-dca4-4760fa0d7440@digikod.net> From: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= Message-ID: <532eefa8-49ca-1c23-1228-d5a4e2d8af90@digikod.net> Date: Tue, 8 Sep 2020 16:14:32 +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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/09/2020 15:42, Stephen Smalley wrote: > On Tue, Sep 8, 2020 at 9:29 AM Mimi Zohar wrote: >> >> On Tue, 2020-09-08 at 08:52 -0400, Stephen Smalley wrote: >>> On Tue, Sep 8, 2020 at 8:50 AM Stephen Smalley >>> wrote: >>>> >>>> On Tue, Sep 8, 2020 at 8:43 AM Mickaël Salaün wrote: >>>>> >>>>> >>>>> On 08/09/2020 14:28, Mimi Zohar wrote: >>>>>> Hi Mickael, >>>>>> >>>>>> On Tue, 2020-09-08 at 09:59 +0200, Mickaël Salaün wrote: >>>>>>> + mode |= MAY_INTERPRETED_EXEC; >>>>>>> + /* >>>>>>> + * For compatibility reasons, if the system-wide policy >>>>>>> + * doesn't enforce file permission checks, then >>>>>>> + * replaces the execute permission request with a read >>>>>>> + * permission request. >>>>>>> + */ >>>>>>> + mode &= ~MAY_EXEC; >>>>>>> + /* To be executed *by* user space, files must be readable. */ >>>>>>> + mode |= MAY_READ; >>>>>> >>>>>> After this change, I'm wondering if it makes sense to add a call to >>>>>> security_file_permission(). IMA doesn't currently define it, but >>>>>> could. >>>>> >>>>> Yes, that's the idea. We could replace the following inode_permission() >>>>> with file_permission(). I'm not sure how this will impact other LSMs though. >> >> I wasn't suggesting replacing the existing security_inode_permission >> hook later, but adding a new security_file_permission hook here. >> >>>> >>>> They are not equivalent at least as far as SELinux is concerned. >>>> security_file_permission() was only to be used to revalidate >>>> read/write permissions previously checked at file open to support >>>> policy changes and file or process label changes. We'd have to modify >>>> the SELinux hook if we wanted to have it check execute access even if >>>> nothing has changed since open time. >>> >>> Also Smack doesn't appear to implement file_permission at all, so it >>> would skip Smack checking. >> >> My question is whether adding a new security_file_permission call here >> would break either SELinux or Apparmor? > > selinux_inode_permission() has special handling for MAY_ACCESS so we'd > need to duplicate that into selinux_file_permission() -> > selinux_revalidate_file_permission(). Also likely need to adjust > selinux_file_permission() to explicitly check whether the mask > includes any permissions not checked at open time. So some changes > would be needed here. By default, it would be a no-op unless there > was a policy reload or the file was relabeled between the open(2) and > the faccessat(2) call. > We could create a new hook path_permission(struct path *path, int mask) as a superset of inode_permission(). To be more convenient, his new hook could then just call inode_permission() for every LSMs not implementing path_permission().