Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3475952imu; Sun, 11 Nov 2018 15:59:18 -0800 (PST) X-Google-Smtp-Source: AJdET5fuqI7a7Jn/cbsS2qavXDXj9u0ATyJqEVi4z9bcD3rke0MK3We6BnKIye2SegbzFhmWjyoP X-Received: by 2002:a63:4f20:: with SMTP id d32mr15481088pgb.47.1541980758381; Sun, 11 Nov 2018 15:59:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980758; cv=none; d=google.com; s=arc-20160816; b=G/G4BkI9hCGeG2bhTebYjtDhH/KTwUSw3EddHHyMaNDGZaOqw8IKSl5PVdTXaRC1Mx DS7t1uzOEJjG93nBp1TyT/2cfjK1EZ8j7elkFIG6qW28HPcx9lvIaFqJ6g/qrQlsJK9v ZtuMLsJ7A0H/lC1vb2KNFHHEuqgv1E0Mt2xLkgC0SwtCSRDfQPchrT09CMoPO2THVeDy 0BGx18AnFMeYimfXTSge0gI5RUtA2BEARay7uiEPPdTib3jNp+jdiBRj2SXFbIrr8c22 fpjxWGgE0B4WOt8MtJM2JdcvuJlT4DlO+5R47fFEoHI/0s5PB8Cikm0dwg1IeKqGLBJC hQmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2aCYfM7OuZMpqhYRd8QY8UBOftjlL+wosJN+yEqFDn4=; b=JmLgJXhMV8YpealC4CtahPRQNeJ56CGOXJo0aZfzcuKEqX3ELNqjExQs+8S8Tra00X zEcgKKfzDz8KvsjcCE5ROEvaJh7LyJ5Su5tsvgd6KECWSLyvz7NK29yRLGs3Ze3/Z5Bv dxC9FrxmIaDhfBNu5CTysCpYZQgOErvqB2CjLIaDmyRQ3pE2OukpDOmD3p87+lXplbi2 tYH1qEZh8c+DExhR1cWeD6p5WOsgYEmBHuA4ONPUEMKpo6a8dUlGm23FwjaUm7JxwdHf 0t89c/j5Q7uTIema6jwjYCZnSjc/01Tvk0kRFEY88be6a88q4oBfG4UQAFwrUCMgad7l +vww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UgCvcHsW; 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 j3-v6si17109717pfc.57.2018.11.11.15.59.03; Sun, 11 Nov 2018 15:59:18 -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=UgCvcHsW; 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 S1732593AbeKLJtE (ORCPT + 99 others); Mon, 12 Nov 2018 04:49:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:35336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732407AbeKLISG (ORCPT ); Mon, 12 Nov 2018 03:18:06 -0500 Received: from localhost (unknown [206.108.79.134]) (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 CE2732154B; Sun, 11 Nov 2018 22:28:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975290; bh=rL5qz7AD4gpCm6ohzUEYMAmxoVqqdrE6uI4vGYwGUlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UgCvcHsWZvb8TGnLoUdzj6HtbI/ZkiYow2GlHrzNeOmvnjx1Ub9R6NBfX9NDJxwrL syOwaIZljF9GZ8MVjSnwwPfYG3tyDA662jtY3Vixwar9smQ9VSz3kxR1x+ZEwyMA8w XtmceX346wZ37mc5VYTzkOXB9YcVBsukeHo3CaCc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Vyukov , Waiman Long , Stephen Smalley , Paul Moore Subject: [PATCH 4.19 231/361] selinux: fix mounting of cgroup2 under older policies Date: Sun, 11 Nov 2018 14:19:38 -0800 Message-Id: <20181111221651.548385501@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stephen Smalley commit 7bb185edb0306bb90029a5fa6b9cff900ffdbf4b upstream. 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 Tested-by: Waiman Long Signed-off-by: Paul Moore Signed-off-by: Greg Kroah-Hartman --- security/selinux/hooks.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1508,6 +1508,11 @@ static int selinux_genfs_get_sid(struct } 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;