Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1881463ybc; Wed, 20 Nov 2019 05:39:52 -0800 (PST) X-Google-Smtp-Source: APXvYqy5ymkr0CPNnvDeKFpp4YbxKiskkHzvfqI6MUvPOpTQ2FE0OQWMFpO0PlYPCHrUjs7LkAZ5 X-Received: by 2002:a17:907:4300:: with SMTP id oa24mr5520291ejb.8.1574257191969; Wed, 20 Nov 2019 05:39:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574257191; cv=none; d=google.com; s=arc-20160816; b=V7qLEDA+qn3t9NRV5C5e18AjWZkrFPHtP2422R4SO7DNM9FWt1VSbEbjRchJ0vy2la eOV9XiUuj26zH9IsdrWrvtu5gOL2JplnP33y8bjthDoc+Q/CGf1aMoDxYtBc9Bgpic+R v3clnxubwbEyTsq0BIzhpRifzuIWg8V61pbtQIK894byiIwMBTb6V+eS6NWOJIhIRRwV eqHK6Of0rXTExGR745c5Tz+6a9Agyw8yCoj6FAworcZqfiUOBo3K9USgxy5cCvofU9gS lAfU87DKUh8N4Ia03fWPxu/cxczxGHVJxYNeq5gdWwg4NgLeAGK90lrOFhtYU5cB0xor u7hg== 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=epkJx0pvQxgDd2Jj9qVnhJ45xjDP9YxoseTKBjwVyog=; b=uDsBXt+tBJy/dBybn9Ez3+pfrAPCSCqvf0qyuS4HCiZWmG1SFEERAFe0fqvNd1PYcz 2LJiZ2/yVJlMhQm4jZSItv2+slWW0SP0SAaKkxfv/FCBvEowLRUcfH4W3wgx98mFVbAY 9Otkh7mjHmC99wcBAcn/5C1r7Ezz5Sa3yyX7bUbMQeoTuqcjZgR9TLmhDoxFZ2idvMY4 1n/8KRZt61UIXSHQKahrG691/5xEkiao6u5D5AVOiCxf4lJMFWtM1ILCbA/jhWC9JOUn vdMumfxb4t+A9hqrNv8kWEhjATeKpcvn1EBhTZRYjdMke5jT+vtcyVuyW3r93VucEDyw t61A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="pdvavX/a"; 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 b17si18097339edj.417.2019.11.20.05.39.27; Wed, 20 Nov 2019 05:39:51 -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="pdvavX/a"; 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 S1728267AbfKTNMf (ORCPT + 99 others); Wed, 20 Nov 2019 08:12:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:33904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727958AbfKTNMf (ORCPT ); Wed, 20 Nov 2019 08:12:35 -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 DFCFA22519; Wed, 20 Nov 2019 13:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574255554; bh=Y1YHQvbgqBVBtYfXoF968NFfUCGRtYRaQ43ufvzwMQs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pdvavX/auzZdjuvYtAjnH7kGUHtTRVMH9RMGBCtfUp/dqm7hOuVcoXzICSr+4KR0X k+nzkC7879TNvYXHP9DvftbfnqeOGzK6+67GMqnl4NTsBdP5WtE5+VpNXlSY/GBk2/ z8P65MllnB3+r6jPfIVRXO0FujcJWL/TDXoOsIHI= Date: Wed, 20 Nov 2019 13:12:30 +0000 From: Will Deacon To: Stephen Smalley Cc: selinux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 1/2] selinux: Don't call avc_compute_av() from RCU path walk Message-ID: <20191120131229.GA21500@willie-the-truck> References: <20191119184057.14961-1-will@kernel.org> <20191119184057.14961-2-will@kernel.org> <5e51f9a5-ba76-a42d-fc2b-9255f8544859@tycho.nsa.gov> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5e51f9a5-ba76-a42d-fc2b-9255f8544859@tycho.nsa.gov> 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 reply. On Tue, Nov 19, 2019 at 01:59:40PM -0500, Stephen Smalley wrote: > On 11/19/19 1:40 PM, Will Deacon wrote: > > 'avc_compute_av()' can block, so we carefully exit the RCU read-side > > critical section before calling it in 'avc_has_perm_noaudit()'. > > Unfortunately, if we're calling from the VFS layer on the RCU path walk > > via 'selinux_inode_permission()' then we're still actually in an RCU > > read-side critical section and must not block. > > avc_compute_av() should never block AFAIK. The blocking concern was with > slow_avc_audit(), and even that appears dubious to me. That seems to be more > about misuse of d_find_alias in dump_common_audit_data() than anything. Apologies, I lost track of GFP_ATOMIC when I reading the code and didn't think it was propagated down to all of the potential allocations and string functions. Having looked at it again, I can't see where it blocks. Might be worth a comment in avc_compute_av(), because the temporary dropping of rcu_read_lock() looks really dodgy when we could be running on the RCU path walk path anyway. Will