Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp417502imm; Thu, 28 Jun 2018 23:29:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLtchyfhwyVqo/teaRoGs0RElpgIItzzmhb71WYsTfls0J2xAwGp16qVMgolwbF3EQYqrHj X-Received: by 2002:a63:2a45:: with SMTP id q66-v6mr11610147pgq.210.1530253774909; Thu, 28 Jun 2018 23:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530253774; cv=none; d=google.com; s=arc-20160816; b=KL70xifOdVTRwyoNJK8+LBmsFT4zGgdyJcR2+aUGfIOHVCL+7qLfO7Cf8lbExm1MaX gm0xE/E8HnL7sOuhkiQBtySsJiTPr+hwrbbox1bwlZTXQPsqeQWgs/2MjJQKAgudza5P KPUK3aiT8t490X2zrCgLAJOuY4XMAo5dXiFj8xqUJ9oZkwd086RKPG9XrbOE1VEJ06AE ppmZWa5SxErhcLdWQisCo9rVw/byZhLrq8RRsPZtLbnrbNz6f3D1s1RmvIapSG6Cqeg6 SHobe5TWQZHDzgMeHgWY+wXzuDfgY1VaqjN/VjryIbgek/ajcvOJ0eDql5xt5PaOhmJi jeCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=l5lIhXn+YcbXhTMyNHVcwsHNlgMtLgqJIEVuvH/OxG4=; b=KIajH+V0B0ZgTyTScJdHxHlNRH6c8KIqxX6WzyxWv12HZlQeq47a+6DsLcz0tQa6yE ZfVPFFft7XQAE04EM5kR0ZEfPTITFueGLheZQOmhPypDESwfpOt+pDDAJjIQey5EE2zQ 5KDiTQLA0XQN2HKY08fr1Z7xnsmGrKYGNMqpK8MDoFVhRx1XTX2YEna6naqoCXHQ3zoy B6kK6kW9izK9EUhY89dWJ3FkNLo6d0X84E/4fkZTBhFD+DhaksKrzdktnnZ6IJrvVaYF p54z4s5KC5BNjFX6+BwoatB3PnZyNUL5EqtMLj7dRY4vRVYufN0TzsNKg7IRWJOGpLCZ 7sDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=ec5BmhFU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g65-v6si8688112pfc.330.2018.06.28.23.29.20; Thu, 28 Jun 2018 23:29:34 -0700 (PDT) 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=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=ec5BmhFU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935382AbeF2APl (ORCPT + 99 others); Thu, 28 Jun 2018 20:15:41 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:45807 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933682AbeF2APk (ORCPT ); Thu, 28 Jun 2018 20:15:40 -0400 Received: by mail-lj1-f193.google.com with SMTP id g3-v6so5890641ljk.12 for ; Thu, 28 Jun 2018 17:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=l5lIhXn+YcbXhTMyNHVcwsHNlgMtLgqJIEVuvH/OxG4=; b=ec5BmhFUfkzg4wCSm8j/ClvKM6UjnE34823GsKSqx6NUFm8Euw+0nzOWSoXjYl3nnh 8JrmYRyTremLSeNBmbryjEK3Css+Z5xWP9TL0C+YTV1oqYozpYZgO++I59IB5TU65O3q zf6qf8PNQER2iiXepBx4Thdxo2lygiHLoVZ7QXRMRQMfXL5JjON+16OohDINDRmYa7sR YFAVhe3Cpy5HJMjiVp7nbh9o8c25+2EgpWQ7Wy96vjg3K1G0ot4aQ1we19E1REjW/D1C YVndNh//faPeYJocHeUTa0Tjq18OMhyfttJy9+krc14o50SJYX3lllAnxkEu9kSP8ciH uwnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=l5lIhXn+YcbXhTMyNHVcwsHNlgMtLgqJIEVuvH/OxG4=; b=nP6dr7v33eSJ7izfTbU3yCs+BtN6oLVfNv5vbDO6ZjNrD4bSGH8wPqyhtMQxwnCDgX 0ZjiJzLNDpuVnjQyLmv45tee3U52phahrmwpFzhoJLLrEiExRsoNBn6mbJOaMYr3o/as XDz0dX0TQgT/DLmEoUe9lIu443zjOJ5nFogmIXNhXQFlFvgzGQF5b+3mAhn5BrOdGqIX cCjfmaXdcYLmgkBkQsPEfkdSWOeY/Y7QV0/9UNLo3Cm3PLwbilXmxNVvOReHDgbPwNJ3 CZHAe5vgjvO+6+lqSe0I9t9GLRBTm8wBA5pi6M/ngjAjVnn2pwKNrX0RGxAI0ELRzfiL L8MQ== X-Gm-Message-State: APt69E2mpL5N51RQMUQueF/v+N71zCcU0DYZYNaYJxYpBWIGKwkfqmEI RaSZFo0vtWLL9ENh5rOA0pUPUW4jJNXjoYzZ7c02 X-Received: by 2002:a2e:29da:: with SMTP id p87-v6mr6861851ljp.12.1530231338880; Thu, 28 Jun 2018 17:15:38 -0700 (PDT) MIME-Version: 1.0 References: <20180625163425.216965-1-jannh@google.com> In-Reply-To: From: Paul Moore Date: Thu, 28 Jun 2018 20:15:27 -0400 Message-ID: Subject: Re: [PATCH] selinux: move user accesses in selinuxfs out of locked regions To: jannh@google.com Cc: Stephen Smalley , Eric Paris , selinux@tycho.nsa.gov, security@kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 25, 2018 at 6:40 PM Jann Horn wrote: > > On Tue, Jun 26, 2018 at 12:36 AM Paul Moore wrote: > > > > On Mon, Jun 25, 2018 at 12:34 PM Jann Horn wrote: > > > If a user is accessing a file in selinuxfs with a pointer to a userspace > > > buffer that is backed by e.g. a userfaultfd, the userspace access can > > > stall indefinitely, which can block fsi->mutex if it is held. > > > > > > For sel_read_policy(), remove the locking, since this method doesn't seem > > > to access anything that requires locking. > > > > Forgive me, I'm thinking about this quickly so I could be very wrong > > here, but isn't the mutex needed to prevent problems in multi-threaded > > apps hitting the same fd at the same time? > > sel_read_policy() operates on a read-only copy of the policy, accessed > via ->private_data, allocated using vmalloc in sel_open_policy() via > security_read_policy(). As far as I can tell, nothing can write to > that read-only copy of the policy. None of the handlers in > sel_policy_ops write - they just mmap as readonly (in which case > you're already reading without locks, by the way) or read. Great, thanks. -- paul moore www.paul-moore.com