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.0 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,URIBL_BLOCKED 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 4A88DC43387 for ; Sun, 6 Jan 2019 18:31:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F239F20859 for ; Sun, 6 Jan 2019 18:31:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=tresys.onmicrosoft.com header.i=@tresys.onmicrosoft.com header.b="NnZLQLaZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726041AbfAFSbs (ORCPT ); Sun, 6 Jan 2019 13:31:48 -0500 Received: from mail-eopbgr690124.outbound.protection.outlook.com ([40.107.69.124]:39904 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726014AbfAFSbs (ORCPT ); Sun, 6 Jan 2019 13:31:48 -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=N7bQpUofd5fD7PcA3hNwnAAsE1uW619CSFSA6v7kP14=; b=NnZLQLaZfAhTzCBc/YZfCz3NmbYWH0pv91gPHIgSnzYbrT86bxr0jd/4cRjBdaM6rC50yZ/HXsLOSyjA3XPLpaRtpYQXMiyMcaVhcu8uSUzPw7Y12TuqxT0LY1HhcH2/RM863oeJ8HZbXFVrvdniVd5Mkad17rrxcXi5GfhFoxM= Received: from BN6PR15MB1507.namprd15.prod.outlook.com (10.172.151.147) by BN6PR15MB1236.namprd15.prod.outlook.com (10.172.206.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1495.6; Sun, 6 Jan 2019 18:31:43 +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.1495.011; Sun, 6 Jan 2019 18:31:43 +0000 From: "Sugar, David" To: "selinux-refpolicy@vger.kernel.org" Subject: [PATCH 2/2 v3] pam_faillock creates files in /run/faillock Thread-Topic: [PATCH 2/2 v3] pam_faillock creates files in /run/faillock Thread-Index: AQHUpe4S8jwL6ECCFEmjxPLFgLoWvg== Date: Sun, 6 Jan 2019 18:31:42 +0000 Message-ID: <20190106182922.20344-2-dsugar@tresys.com> References: <20190106182922.20344-1-dsugar@tresys.com> In-Reply-To: <20190106182922.20344-1-dsugar@tresys.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [73.180.141.176] x-clientproxiedby: BN7PR06CA0004.namprd06.prod.outlook.com (2603:10b6:406:80::17) 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;BN6PR15MB1236;6:qFBlUxF+9ImR9NZ9DldlmIQ/tGT1z4KA85KToIqaLiFPj9BVT2I+f5PtmpeNM1OIKmpLsz4yVQfUW7ZvUKdkwlUkL7ZlypeUzScDXGv+13tAbKl8yBCPQgq/8T3EZc724gu88PpABsWkTr6llPqSULVRVEEscDl4wHVNgZDCszGnoslllByjoMuH7L+xdhh7skA1l9F2/iD/PALjrMf8inOBJoukUVDuE3EpDkEXEuIBERgc0so/uyhw4ukvfjuhrNoAwVV/rUxECWCZDlvXmbPHEeNVw+gcDrphbSRpWccTNV8hlJmDjw0oQv/H7BVjh71syF7w0xsVZFRDdSNtAFX1hA1kZfKS2wX0zlDRH62ObgJoEsyeV/1XaZMJH4Ihx2PbcYKLO19K8YT4zjSCOjIHTEphIFvKxEJ+zB2iGemrii41m3rR4YmFFBZxASUoLAS1N9NQ9XbNk2os59CraQ==;5:k9DVQSLDK5rYAVg24/GxD2mCDrWwb41dN9nDLpPWpDxXKq3B/s1QbqGaLyqeBLwnUKR3oBS1UFsgZDSGKMNTjojAe+LAoYKl2rdk6/ZQ1G1676ee9DVY8hHyDkG1kXCbt934ZNjAV4cnQSDLv8S6ua5fR6fRFnRJcBzU9jUHyAVWB+cV51h/HY+rZmo+siQN8RhJyNH2KWrmpwsgHbWZBQ==;7:l02s14f5t/5z+aEI4awUvqpSRIBeqOAyBK26NcFbaEICkDe6Kpxf7qGtj84nh8LDIq61sKyR+oJ1FQmZcBcdJv8wpRx2zJe1HRDKXAeTrvvNMS+z9WzhlscwlMBkSxdLMpsmYu5VTQBnF0gYxe9aEg== x-ms-office365-filtering-correlation-id: f45d9a0c-8b4e-4d11-1820-08d674053495 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:BN6PR15MB1236; x-ms-traffictypediagnostic: BN6PR15MB1236: x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(8220060)(2401047)(8121501046)(10201501046)(3002001)(3231475)(944501520)(52105112)(93006095)(93001095)(6041310)(2016111802025)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(6043046)(201708071742011)(7699051)(76991095);SRVR:BN6PR15MB1236;BCL:0;PCL:0;RULEID:;SRVR:BN6PR15MB1236; x-forefront-prvs: 09090B6B69 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(366004)(396003)(346002)(39830400003)(136003)(189003)(199004)(71200400001)(8936002)(71190400001)(66066001)(5640700003)(81166006)(53936002)(81156014)(14444005)(256004)(6916009)(25786009)(2501003)(1076003)(2906002)(8676002)(6436002)(5660300001)(6486002)(99286004)(316002)(6512007)(386003)(26005)(6506007)(2616005)(14454004)(186003)(446003)(102836004)(97736004)(508600001)(11346002)(476003)(3846002)(6116002)(52116002)(86362001)(486006)(36756003)(575784001)(305945005)(7736002)(76176011)(106356001)(2351001)(68736007)(105586002)(551544002);DIR:OUT;SFP:1102;SCL:1;SRVR:BN6PR15MB1236;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: WiFyoxoQzDQ+Bp4C5nPKg0HifSnagbnT7Jdp07MM6OhxZy0eGQi8VEB3EkJY1ZDWEc3FOzvnqeVwggbyU9xGZoBFEIWioBDb84CztCB8gdVI9+snRMO0mMJV+tBUlSq8rJdqb4meZ/Y8heoeS/Ciy/Vx6pZaCI4FOlD/H3W3o7VHgDf25BwNZvdKOHBOcXfb72QeHos0xFcgQhFgCsAY2cLeDdZHqETlvCvowUX9iQFLwoFs46mfV5JN5dSDxBqGbxtUvOqzSD8bntiIvT42TtB8He0gR35GCySvrIedSXq2l08EKt3VRdUjIU0DLpnQ 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: f45d9a0c-8b4e-4d11-1820-08d674053495 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2019 18:31:42.8942 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a0d45667-6c07-4e88-868f-4ac9af95c7ed X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR15MB1236 Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org These are changes needed when pam_fallock creates files in /run/faillock (which is labeled faillog_t). sudo and xdm (and probably other domains) will create files in this directory for successful and failed login attempts. v3 - Updated based on feedback type=3DAVC msg=3Daudit(1545153126.899:210): avc: denied { search } for pi= d=3D8448 comm=3D"lightdm" name=3D"faillock" dev=3D"tmpfs" ino=3D39318 scont= ext=3Dsystem_u:system_r:xdm_t:s0-s0:c0.c1023 tcontext=3Dsystem_u:object_r:f= aillog_t:s0 tclass=3Ddir permissive=3D1 type=3DAVC msg=3Daudit(1545153131.090:214): avc: denied { write } for pid= =3D8448 comm=3D"lightdm" name=3D"faillock" dev=3D"tmpfs" ino=3D39318 sconte= xt=3Dsystem_u:system_r:xdm_t:s0-s0:c0.c1023 tcontext=3Dsystem_u:object_r:fa= illog_t:s0 tclass=3Ddir permissive=3D1 type=3DAVC msg=3Daudit(1545153131.090:214): avc: denied { add_name } for = pid=3D8448 comm=3D"lightdm" name=3D"dsugar" scontext=3Dsystem_u:system_r:xd= m_t:s0-s0:c0.c1023 tcontext=3Dsystem_u:object_r:faillog_t:s0 tclass=3Ddir p= ermissive=3D1 type=3DAVC msg=3Daudit(1545153131.090:214): avc: denied { create } for pi= d=3D8448 comm=3D"lightdm" name=3D"dsugar" scontext=3Dsystem_u:system_r:xdm_= t:s0-s0:c0.c1023 tcontext=3Dsystem_u:object_r:faillog_t:s0 tclass=3Dfile pe= rmissive=3D1 type=3DAVC msg=3Daudit(1545153131.091:215): avc: denied { setattr } for p= id=3D8448 comm=3D"lightdm" name=3D"dsugar" dev=3D"tmpfs" ino=3D87599 sconte= xt=3Dsystem_u:system_r:xdm_t:s0-s0:c0.c1023 tcontext=3Dsystem_u:object_r:fa= illog_t:s0 tclass=3Dfile permissive=3D1 type=3DAVC msg=3Daudit(1545167205.531:626): avc: denied { search } for pi= d=3D8264 comm=3D"sudo" name=3D"faillock" dev=3D"tmpfs" ino=3D35405 scontext= =3Dsysadm_u:sysadm_r:cleaner_applyconfig_sudo_t:s0-s0:c0.c1023 tcontext=3Ds= ystem_u:object_r:faillog_t:s0 tclass=3Ddir permissive=3D1 type=3DAVC msg=3Daudit(1545167205.531:627): avc: denied { write } for pid= =3D8264 comm=3D"sudo" name=3D"faillock" dev=3D"tmpfs" ino=3D35405 scontext= =3Dsysadm_u:sysadm_r:cleaner_applyconfig_sudo_t:s0-s0:c0.c1023 tcontext=3Ds= ystem_u:object_r:faillog_t:s0 tclass=3Ddir permissive=3D1 type=3DAVC msg=3Daudit(1545167205.531:627): avc: denied { add_name } for = pid=3D8264 comm=3D"sudo" name=3D"root" scontext=3Dsysadm_u:sysadm_r:cleaner= _applyconfig_sudo_t:s0-s0:c0.c1023 tcontext=3Dsystem_u:object_r:faillog_t:s= 0 tclass=3Ddir permissive=3D1 type=3DAVC msg=3Daudit(1545167205.531:627): avc: denied { create } for pi= d=3D8264 comm=3D"sudo" name=3D"root" scontext=3Dsysadm_u:sysadm_r:cleaner_a= pplyconfig_sudo_t:s0-s0:c0.c1023 tcontext=3Dsysadm_u:object_r:faillog_t:s0 = tclass=3Dfile permissive=3D1 Signed-off-by: Dave Sugar --- policy/modules/admin/sudo.if | 2 +- policy/modules/services/xserver.te | 1 - policy/modules/system/authlogin.if | 38 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/policy/modules/admin/sudo.if b/policy/modules/admin/sudo.if index 01f408ef..1c1fbe7b 100644 --- a/policy/modules/admin/sudo.if +++ b/policy/modules/admin/sudo.if @@ -116,8 +116,8 @@ template(`sudo_role_template',` auth_run_chk_passwd($1_sudo_t, $2) # sudo stores a token in the pam_pid directory auth_manage_pam_pid($1_sudo_t) + auth_use_pam($1_sudo_t) auth_pid_filetrans_pam_var_run($1_sudo_t, dir, "sudo") - auth_use_nsswitch($1_sudo_t) =20 init_rw_utmp($1_sudo_t) =20 diff --git a/policy/modules/services/xserver.te b/policy/modules/services/x= server.te index c7714d3e..edac2833 100644 --- a/policy/modules/services/xserver.te +++ b/policy/modules/services/xserver.te @@ -484,7 +484,6 @@ term_setattr_unallocated_ttys(xdm_t) auth_domtrans_pam_console(xdm_t) auth_manage_pam_pid(xdm_t) auth_manage_pam_console_data(xdm_t) -auth_rw_faillog(xdm_t) auth_write_login_records(xdm_t) =20 # Run telinit->init to shutdown. diff --git a/policy/modules/system/authlogin.if b/policy/modules/system/aut= hlogin.if index 9b5e0fe0..0153ab07 100644 --- a/policy/modules/system/authlogin.if +++ b/policy/modules/system/authlogin.if @@ -47,6 +47,7 @@ interface(`auth_use_pam',` # for encrypted homedir dev_read_sysfs($1) =20 + auth_create_faillog_files($1) auth_domtrans_chk_passwd($1) auth_domtrans_upd_passwd($1) auth_dontaudit_read_shadow($1) @@ -54,6 +55,7 @@ interface(`auth_use_pam',` auth_append_login_records($1) auth_rw_lastlog($1) auth_rw_faillog($1) + auth_setattr_faillog_files($1) auth_exec_pam($1) auth_use_nsswitch($1) =20 @@ -744,6 +746,24 @@ interface(`auth_append_faillog',` allow $1 faillog_t:file append_file_perms; ') =20 +######################################## +## +## Create fail log lock (in /run/faillock). +## +## +## +## Domain allowed access. +## +## +# +interface(`auth_create_faillog_files',` + gen_require(` + type faillog_t; + ') + + create_files_pattern($1, faillog_t, faillog_t) +') + ######################################## ## ## Read and write the login failure log. @@ -782,6 +802,24 @@ interface(`auth_manage_faillog',` logging_rw_generic_log_dirs($1) ') =20 +######################################## +## +## Setattr the login failure logs. +## +## +## +## Domain allowed access. +## +## +# +interface(`auth_setattr_faillog_files',` + gen_require(` + type faillog_t; + ') + + setattr_files_pattern($1, faillog_t, faillog_t) +') + ####################################### ## ## Read the last logins log. --=20 2.20.1