Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp963522imj; Fri, 15 Feb 2019 09:40:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IZsCN2kOJIiD8A0OUzzZFxJDdLO1FaerTPWg3UT8K9K9zcUW/IOP5hMIvE/gTA3wywDlZ98 X-Received: by 2002:a62:e519:: with SMTP id n25mr10838789pff.151.1550252434333; Fri, 15 Feb 2019 09:40:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550252434; cv=none; d=google.com; s=arc-20160816; b=F5KtzyACVXRu3f+wjqWV4MzWSmxWoVzFEQRejDEh4UDJLB84nM+joIqy/6bILfXMif ruktD/Nd/Z8BxR7YtyQI3qRc7SB+nQbKC8OGquqd3gXP/MgvNjzeII2Hvee1g/i3xEKB zzlJCvGbLsh2d9KKFqoAwlV7RXubxU7AIjHTN0DaJBqTZUvdJzgl42EcG2bZngajI3QB X4hwhsfscj1QXZYzWJ8D13fk3q92cyz0SyYs+OV+GTpLzuxJb7IvCt2u8th5cQUPoJFB ptQg7B1rf1HtVOTFF//Y5ih41Jmjy8dUmzWHcnGMdeze3e7TKCMjvzl0q2+/yJA1MaZ9 PjYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization; bh=xl0dr3NWSlSDIcJ/ELIli9/LhlxisTa8BQ0KCYomGy8=; b=rDPZ2BmZfeNw1bxGCl0u4/+gl+D3c3Xw+cfWWY5HrP1UtTQZ1YiHfnMwoR+0EwCdly LbD6DLxlrggYJwgDcDH77SJPlM4xbwAH2C4JnLMIMj14v9vKfafKfHuFv53mnGU49Kw6 7sJmVhKdEu8zWx2NxaTYxN5igLJHSiipAZlmf/E3dEPG0U70f4UDroTc28D20HZuEQ1Y cxI4ZbRr+UX+rBnPa4BmMvc6Tv6X4Nnjn9qcaG07BnphLO0HdMVpVZxZbyx4ywqSypJy XnOXC9qPmIbrvJIEw0P5TABZsd/AiCM3Z99b0ZekwCDTHies1U7J52IHkTO4b4Cr3QfI +Qjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1si3879460pls.326.2019.02.15.09.40.18; Fri, 15 Feb 2019 09:40:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729898AbfBORjf convert rfc822-to-8bit (ORCPT + 99 others); Fri, 15 Feb 2019 12:39:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57708 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbfBORje (ORCPT ); Fri, 15 Feb 2019 12:39:34 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6BEE1C0D8047; Fri, 15 Feb 2019 17:39:33 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-121-129.rdu2.redhat.com [10.10.121.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF9895C3FD; Fri, 15 Feb 2019 17:39:20 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <758871dc-15b7-ed5c-a119-a40037309507@tycho.nsa.gov> References: <758871dc-15b7-ed5c-a119-a40037309507@tycho.nsa.gov> <155024683432.21651.14153938339749694146.stgit@warthog.procyon.org.uk> <155024709026.21651.7275876165845045967.stgit@warthog.procyon.org.uk> To: Stephen Smalley Cc: dhowells@redhat.com, keyrings@vger.kernel.org, trond.myklebust@hammerspace.com, sfrench@samba.org, linux-security-module@vger.kernel.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, rgb@redhat.com, linux-kernel@vger.kernel.org, Paul Moore , SELinux Subject: Re: [RFC PATCH 22/27] KEYS: Replace uid/gid/perm permissions checking with an ACL MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <32622.1550252354.1@warthog.procyon.org.uk> Content-Transfer-Encoding: 8BIT Date: Fri, 15 Feb 2019 17:39:14 +0000 Message-ID: <32623.1550252354@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 15 Feb 2019 17:39:34 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Stephen Smalley wrote: > > --- a/security/selinux/hooks.c > > +++ b/security/selinux/hooks.c > > @@ -6560,6 +6560,7 @@ static int selinux_key_permission(key_ref_t key_ref, > > { > > struct key *key; > > struct key_security_struct *ksec; > > + unsigned oldstyle_perm; > > u32 sid; > > /* if no specific permissions are requested, we skip the > > @@ -6568,13 +6569,26 @@ static int selinux_key_permission(key_ref_t key_ref, > > if (perm == 0) > > return 0; > > + oldstyle_perm = perm & (KEY_NEED_VIEW | KEY_NEED_READ | KEY_NEED_WRITE > > | > > + KEY_NEED_SEARCH | KEY_NEED_LINK); > > + if (perm & KEY_NEED_SETSEC) > > + oldstyle_perm |= OLD_KEY_NEED_SETATTR; > > + if (perm & KEY_NEED_INVAL) > > + oldstyle_perm |= KEY_NEED_SEARCH; > > + if (perm & KEY_NEED_REVOKE && !(perm & OLD_KEY_NEED_SETATTR)) > > + oldstyle_perm |= KEY_NEED_WRITE; > > + if (perm & KEY_NEED_JOIN) > > + oldstyle_perm |= KEY_NEED_SEARCH; > > + if (perm & KEY_NEED_CLEAR) > > + oldstyle_perm |= KEY_NEED_WRITE; > > + > > sid = cred_sid(cred); > > key = key_ref_to_ptr(key_ref); > > ksec = key->security; > > return avc_has_perm(&selinux_state, > > - sid, ksec->sid, SECCLASS_KEY, perm, NULL); > > + sid, ksec->sid, SECCLASS_KEY, oldstyle_perm, NULL); > > This might be ok temporarily for compatibility but we'll want to ultimately > define the new permissions in SELinux and switch over to using them if a new > policy capability bit is set to indicate that the policy supports them. We > should probably decouple the SELinux permission bits from the KEY_NEED_* > values and explicitly map them all at the same time. Sounds reasonable. I should probably detach the first two ACL patches from the set and push them separately. David