Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D8B8C43612 for ; Fri, 11 Jan 2019 15:31:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4292220836 for ; Fri, 11 Jan 2019 15:31:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=tresys.onmicrosoft.com header.i=@tresys.onmicrosoft.com header.b="Ck/wmqQt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731608AbfAKPbN (ORCPT ); Fri, 11 Jan 2019 10:31:13 -0500 Received: from mail-eopbgr700120.outbound.protection.outlook.com ([40.107.70.120]:34256 "EHLO NAM04-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731244AbfAKPbM (ORCPT ); Fri, 11 Jan 2019 10:31:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tresys.onmicrosoft.com; s=selector1-tresys-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dZB9eytaUnv/AEeYziXlxdO+4TTxj6qbjs5Hxz/Rsj8=; b=Ck/wmqQtcUk9IJ3NiCYxz2mrW2+immb6k1pLPs8leMgIUma288ADjv+QmbVTMaeICzfQwUJWsE+MOhESpVkYqkCK8IhfPkWU36XctET7ZDkhog1j5dULGaSuTRZDyV+JwK9nyf2idh5T5oy8Iokvp7h2dhIh3QM23RsDz+57q5M= Received: from BN6PR15MB1507.namprd15.prod.outlook.com (10.172.151.147) by BN6PR15MB1378.namprd15.prod.outlook.com (10.172.150.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.15; Fri, 11 Jan 2019 15:30:54 +0000 Received: from BN6PR15MB1507.namprd15.prod.outlook.com ([fe80::6d82:5bd:50b3:6a10]) by BN6PR15MB1507.namprd15.prod.outlook.com ([fe80::6d82:5bd:50b3:6a10%3]) with mapi id 15.20.1516.016; Fri, 11 Jan 2019 15:30:54 +0000 From: "Sugar, David" To: "selinux-refpolicy@vger.kernel.org" Subject: [PATCH 2/2] Setup private type for /etc/hostname. Thread-Topic: [PATCH 2/2] Setup private type for /etc/hostname. Thread-Index: AQHUqcKjsgplOtKTxkOvDqK/WKf0Tg== Date: Fri, 11 Jan 2019 15:30:54 +0000 Message-ID: <20190111153011.27275-5-dsugar@tresys.com> References: <20190111153011.27275-1-dsugar@tresys.com> In-Reply-To: <20190111153011.27275-1-dsugar@tresys.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [96.244.17.66] x-clientproxiedby: BN8PR12CA0034.namprd12.prod.outlook.com (2603:10b6:408:60::47) To BN6PR15MB1507.namprd15.prod.outlook.com (2603:10b6:404:c6::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=dsugar@tresys.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BN6PR15MB1378;6:nQ6cPOC90ebrR5idM4TxpoPKeF+TWXEeL6lBnQlMgezpFZBQlfZ5EO7LxcKSj8UVrZdAiwgrt+QhHbTTFTejv6zli+ZTUh1p54rVqYaZD1+8jMROm3Zc58yWnJLgVg71iTagjpKBX7ZLzKxTLiEVGcQJf/M3QqyfwrdZr0EPLg4zgVC/BTL64f52SjBC7+nByP3vk3uCDZWUQr3VMm84mEtbvmuzJ6bDU6k0J32iwXNfSAuWxnXsYc9u6pMzqGsCXmtF+b3N6dlUgXvREtCaidqX0UfJk9uPnNgM4LxW0ugnU1IU0JjD2X8MQ0ECVea7ev3Z10iZCUSdLBCKMF0VVfGBaW/zS2yyqVvCunqfflmEOhRdCe7O+jh7St3BXA5xMG5xzukiYVJWOF/NgqF+TNbsRi2CG1mogDMwS4IitB6/jHtSdsaeY0uubTebu2UQBrfJKwyLxNKre4D7ZWhx5g==;5:quUnROXwO1hoHqCjw+UCB4OolLdnC+QHA4fdl36MdjBg63zCeZIMmaxjMihH2Ty9GNP+Zt/ecEgg2Sn0FZXWMDEACBDWZmPixRLOqa6jzBZ1IiLecCnj9VpCguZ8a0bR/ImqciOUchsakby4LjO54CZj58QCmJSDgN6Q6iXMPUQeRg5vB2X+9tDrCymg4gFwPTaBPaBQGZ4AVZcCuNpM5w==;7:UaZxImrud37qD8Jj0Gu2fwUZwR4C83Tvw9ytDPnl1xfksNQabkQFT8aX0D4RfY2aEhzc947t5FKsZ6noXkInv9Lm2ISjnoTd54ItVzLC2D9oX2kJaTzZ1iQKsfbZgKFHUlltJJajHMO3z9zG6Y7EEQ== x-ms-office365-filtering-correlation-id: 450b065a-1cd9-4b63-8076-08d677d9c616 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(7021145)(8989299)(4534185)(7022145)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600109)(711020)(2017052603328)(7153060)(7193020);SRVR:BN6PR15MB1378; x-ms-traffictypediagnostic: BN6PR15MB1378: x-microsoft-antispam-prvs: x-forefront-prvs: 09144DB0F7 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39830400003)(376002)(366004)(136003)(346002)(396003)(189003)(199004)(316002)(86362001)(14444005)(575784001)(6916009)(36756003)(66066001)(256004)(97736004)(508600001)(99286004)(14454004)(5660300001)(71200400001)(71190400001)(105586002)(106356001)(2906002)(76176011)(26005)(102836004)(2351001)(6506007)(386003)(53936002)(6512007)(6116002)(3846002)(7736002)(11346002)(52116002)(486006)(476003)(2616005)(8676002)(81156014)(8936002)(186003)(2501003)(446003)(6486002)(81166006)(5640700003)(6436002)(305945005)(68736007)(1076003)(25786009);DIR:OUT;SFP:1102;SCL:1;SRVR:BN6PR15MB1378;H:BN6PR15MB1507.namprd15.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: tresys.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: EKbUEr2+3Mc3nzLKvn/pGznPZe19ugd1XW3/qyqsmlPertWXEQgvvj/FaWrkiDojkjrZSwcmhMAXchVcs/8I2WgdXLO0mUylKXm3s2jXMJC717sF+igppDIAlKo/uqOd/X9MVnsL4lEalF/Zbv7AygnuSsRJ/DRjOL93jVRqI3m2IC1pjgtytlekDNuUl5yLz88KGUf5DozkwkkNFlFV/VqwoW6ak/zNp12mytKtWWPJX2u+rmmB1uUC9rym0x8TPljpmovREQzZF83aooeaGR90OtazCi065pYICXkb4YGw09oesZ8Aliv8A15zmuNMR/kh2hAYGmyeEjYuNwYhajkjOyDvllHpO2b1FVGB4m7KK1mwa0evz9obyPBTM2IBvxGvf563TAcgrJVaIH2PcpvOn5sCMApzZJiAS+vQ1Bw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: tresys.com X-MS-Exchange-CrossTenant-Network-Message-Id: 450b065a-1cd9-4b63-8076-08d677d9c616 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jan 2019 15:30:54.0180 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a0d45667-6c07-4e88-868f-4ac9af95c7ed X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR15MB1378 Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org hostnamectl updates /etc/hostname. This change is setting up a private type for the file /etc/hostname (was et= c_t) and granting hostnamectl permission to edit this file. Note that hostnamec= tl is initially creating a new file .#hostname????? which is why the create permissions are requied. type=3DAVC msg=3Daudit(1547039052.041:563): avc: denied { write } for pi= d=3D7564 comm=3D"systemd-hostnam" name=3D"etc" dev=3D"dm-1" ino=3D101 scont= ext=3Dsystem_u:system_r:systemd_hostnamed_t:s0 tcontext=3Dsystem_u:object_r= :etc_t:s0 tclass=3Ddir permissive=3D1 type=3DAVC msg=3Daudit(1547039052.041:563): avc: denied { add_name } for = pid=3D7564 comm=3D"systemd-hostnam" name=3D".#hostnamezyqZ9t" scontext=3Ds= ystem_u:system_r:systemd_hostnamed_t:s0 tcontext=3Dsystem_u:object_r:etc_t:= s0 tclass=3Ddir permissive=3D1 type=3DAVC msg=3Daudit(1547039052.041:563): avc: denied { create } for p= id=3D7564 comm=3D"systemd-hostnam" name=3D".#hostnamezyqZ9t" scontext=3Dsys= tem_u:system_r:systemd_hostnamed_t:s0 tcontext=3Dsystem_u:object_r:etc_t:s0= tclass=3Dfile permissive=3D1 type=3DAVC msg=3Daudit(1547039052.041:563): avc: denied { write } for pi= d=3D7564 comm=3D"systemd-hostnam" path=3D"/etc/.#hostnamezyqZ9t" dev=3D"dm-= 1" ino=3D1094726 scontext=3Dsystem_u:system_r:systemd_hostnamed_t:s0 tconte= xt=3Dsystem_u:object_r:etc_t:s0 tclass=3Dfile permissive=3D1 type=3DSYSCALL msg=3Daudit(1547039052.041:563): arch=3Dc000003e syscall=3D2= success=3Dyes exit=3D8 a0=3D560d0bba34b0 a1=3D800c2 a2=3D180 a3=3D5c35f14c= items=3D2 ppid=3D1 pid=3D7564 auid=3D4294967295 uid=3D0 gid=3D0 euid=3D0 s= uid=3D0 fsuid=3D0 egid=3D0 sgid=3D0 fsgid=3D0 tty=3D(none) ses=3D4294967295= comm=3D"systemd-hostnam" exe=3D"/usr/lib/systemd/systemd-hostnamed" subj= =3Dsystem_u:system_r:systemd_hostnamed_t:s0 key=3D(null) type=3DAVC msg=3Daudit(1547039052.041:564): avc: denied { setattr } for = pid=3D7564 comm=3D"systemd-hostnam" name=3D".#hostnamezyqZ9t" dev=3D"dm-1" = ino=3D1094726 scontext=3Dsystem_u:system_r:systemd_hostnamed_t:s0 tcontext= =3Dsystem_u:object_r:etc_t:s0 tclass=3Dfile permissive=3D1 type=3DSYSCALL msg=3Daudit(1547039052.041:564): arch=3Dc000003e syscall=3D9= 1 success=3Dyes exit=3D0 a0=3D8 a1=3D1a4 a2=3Dfbad2484 a3=3D24 items=3D1 pp= id=3D1 pid=3D7564 auid=3D4294967295 uid=3D0 gid=3D0 euid=3D0 suid=3D0 fsuid= =3D0 egid=3D0 sgid=3D0 fsgid=3D0 tty=3D(none) ses=3D4294967295 comm=3D"syst= emd-hostnam" exe=3D"/usr/lib/systemd/systemd-hostnamed" subj=3Dsystem_u:sys= tem_r:systemd_hostnamed_t:s0 key=3D(null) type=3DAVC msg=3Daudit(1547039052.041:565): avc: denied { remove_name } f= or pid=3D7564 comm=3D"systemd-hostnam" name=3D".#hostnamezyqZ9t" dev=3D"dm= -1" ino=3D1094726 scontext=3Dsystem_u:system_r:systemd_hostnamed_t:s0 tcont= ext=3Dsystem_u:object_r:etc_t:s0 tclass=3Ddir permissive=3D1 type=3DAVC msg=3Daudit(1547039052.041:565): avc: denied { rename } for p= id=3D7564 comm=3D"systemd-hostnam" name=3D".#hostnamezyqZ9t" dev=3D"dm-1" i= no=3D1094726 scontext=3Dsystem_u:system_r:systemd_hostnamed_t:s0 tcontext= =3Dsystem_u:object_r:etc_t:s0 tclass=3Dfile permissive=3D1 type=3DAVC msg=3Daudit(1547039052.041:565): avc: denied { unlink } for p= id=3D7564 comm=3D"systemd-hostnam" name=3D"hostname" dev=3D"dm-1" ino=3D109= 4712 scontext=3Dsystem_u:system_r:systemd_hostnamed_t:s0 tcontext=3Dsystem_= u:object_r:etc_t:s0 tclass=3Dfile permissive=3D1 Signed-off-by: Dave Sugar --- policy/modules/system/systemd.fc | 1 + policy/modules/system/systemd.te | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/policy/modules/system/systemd.fc b/policy/modules/system/syste= md.fc index eefcfaf1..2277fc1e 100644 --- a/policy/modules/system/systemd.fc +++ b/policy/modules/system/systemd.fc @@ -1,3 +1,4 @@ +/etc/hostname -- gen_context(system_u:object_r:hostname_etc_t,s0) /etc/udev/hwdb\.bin -- gen_context(system_u:object_r:systemd_hwdb_t,s0) =20 /run/log/journal(/.*)? gen_context(system_u:object_r:systemd_journal_t,= s0) diff --git a/policy/modules/system/systemd.te b/policy/modules/system/syste= md.te index f5f7dc1b..3704b756 100644 --- a/policy/modules/system/systemd.te +++ b/policy/modules/system/systemd.te @@ -77,6 +77,9 @@ type systemd_detect_virt_t; type systemd_detect_virt_exec_t; init_daemon_domain(systemd_detect_virt_t, systemd_detect_virt_exec_t) =20 +type hostname_etc_t; +files_config_file(hostname_etc_t) + type systemd_hostnamed_t; type systemd_hostnamed_exec_t; init_daemon_domain(systemd_hostnamed_t, systemd_hostnamed_exec_t) @@ -317,10 +320,13 @@ seutil_search_default_contexts(systemd_coredump_t) # Hostnamed policy # =20 +allow systemd_hostnamed_t hostname_etc_t:file manage_file_perms; + kernel_read_kernel_sysctls(systemd_hostnamed_t) =20 dev_read_sysfs(systemd_hostnamed_t) =20 +files_etc_filetrans(systemd_hostnamed_t, hostname_etc_t, file) files_read_etc_files(systemd_hostnamed_t) =20 seutil_read_file_contexts(systemd_hostnamed_t) --=20 2.20.1