To: Stephen Smalley , paul@paul-moore.com Cc: selinux@tycho.nsa.gov, dvyukov@google.com, stable@vger.kernel.org References: <20180904205136.27935-1-sds@tycho.nsa.gov> From: Waiman Long Message-ID: <956a49bf-e31f-2ee6-b438-7dea1e04dae7@redhat.com> Date: Tue, 4 Sep 2018 17:22:56 -0400 MIME-Version: 1.0 In-Reply-To: <20180904205136.27935-1-sds@tycho.nsa.gov> Content-Type: text/plain; charset=utf-8 Subject: Re: [PATCH] selinux: fix mounting of cgroup2 under older policies List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: On 09/04/2018 04:51 PM, Stephen Smalley wrote: > commit 901ef845fa2469c ("selinux: allow per-file labeling for cgroupfs") > broke mounting of cgroup2 under older SELinux policies which lacked > a genfscon rule for cgroup2. This prevents mounting of cgroup2 even > when SELinux is permissive. > > Change the handling when there is no genfscon rule in policy to > just mark the inode unlabeled and not return an error to the caller. > This permits mounting and access if allowed by policy, e.g. to > unconfined domains. > > I also considered changing the behavior of security_genfs_sid() to > never return -ENOENT, but the current behavior is relied upon by > other callers to perform caller-specific handling. > > Fixes: 901ef845fa2469c ("selinux: allow per-file labeling for cgroupfs") > CC: > Reported-by: Dmitry Vyukov > Reported-by: Waiman Long > Signed-off-by: Stephen Smalley > --- > security/selinux/hooks.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > index f78318af8254..58fee382a3bb 100644 > --- a/security/selinux/hooks.c > +++ b/security/selinux/hooks.c > @@ -1508,6 +1508,11 @@ static int selinux_genfs_get_sid(struct dentry *dentry, > } > rc = security_genfs_sid(&selinux_state, sb->s_type->name, > path, tclass, sid); > + if (rc == -ENOENT) { > + /* No match in policy, mark as unlabeled. */ > + *sid = SECINITSID_UNLABELED; > + rc = 0; > + } > } > free_page((unsigned long)buffer); > return rc; I have tested this patch and it works in my case. Tested-by: Waiman Long