Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1883747ybc; Wed, 20 Nov 2019 05:42:01 -0800 (PST) X-Google-Smtp-Source: APXvYqxeAJx58n+JPnDRTeO6TLdLNmBTTjS6o+7Hx4YxwRJwyYwR61xAoQJCHqtvvjWabJx/OWFL X-Received: by 2002:a17:906:4e53:: with SMTP id g19mr5527244ejw.286.1574257321436; Wed, 20 Nov 2019 05:42:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574257321; cv=none; d=google.com; s=arc-20160816; b=clKREKaW7u+WUsHo8dcYTrGYLRNZ8wk2n0N0K740iPLXAJgDOfLpdidS8ADvu4q3yR FrOK0VOgNnOPgK0AvYu+sB+UQk+oaf2bBkxqBnrsONOlEt+W8udShSk+tTHFM9q2QTyc EyTytxZKnwWqTovhIfp/zjf/eB3HEUjQPbOruOc7Ycu+V7WZf6RMvChDcf/qCrxijGho rQYHaem3QNbvxMKib8VWJDZ1HALH7DUbTQ8qJHJlEB2oszrnY5c09UjJTChn5GiaPXP9 QPIaJ2Uq56ccVk1A9MpBsac7adbjzU2T1dK4RpGUXU3gb7gQEVpJ4pmPaarjP8muWtjg m0Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4qy3FoJtads4GtZW3QGOmRtnWq2Bz6ggTYvEAib3ssM=; b=gLsbuL9evCpgtKy93SrWCCigIQrVMTgJFJjHwusKonTWsk1E4dU2IVyb9uamlZfWA3 w0BHEhlCeRrn/+cwUSJTMAsBqOl7nfhMc2jKlG2/z72qCuBQKs4Ai0Edon+VXwIMqdwQ gMgQ789s9+OvnJYA6TaRkBvUfqZ27C+baUkydN1pb7TUwXStJKPo9onQ+4WHJFJRazhn HZbJUcOH0V03yyLf0nV8HGSIjwtvTC5JFEEKRDEDT5Ao/SdLiKiOqzyCrsuPRU9OOGab tToXyA2Ss5ik5hLTt9aOQD2vLUjYFvI1xII59HNV8BdzeWshc6Fm3+zotkzBgDuv4BO3 fNDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="tBFRoJ/W"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si16289348eja.438.2019.11.20.05.41.36; Wed, 20 Nov 2019 05:42:01 -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; dkim=pass header.i=@kernel.org header.s=default header.b="tBFRoJ/W"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728965AbfKTNNI (ORCPT + 99 others); Wed, 20 Nov 2019 08:13:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:34018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727958AbfKTNNI (ORCPT ); Wed, 20 Nov 2019 08:13:08 -0500 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D761022519; Wed, 20 Nov 2019 13:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574255587; bh=4QxDfTWhfYIfShUTFJUNL5e7kwntUpyWkEOl1iCfVwM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tBFRoJ/WF6PtVpkvzfpadq7Q21oE83R3/+0YLWppJ5Uprf8ZyM+FNehc8utKG01rp G330xEHF3fP5srBsNurWZd61K0s/9/s1MDQ93RQCq7zPwqpOLRdVBhs7n7dBvlzdVA d4ssQ5uDToxXvzRzpRF3zbQMlL/Z6DLsaduA8o2A= Date: Wed, 20 Nov 2019 13:13:03 +0000 From: Will Deacon To: Stephen Smalley Cc: selinux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 2/2] selinux: Propagate RCU walk status from 'security_inode_follow_link()' Message-ID: <20191120131303.GB21500@willie-the-truck> References: <20191119184057.14961-1-will@kernel.org> <20191119184057.14961-3-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stephen, Thanks for the quick review. On Tue, Nov 19, 2019 at 01:46:37PM -0500, Stephen Smalley wrote: > On 11/19/19 1:40 PM, Will Deacon wrote: > > 'selinux_inode_follow_link()' can be called as part of an RCU path walk, > > and is passed a 'bool rcu' parameter to indicate whether or not it is > > being called from within an RCU read-side critical section. > > > > Unfortunately, this knowledge is not propagated further and, instead, > > 'avc_has_perm()' unconditionally passes a flags argument of '0' to both > > 'avc_has_perm_noaudit()' and 'avc_audit()' which may block. > > > > Introduce 'avc_has_perm_flags()' which can be used safely from within an > > RCU read-side critical section. > > Please see e46e01eebbbcf2ff6d28ee7cae9f117e9d1572c8 ("selinux: stop passing > MAY_NOT_BLOCK to the AVC upon follow_link"). Ha, not sure how I missed that -- my patch is almost a direct revert, including the name 'avs_has_perm_flags()'! My only concern is that the commit message for e46e01eebbbc asserts that the only use of MAY_NOT_BLOCK is in slow_avc_audit(), but AVC_NONBLOCKING is used more widely than that. For example: selinux_inode_follow_link() -> avc_has_perm() -> avc_has_perm_noaudit() -> avc_denied() -> avc_update_node() where we return early if AVC_NONBLOCKING is set, except flags are always zero on this path. Will