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=-9.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 B10C2C43387 for ; Sun, 6 Jan 2019 19:14:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 76F2820859 for ; Sun, 6 Jan 2019 19:14:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ieee.org header.i=@ieee.org header.b="UO615CZC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726146AbfAFTOr (ORCPT ); Sun, 6 Jan 2019 14:14:47 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:36341 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726041AbfAFTOq (ORCPT ); Sun, 6 Jan 2019 14:14:46 -0500 Received: by mail-qt1-f195.google.com with SMTP id t13so45606220qtn.3 for ; Sun, 06 Jan 2019 11:14:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=pKdlZRot4XPCkEVmRblx13Pcwlz0B7eGb8ipXDKQyyc=; b=UO615CZClgCQrcLv3zuhTDVkyJdu7+1Ko61IMxYQnb+EeLDihsUsA4e6l5GANwciBh bZoSJ4hkisPYv7+66Is05Jg+g/EcXNrMxjCBjOIwK75VTcTCcEvXeHoBR8ccohajnnVR aeW/tb91Dm6QLY1U9SMJGETI2VmEUMrf1q+Uk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pKdlZRot4XPCkEVmRblx13Pcwlz0B7eGb8ipXDKQyyc=; b=BV1pH/3PS5TLaoxqVNqu1mqAcqrHSRlDxOsmXZM+Dsi6vvf57X/q1kIX5yXPnlSPta HmB/GTAdj63rOSdO2yqHjPekg4d7KTQB8SbRHZr5RTfKIiiiDNtS9zLa1ArUKWZ+zK24 kcrcgspi2DCduz2OttysFU9QaBo1q1fJJZK27Jmoyc8yJhzF9De2QtDWdLwSyZ1c0WA7 zbIoKnH6sxjruYvIH9JsBWuN8IRaoNF7CXc58OuFz4OoZ/Iq+gi7/smbQHX2iiKbIP4u AtLfjb0WDyuoqNbbcbmAyl2TJm1A+v2seZ1EABpLIUrO7RovDYOSmsxOqvXKgS1yo7TZ PcUA== X-Gm-Message-State: AJcUukfSbkSfPDecqmnpCTNEv7h8Mt9WAFMFFvg/nFeHWLg3AEqcIKkX Fdnz09MouZvTSoZNiAdEtPsBdccExZs= X-Google-Smtp-Source: ALg8bN7+zvFfNi3FrHh+QVFKLvIuawGaZkrmVz80Kv/XuZy8dT5dHZ4Q4dTEglxY5lVt5wF5UtY+Kw== X-Received: by 2002:a0c:fa46:: with SMTP id k6mr57261540qvo.36.1546802085194; Sun, 06 Jan 2019 11:14:45 -0800 (PST) Received: from [192.168.1.190] (pool-108-15-23-247.bltmmd.fios.verizon.net. [108.15.23.247]) by smtp.gmail.com with ESMTPSA id u67sm29745381qki.22.2019.01.06.11.14.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Jan 2019 11:14:44 -0800 (PST) Subject: Re: [PATCH 2/2 v3] pam_faillock creates files in /run/faillock To: "Sugar, David" , "selinux-refpolicy@vger.kernel.org" References: <20190106182922.20344-1-dsugar@tresys.com> <20190106182922.20344-2-dsugar@tresys.com> From: Chris PeBenito Message-ID: <891bd39b-a373-6820-a797-8948e4c16e44@ieee.org> Date: Sun, 6 Jan 2019 13:57:36 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20190106182922.20344-2-dsugar@tresys.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org On 1/6/19 1:31 PM, Sugar, David wrote: > 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=AVC msg=audit(1545153126.899:210): avc: denied { search } for pid=8448 comm="lightdm" name="faillock" dev="tmpfs" ino=39318 scontext=system_u:system_r:xdm_t:s0-s0:c0.c1023 tcontext=system_u:object_r:faillog_t:s0 tclass=dir permissive=1 > type=AVC msg=audit(1545153131.090:214): avc: denied { write } for pid=8448 comm="lightdm" name="faillock" dev="tmpfs" ino=39318 scontext=system_u:system_r:xdm_t:s0-s0:c0.c1023 tcontext=system_u:object_r:faillog_t:s0 tclass=dir permissive=1 > type=AVC msg=audit(1545153131.090:214): avc: denied { add_name } for pid=8448 comm="lightdm" name="dsugar" scontext=system_u:system_r:xdm_t:s0-s0:c0.c1023 tcontext=system_u:object_r:faillog_t:s0 tclass=dir permissive=1 > type=AVC msg=audit(1545153131.090:214): avc: denied { create } for pid=8448 comm="lightdm" name="dsugar" scontext=system_u:system_r:xdm_t:s0-s0:c0.c1023 tcontext=system_u:object_r:faillog_t:s0 tclass=file permissive=1 > type=AVC msg=audit(1545153131.091:215): avc: denied { setattr } for pid=8448 comm="lightdm" name="dsugar" dev="tmpfs" ino=87599 scontext=system_u:system_r:xdm_t:s0-s0:c0.c1023 tcontext=system_u:object_r:faillog_t:s0 tclass=file permissive=1 > > type=AVC msg=audit(1545167205.531:626): avc: denied { search } for pid=8264 comm="sudo" name="faillock" dev="tmpfs" ino=35405 scontext=sysadm_u:sysadm_r:cleaner_applyconfig_sudo_t:s0-s0:c0.c1023 tcontext=system_u:object_r:faillog_t:s0 tclass=dir permissive=1 > type=AVC msg=audit(1545167205.531:627): avc: denied { write } for pid=8264 comm="sudo" name="faillock" dev="tmpfs" ino=35405 scontext=sysadm_u:sysadm_r:cleaner_applyconfig_sudo_t:s0-s0:c0.c1023 tcontext=system_u:object_r:faillog_t:s0 tclass=dir permissive=1 > type=AVC msg=audit(1545167205.531:627): avc: denied { add_name } for pid=8264 comm="sudo" name="root" scontext=sysadm_u:sysadm_r:cleaner_applyconfig_sudo_t:s0-s0:c0.c1023 tcontext=system_u:object_r:faillog_t:s0 tclass=dir permissive=1 > type=AVC msg=audit(1545167205.531:627): avc: denied { create } for pid=8264 comm="sudo" name="root" scontext=sysadm_u:sysadm_r:cleaner_applyconfig_sudo_t:s0-s0:c0.c1023 tcontext=sysadm_u:object_r:faillog_t:s0 tclass=file permissive=1 > > 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) > > init_rw_utmp($1_sudo_t) > > diff --git a/policy/modules/services/xserver.te b/policy/modules/services/xserver.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) > > # Run telinit->init to shutdown. > diff --git a/policy/modules/system/authlogin.if b/policy/modules/system/authlogin.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) > > + 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) > > @@ -744,6 +746,24 @@ interface(`auth_append_faillog',` > allow $1 faillog_t:file append_file_perms; > ') > > +######################################## > +## > +## 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) > ') > > +######################################## > +## > +## 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. > Merged. -- Chris PeBenito