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=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 F3C83C43387 for ; Sun, 6 Jan 2019 12:47:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC7DA20878 for ; Sun, 6 Jan 2019 12:47:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cFNqWLyy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726336AbfAFMra (ORCPT ); Sun, 6 Jan 2019 07:47:30 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:35858 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726315AbfAFMra (ORCPT ); Sun, 6 Jan 2019 07:47:30 -0500 Received: by mail-ed1-f65.google.com with SMTP id f23so35517473edb.3 for ; Sun, 06 Jan 2019 04:47:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=DRA/aYXJzsjTaaWTyDdN0qRai7s/+G2BoUGFHOaGvYc=; b=cFNqWLyy5/kQe03Ym1opwnTPb6fCPjmSieVhuwjR+Rw71eoEv8QHJCpcaVLoH6dafO t3CZFrHURcVAgc371uGGKlkk4EeRDKsMJkV9EMRrBVb4hCtd8VErJ9v3qoaElBtKxYML XnevdxYty5f/ShNCnCf8iCSizKqyFm2Oh9Uu4KT0xmWwTZI0Q6Hm9mzLhLhGBUEx1Gvc kyzUWllKkm5MkmZn3wYeFTk3nGLjPKSA5fII62gHzPm3TX7UIXlhWTKZnyXgLnMAsF9c snJbuNucuOLR/LtkrVI+E8yP+24f17rc+14P88gc49AcOwU1GGoaIOeT9f81pdZIriaU 8QiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=DRA/aYXJzsjTaaWTyDdN0qRai7s/+G2BoUGFHOaGvYc=; b=I585Jrueh2ODcnGhLk6YXw1zn30+uMu1YPVQTvKGvMabA0vrRTD/fPuqqswBPisJGY es/9jXFPtlcwrQlPZ+l17YwkpiYIAZ136LMost/DI6HtT8vqWv0lpvFr/UqWLd8kPAO/ 67ZPKa4GzULNGen+l6lA381YzDtS/qw+D3ckaYHa3y4drYxlhmpaFB+piAJxUIA3I8Sj u+W7RiEWGpS+d26jTI3DsOWaI4t8WdzK/5b8Iwqmuc6UINly9cez0uMmNJSY4UjlcVwJ JuTD8o1Zfh3l8HyxH83M2+hxiRR+c+EjBZP3Sq4qdRJ5IDYuL5JX3CVfupUt6QkKXoiy drlQ== X-Gm-Message-State: AA+aEWZzJeJ2ZPjpxtB4PltQoowGWg1aNZUpcTwP53XYVhMDVPSOtPDg vxrDULOTg5NUr1uYvawzdID1FUhQPkw= X-Google-Smtp-Source: AFSGD/XxSmodJ2Epgply27jT7jOZDAfI+yRLGvoAwRpVDYAXd42ibDPcamkmsI7SjHqmos82edHT5w== X-Received: by 2002:a17:906:754e:: with SMTP id a14-v6mr45007336ejn.145.1546778847526; Sun, 06 Jan 2019 04:47:27 -0800 (PST) Received: from brutus ([2001:985:d55d::438]) by smtp.gmail.com with ESMTPSA id ec19-v6sm15919348ejb.11.2019.01.06.04.47.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 06 Jan 2019 04:47:27 -0800 (PST) From: Dominick Grift To: "Sugar\, David" Cc: "selinux-refpolicy\@vger.kernel.org" Subject: Re: [PATCH 2/2 v2] pam_faillock creates files in /run/faillock References: <20190106123358.18395-1-dsugar@tresys.com> <20190106123358.18395-2-dsugar@tresys.com> Date: Sun, 06 Jan 2019 13:47:26 +0100 In-Reply-To: <20190106123358.18395-2-dsugar@tresys.com> (David Sugar's message of "Sun, 6 Jan 2019 12:34:35 +0000") Message-ID: <878szy7y1t.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org "Sugar, David" writes: > 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. > > 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 | 21 +++++++++++++++++++++ > 3 files changed, 22 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 cc717e7f..37fb2a71 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..8d79af78 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($1) auth_create_faillog_files($1) auth_rw_faillog($1) auth_setattr_faillog_files($1) > auth_domtrans_chk_passwd($1) > auth_domtrans_upd_passwd($1) > auth_dontaudit_read_shadow($1) > @@ -744,6 +745,26 @@ 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',` > + gen_require(` > + type faillog_t; > + ') > + > + auth_rw_faillog($1) > + create_files_pattern($1, faillog_t, faillog_t) > + setattr_files_pattern($1, faillog_t, faillog_t) > +') interface name is not accurate: auth_create_faillog_files() auth_rw_faillog does not belong here setattr needs a seperate interface: auth_setattr_faillog_files() > + > ######################################## > ## > ## Read and write the login failure log. -- Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02 https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02 Dominick Grift