Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp4428863imm; Mon, 25 Jun 2018 15:50:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIKa+kHRiVJs1Ru7nbzOyNIA2qmbJlT82sCgL6EWTsknxpAdfI5/vjX+4VYex+FF+ZiKLUc X-Received: by 2002:a17:902:5991:: with SMTP id p17-v6mr13981129pli.191.1529967047824; Mon, 25 Jun 2018 15:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529967047; cv=none; d=google.com; s=arc-20160816; b=IXzFXsNFsYugNYrBwpf0M2EG64RhO4D/tNaXI5dtfTX0tJoyblvt3mj7rB2AZdi/Do 3165EtmXP51Ohjof6UETt6s5vFXXkzuAZOVS/DPUJTONX9XAQkDsM4hA7QVVasHRs/wM qVdErYvttgt129sy67WKhduoYNKmY3gLHTcFeTSbw1mx9LGjeWghYdcIA/5RdKUq2/f6 OEjI26EY8r2Hle63NeP1OWBQ4tcpwmsXj6bhg9WdoJ64DKuwKwLQIITdgFRpF94IrYBl YhRqBaP7Xtaaa7oeNfIu4tzB46DRDO0fLA1tpiuAwdgYP0tSEdYsp8nTq/KIkBJ4dZvH S5kQ== 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=v7gsdRJHMHZ0qJzG/sa03VJYQh7eFitNZlue94uW47M=; b=UtOS70/rcgmmPzsiZ6PgX/TH6bZokbsYPdSSBEOhb6ulfVbq0bE8ablMo/AScxL5op wqKrcGl9u8X54NmW6fop0txieinzayLlkbBDyDBe319l6QQDZtVjwRO70s8ZZ3h84a2a PgR4xpG78uCx5TM2Ks0qvIqjxpb3MK2Il0XC1qiqMQj2vxfIlmG2pgleR9aYqsL7AQyK yG3UKZNDAJCiM3JSQcmFOd6n4cgQ3DcpmiuwboqP52MW5WrhuUaoywXRDkEhPfY8uQMr yNjUVPi0LdzYsSZl7AK2o1l0kLPkeRmTv+T7P8wrQtqJ0BhRkdnqiwxBbF2W/DbbXSAR M64g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DSwVpy7I; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k138-v6si107621pfd.23.2018.06.25.15.50.33; Mon, 25 Jun 2018 15:50:47 -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=@google.com header.s=20161025 header.b=DSwVpy7I; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932544AbeFYWlD (ORCPT + 99 others); Mon, 25 Jun 2018 18:41:03 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:45575 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754551AbeFYWk7 (ORCPT ); Mon, 25 Jun 2018 18:40:59 -0400 Received: by mail-oi0-f65.google.com with SMTP id 188-v6so14083558oid.12 for ; Mon, 25 Jun 2018 15:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=v7gsdRJHMHZ0qJzG/sa03VJYQh7eFitNZlue94uW47M=; b=DSwVpy7IMsurMgskQoKtPDi0GqSEAYCrfQNBGtUzOjf2wNd/HkwpL/1t4gMIGgLUxU VgeJUzATHsEHspeDIlGjRj1YV1ObrNtT5qHdX7CT8uR+nMs7NC/L9KXN6mAdk5ha+Mz0 9c7VSA685U10kV/v5dFuxDFlfKHuRXc1RVdx74syBLgTyxxTIaYh4hTFtayqWX3B/oSW aPTFaPvDQA6VWTp4mXDNb1sLQCBmMQnBhUuBSnfiFo01S1zxbEfprBOtuQsl2Dxs4QHV pr3obs8wtsPhI336XSttFC6NLwcip/Z06HrBDn195z5MSnH7wxX5GOUQuUn7zKzuagA7 AkYg== 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=v7gsdRJHMHZ0qJzG/sa03VJYQh7eFitNZlue94uW47M=; b=l3GFGEPgHxYdUJycEUrXAs9Zsi1XdSZUPMj8XkRtHCuN+1cnn7cnvipe43oS47XmhR 0HmEfAviBv1beoFBXzlTAaryhXw6ib+gd0Vk2EGOPpUxsOvuGzzoa4Sf/rjAxRqpycV+ JvlppvkTQFTVv6WVZK4d42Ah+6LWiummp2aF0vs91FlRYQwuIEqdF7jp348kH9SEsoXX 4IO4kJXYqtxmHnRUzXjavubws+CxoruBM1TiqyuePg4Ml6SQYLsJeMkAu+vBYf58eEl9 KKBcsLZcjOpVEl52Ajg9WqOLYWGOr44ZT7Fd2N54cfCKLGnhu3+o+Woge6aCPwOMLqKX QjCA== X-Gm-Message-State: APt69E3CHuuBPOVFSwWUr7C9BaAdF8G12CwFAzdLM1T+h5nN8A5XPAtw aZO4ndpWxqw+2Ia93ohKYqjo5zKqDcgwJD3PsJTNKA== X-Received: by 2002:aca:5bd5:: with SMTP id p204-v6mr8479093oib.91.1529966458338; Mon, 25 Jun 2018 15:40:58 -0700 (PDT) MIME-Version: 1.0 References: <20180625163425.216965-1-jannh@google.com> In-Reply-To: From: Jann Horn Date: Tue, 26 Jun 2018 00:40:46 +0200 Message-ID: Subject: Re: [PATCH] selinux: move user accesses in selinuxfs out of locked regions To: Paul Moore Cc: Stephen Smalley , Eric Paris , selinux@tycho.nsa.gov, security@kernel.org, kernel list 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 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.