Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1159918pxk; Mon, 31 Aug 2020 11:24:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3UIcJVAD4N3PDifg5VdDbqs4Cv+GPlmXd425hwKRBmny21qCwpq62q7f9Ef81WU/UQ0pH X-Received: by 2002:a17:906:46c2:: with SMTP id k2mr2314073ejs.448.1598898259822; Mon, 31 Aug 2020 11:24:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598898259; cv=none; d=google.com; s=arc-20160816; b=RhumlJlGbm/xkgHigWG6MT0l1w3hV8PC864ci9/+Hl0RIw2KjqlXI/OSWupuBvLpCn JIIhathMOxz/i+k5XF5t7KkytKwPZ7eqqdLLD/HRNEtCbxxr8LEa+m+FpQHzm5grnU11 4qzXq/fs4xHcXscZ+yS11ZnQNXgdz+yNx+yAslNUVNpDGpGWlCLvbKfxCAVrtPDk2Vrl exDdqKoTg+jt2FUhCY/zrlsEoeeT9GFpZmAtLNRG2DkHFHFje1r4FIAIU0QYONmeVgKG 2SfhURUzS6WU8I6MpOSTF50MukUtFLkLIJN0tvtkUjqrF3ymeGgdOz7HPqr5yhamUiah hOZA== 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; bh=X3QYc0qUilro/bdxtUXo+KBifJgEgJArvSnQjd2oRO8=; b=ZQcxJKpnwmFj4VmUzVqNUT8BjM05di7GhnA7R1UoiBe9bvo/O3EHQ/byyxrBzqWsHs IoWf3IY/CujBlKuDaH3kRMvxJeglJ9HKLK6g1YGSljp2lQtAx0apbz4N3Bui+ZvVW5cs ZshrNrLRBAn9XeQ6BHNw+nN19eKgpqFw11E5zZ0qpWGEzxKZ8eeFMOtlffja8ep4oNGF /ZnCOGNnO+6A4GJDxAQ+WykhzFSYJYKQIykHcBkxDvriOMUbL1BvTEaakQLlEIhccg6P t6mFDMBw9l+r59y9pZX2pDWD5Gw625S3lp6vbhmEs9L4RgbG5J+onQcPaQ+ev5qb9WI7 YFig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=NZoNODsK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id x14si5439753edv.549.2020.08.31.11.23.57; Mon, 31 Aug 2020 11:24:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=NZoNODsK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1729883AbgHaSVw (ORCPT + 99 others); Mon, 31 Aug 2020 14:21:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729043AbgHaSVu (ORCPT ); Mon, 31 Aug 2020 14:21:50 -0400 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28C98C061573 for ; Mon, 31 Aug 2020 11:21:50 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id t13so2009486ile.9 for ; Mon, 31 Aug 2020 11:21:50 -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=X3QYc0qUilro/bdxtUXo+KBifJgEgJArvSnQjd2oRO8=; b=NZoNODsK62AWX3XXgbhwvgj4xsKlN9RPyEndc3heBWH5oSQ/yEgPaopAIO0pasJJGY yeJNE1m+q4C7SdJzMSXi32IxZ5pVi8nfRpfDxwUOS5ZLMJ7CP/rRwt62wt1XKtYJEi5w 00U3QRrHeVbHgln2joAZuwCq4otiompg1Q6EHjWNwCreW+6wxPJkMVIV8PAmvbErZug0 8pUgvFzg5hW4fZQKAr7clfdnAa6Cxli4+k3gIiS6WuZVj9z9JF2UaiJ7cPbsyji1wRQM fCgsBDhfO2fZa0IooKzzN4Ub4/ywDnMfAEaj4AyAVWv8fiSMuF9kSLuFxGMjged+Jk4t WgAA== 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=X3QYc0qUilro/bdxtUXo+KBifJgEgJArvSnQjd2oRO8=; b=iEJ6SR+MqUQAk+lpW9u9KUo67z8+HJ0mRFjdaph0nP3MRWdVnQYuw+Yx8kf68O0SPa D7OcnpJ4AhsLNHH+WG+ETBkKLe3OZufL6hlVy8vQOWs3TBLW9HYhh6fIVQr+J9SDoeF/ 0KusXgqbXchFYPawoCMfbxenZ8+1arGC0yLO1f7Uf+S8vbGxF3atFszFj8+si6NFKsuS xbnHUoOtwF6NNtuR6XjA4CtB/d7LyBzmkeGTaxoN28N8fUekcfpopEezIaluevtZbZdL toNeMgSZom/NM4uWFaciJGlkvbPX0r2vfWYOztu7ll1vbsC/sSoNP8uBtGyb2hKLPiB6 gzxg== X-Gm-Message-State: AOAM533WDlztVWrMqvqa6EgP5Nzw3usfHoXLNi5On7LVhI93sw4M1bD6 fzshYM3gSCmAZig/qnpeBZqJa8LJGmXO0dpF+jSAyA== X-Received: by 2002:a92:c5ac:: with SMTP id r12mr2298152ilt.274.1598898109167; Mon, 31 Aug 2020 11:21:49 -0700 (PDT) MIME-Version: 1.0 References: <20200827063522.2563293-1-lokeshgidra@google.com> <20200827063522.2563293-3-lokeshgidra@google.com> In-Reply-To: From: Lokesh Gidra Date: Mon, 31 Aug 2020 11:21:38 -0700 Message-ID: Subject: Re: [PATCH v8 2/3] Teach SELinux about anonymous inodes To: Stephen Smalley Cc: Alexander Viro , James Morris , Casey Schaufler , Eric Biggers , "Serge E. Hallyn" , Paul Moore , Eric Paris , Daniel Colascione , Kees Cook , "Eric W. Biederman" , KP Singh , David Howells , Thomas Cedeno , Anders Roxell , Sami Tolvanen , Matthew Garrett , Aaron Goidel , Randy Dunlap , "Joel Fernandes (Google)" , YueHaibing , Christian Brauner , Alexei Starovoitov , Alexey Budankov , Adrian Reber , Aleksa Sarai , Linux FS Devel , linux-kernel , LSM List , SElinux list , Kalesh Singh , Calin Juravle , Suren Baghdasaryan , Nick Kralevich , Jeffrey Vander Stoep , kernel-team@android.com, Daniel Colascione , Andrew Morton 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, Aug 31, 2020 at 11:05 AM Stephen Smalley wrote: > > On Thu, Aug 27, 2020 at 2:35 AM Lokesh Gidra wrote: > > > > From: Daniel Colascione > > > > This change uses the anon_inodes and LSM infrastructure introduced in > > the previous patch to give SELinux the ability to control > > anonymous-inode files that are created using the new anon_inode_getfd_secure() > > function. > > > > A SELinux policy author detects and controls these anonymous inodes by > > adding a name-based type_transition rule that assigns a new security > > type to anonymous-inode files created in some domain. The name used > > for the name-based transition is the name associated with the > > anonymous inode for file listings --- e.g., "[userfaultfd]" or > > "[perf_event]". > > > > Example: > > > > type uffd_t; > > type_transition sysadm_t sysadm_t : anon_inode uffd_t "[userfaultfd]"; > > allow sysadm_t uffd_t:anon_inode { create }; > > > > (The next patch in this series is necessary for making userfaultfd > > support this new interface. The example above is just > > for exposition.) > > > > Signed-off-by: Daniel Colascione > > Acked-by: Casey Schaufler > > Acked-by: Stephen Smalley > > Cc: Al Viro > > Cc: Andrew Morton > > --- > > security/selinux/hooks.c | 53 +++++++++++++++++++++++++++++ > > security/selinux/include/classmap.h | 2 ++ > > 2 files changed, 55 insertions(+) > > > > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > > index a340986aa92e..b83f56e5ef40 100644 > > --- a/security/selinux/hooks.c > > +++ b/security/selinux/hooks.c > > @@ -2926,6 +2926,58 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, > > return 0; > > } > > > > +static int selinux_inode_init_security_anon(struct inode *inode, > > + const struct qstr *name, > > + const struct inode *context_inode) > > +{ > > + const struct task_security_struct *tsec = selinux_cred(current_cred()); > > + struct common_audit_data ad; > > + struct inode_security_struct *isec; > > + int rc; > > + > > + if (unlikely(!selinux_state.initialized)) > > This should use selinux_initialized(&selinux_state) instead. Thanks for the review. I'll make the change in the next version. Kindly have a look at other patches in the series as well.