Received: by 10.223.185.116 with SMTP id b49csp1108630wrg; Fri, 16 Feb 2018 12:37:28 -0800 (PST) X-Google-Smtp-Source: AH8x22500z6ZPKOOXx2o3MkuWcjAYJW5G9eTEngnsquTXW15Gk4jnHrLprk3JnTNGhfO+2kEF5uY X-Received: by 10.101.92.196 with SMTP id b4mr5985284pgt.27.1518813448058; Fri, 16 Feb 2018 12:37:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518813448; cv=none; d=google.com; s=arc-20160816; b=Ro39Qll7cwmEM1anvY36qVO7HNTQTI5XZdnhkcwST8ldfvprZi5nZ/QredUflR4K9E Fy3/Bv0JpGns1bO9HRK4TX9w3ZaagrC2j8IooNCAknS74KW7BqLBCZ0ae7CSaPBR4jiI hTbzD4tXpXlj7Meiz4Fxf7X6FRxVd7nb6V//468LjJ51Cj5bXIAIYgF17l0QkFJqTLK7 OtdJKLb5Mlqa3U6bkxVlGSu94gREDwBqG6uKCUW86Fg8CW6lQRd2Jmbaz5EaoHnwP2qs i2ryXM2PMzwVWIN7A+7P2NSpM9Uut7VDxIpXdYxXDN+D5/X789moSUH6+ecES058rkGr Zneg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=bMDHejotnIJAIN+Gl2dmRyy6XAnlh4dSuvALBKEW+fc=; b=twUK1etF+Hj8xb7Gxll3l87aVSFWNTBy7529QagXDaPB3tKrusZNP5mtYZIzxhtqp6 XH22kjGjlTe96ILpfY0HZfXjTqpfbAh6GN2zxzDV4288Ub2baKmjHbE6Tcovtigu5A/w aiJKVAccysezhedoGM+PB9JOf5uCtFxEfnf3gglhtPZIT7v7droOPxDTco6mqzT9jsb/ cwhdrRn8hP6C+V/bU/7M9CRJKiwT8+BC2dIFeWuOYIyHo6y8WnP+78uIB9nPjCBK/fwp 6SzqO5eB4Qmmu3oGi5Bl07Pb3/TFieH0+ClSinNIBUmjEk84a4RLyX7pcCEIq0ANeCHt cSiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=iGG+2L+e; 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=NONE sp=NONE dis=NONE) header.from=cisco.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e12si230744pgf.646.2018.02.16.12.37.13; Fri, 16 Feb 2018 12:37:28 -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=@cisco.com header.s=iport header.b=iGG+2L+e; 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=NONE sp=NONE dis=NONE) header.from=cisco.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751164AbeBPUgJ (ORCPT + 99 others); Fri, 16 Feb 2018 15:36:09 -0500 Received: from alln-iport-6.cisco.com ([173.37.142.93]:35249 "EHLO alln-iport-6.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751078AbeBPUeJ (ORCPT ); Fri, 16 Feb 2018 15:34:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1404; q=dns/txt; s=iport; t=1518813249; x=1520022849; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=GVG8yZSIqBpAYoYeLbJ4sv4eV9fL21UfOz/cszDkk3s=; b=iGG+2L+e0Zb04v5nVWdGBjxAAMc/qwq/7Rdwldv5H43WS8Q7MEmmdznQ MECm7Jy8iLikh+JJp2Qgm/mRFfr42SGN1j9ZZYlPXmS0aTKco7GeWKtKs R1SBsMamqKd3VSyFE9PdkeR0dUByf4uUCbSw/JwOZycFOYcvO55lMBNWr s=; X-IronPort-AV: E=Sophos;i="5.46,520,1511827200"; d="scan'208";a="71375533" Received: from rcdn-core-6.cisco.com ([173.37.93.157]) by alln-iport-6.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Feb 2018 20:34:08 +0000 Received: from sjc-ads-7132.cisco.com (sjc-ads-7132.cisco.com [10.30.217.207]) (authenticated bits=0) by rcdn-core-6.cisco.com (8.14.5/8.14.5) with ESMTP id w1GKXsMf015412 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Fri, 16 Feb 2018 20:34:08 GMT From: Taras Kondratiuk To: "H. Peter Anvin" , Al Viro , Arnd Bergmann , Rob Landley , Mimi Zohar , Jonathan Corbet , James McMechan Cc: initramfs@vger.kernel.org, Victor Kamensky , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, xe-linux-external@cisco.com Subject: [PATCH v3 14/15] selinux: allow setxattr on rootfs so initramfs code can set them Date: Fri, 16 Feb 2018 20:33:52 +0000 Message-Id: <1518813234-5874-17-git-send-email-takondra@cisco.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518813234-5874-1-git-send-email-takondra@cisco.com> References: <1518813234-5874-1-git-send-email-takondra@cisco.com> X-Auto-Response-Suppress: DR, OOF, AutoReply X-Authenticated-User: takondra@cisco.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Victor Kamensky initramfs code supporting extended cpio format have ability to fill extended attributes from cpio archive, but if SELinux enabled and security server is not initialized yet, selinux callback would refuse setxattr made by initramfs code. Solution enable SBLABEL_MNT on rootfs even if secrurity server is not initialized yet. Signed-off-by: Victor Kamensky --- security/selinux/hooks.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 8644d864e3c1..f3fe65589f02 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -706,6 +706,18 @@ static int selinux_set_mnt_opts(struct super_block *sb, if (!ss_initialized) { if (!num_opts) { + /* + * Special handling for rootfs. Is genfs but supports + * setting SELinux context on in-core inodes. + * + * Chicken and egg problem: policy may reside in rootfs + * but for initramfs code to fill in attributes, it + * needs selinux to allow that. + */ + if (!strncmp(sb->s_type->name, "rootfs", + sizeof("rootfs"))) + sbsec->flags |= SBLABEL_MNT; + /* Defer initialization until selinux_complete_init, after the initial policy is loaded and the security server is ready to handle calls. */ -- 2.10.3.dirty