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_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 4E8A2C282DD for ; Tue, 23 Apr 2019 22:37:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 10643218D2 for ; Tue, 23 Apr 2019 22:37:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ieee.org header.i=@ieee.org header.b="G5WBqWzQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726953AbfDWWhy (ORCPT ); Tue, 23 Apr 2019 18:37:54 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:46297 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbfDWWhy (ORCPT ); Tue, 23 Apr 2019 18:37:54 -0400 Received: by mail-qk1-f194.google.com with SMTP id w73so7508944qkb.13 for ; Tue, 23 Apr 2019 15:37:53 -0700 (PDT) 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=ASxZZoMbaPtC4sMMMWTc9RdzMx72HQVbtpW+qxSqOhQ=; b=G5WBqWzQNG0rg1JyFFsMxDE7UvkVu/+VG7qKXE8ZbBLysVIT21KS26OpV4Yno9/arb zpXcp+mRCKsADrInWVA7xRgENitT/BH4qRNIMikVSNt0UniK5q0TG165SF7HRNvDDYkp PVLjIr9GXw9rzNcRFPNmQQwTZpgqYIYsHPguo= 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=ASxZZoMbaPtC4sMMMWTc9RdzMx72HQVbtpW+qxSqOhQ=; b=cEVibUN4Thi0VHzaGpZIGpv51mfYli3dz5qqnq3BJi/8ru/0g9sef5qSZQIuFJwzk6 WNEq5wrVpqyQSksWQakXAn3EglPEZPL/xHYAkooPSOyrd06+QGIoyCf7Ue91X1j91D7w ClxtEff3ZRL0iDFcdvNFw2Q7d6P+qjDoZ3EYsVfphllvfByS2Red4HMcoHTCewYRHr4e 21SuqtV1XaltzxoZOQY18uj2RbxK086ymN2uXpmhMt+PdZaJqjNC5aLdRGrRFN3d39P9 D83rUz8ZGoG0draoxcrAlkBzqbk6H95M/fshnFHGCmCXm6tdlTavebC3Hu7WvhnxKHH5 qExw== X-Gm-Message-State: APjAAAXV3k5XMG6HHdXLT7coKiLH3O74DVTufErh09XY9por/Rklnsgl pxee5tDeAa847smXuwEBo6AGAbIU0yc= X-Google-Smtp-Source: APXvYqwV1agY8EQDNzs7Q7ZFohgPZfFVj2+9idZ1OBcHIi7HP8QYHhTHnNRZ+L+JrvmNUNKbgPsqsw== X-Received: by 2002:a05:620a:166b:: with SMTP id d11mr21414789qko.1.1556059073097; Tue, 23 Apr 2019 15:37:53 -0700 (PDT) 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 a7sm8122125qkk.65.2019.04.23.15.37.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:37:52 -0700 (PDT) Subject: Re: [PATCH 2/3] Changes to support plymouth working in enforcing To: "Sugar, David" , "selinux-refpolicy@vger.kernel.org" References: <20190412193917.23886-1-dsugar@tresys.com> <20190412193917.23886-3-dsugar@tresys.com> From: Chris PeBenito Message-ID: <9a2ec89f-3aac-28db-7005-447beacf339f@ieee.org> Date: Tue, 23 Apr 2019 18:31:03 -0400 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: <20190412193917.23886-3-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 4/12/19 3:39 PM, Sugar, David wrote: > plymouth is started very early in the boot process. Looks > like before the SELinux policy is loaded so plymouthd is > running as kernel_t rather than plymouthd_t. Due to this > I needed to allow a few permissions on kernel_t to get > the system to boot. > > Please note that in this case I have the harddisk encrypted > with LUKS so when plymouthd is started the harddisk is not > unlocked yet. I don't know if the permissions are different > in the case when LUKS is not involved. > > type=AVC msg=audit(1554917011.127:225): avc: denied { write } for pid=2585 comm="plymouthd" name="plymouth" dev="tmpfs" ino=18877 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:plymouthd_var_run_t:s0 tclass=dir permissive=1 > type=AVC msg=audit(1554917011.127:226): avc: denied { remove_name } for pid=2585 comm="plymouthd" name="pid" dev="tmpfs" ino=18883 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:plymouthd_var_run_t:s0 tclass=dir permissive=1 > type=AVC msg=audit(1554917011.127:227): avc: denied { unlink } for pid=2585 comm="plymouthd" name="pid" dev="tmpfs" ino=18883 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:plymouthd_var_run_t:s0 tclass=file permissive=1 > > type=AVC msg=audit(1554917011.116:224): avc: denied { write } for pid=2585 comm="plymouthd" name="boot-duration" dev="dm-16" ino=2097285 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:plymouthd_var_lib_t:s0 tclass=file permissive=1 > > type=AVC msg=audit(1555069712.938:237): avc: denied { ioctl } for pid=2554 comm="plymouthd" path="/dev/dri/card0" dev="devtmpfs" ino=12229 ioctlcmd=64b1 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:dri_device_t:s0 tclass=chr_file permissive=0 > > Signed-off-by: Dave Sugar > --- > policy/modules/kernel/devices.if | 18 +++++++++++++ > policy/modules/kernel/kernel.te | 5 +++- > policy/modules/services/plymouthd.if | 38 ++++++++++++++++++++++++++++ > 3 files changed, 60 insertions(+), 1 deletion(-) > > diff --git a/policy/modules/kernel/devices.if b/policy/modules/kernel/devices.if > index 78a95ce8..d1cdf933 100644 > --- a/policy/modules/kernel/devices.if > +++ b/policy/modules/kernel/devices.if > @@ -1939,6 +1939,24 @@ interface(`dev_setattr_dri_dev',` > setattr_chr_files_pattern($1, device_t, dri_device_t) > ') > > +######################################## > +## > +## IOCLT the dri devices. > +## > +## > +## > +## Domain allowed access. > +## > +## > +# > +interface(`dev_ioctl_dri_dev',` > + gen_require(` > + type device_t, dri_device_t; > + ') > + > + allow $1 dri_device_t:chr_file ioctl; > +') > + > ######################################## > ## > ## Read and write the dri devices. > diff --git a/policy/modules/kernel/kernel.te b/policy/modules/kernel/kernel.te > index b9ae4079..d230a5a2 100644 > --- a/policy/modules/kernel/kernel.te > +++ b/policy/modules/kernel/kernel.te > @@ -397,9 +397,12 @@ optional_policy(` > ') > > optional_policy(` > - plymouthd_read_lib_files(kernel_t) > + dev_ioctl_dri_dev(kernel_t) > + > + plymouthd_delete_pid_files(kernel_t) > plymouthd_read_pid_files(kernel_t) > plymouthd_read_spool_files(kernel_t) > + plymouthd_rw_lib_files(kernel_t) > > term_use_ptmx(kernel_t) > term_use_unallocated_ttys(kernel_t) > diff --git a/policy/modules/services/plymouthd.if b/policy/modules/services/plymouthd.if > index 04e0c734..3cc08b96 100644 > --- a/policy/modules/services/plymouthd.if > +++ b/policy/modules/services/plymouthd.if > @@ -192,6 +192,25 @@ interface(`plymouthd_read_lib_files',` > read_files_pattern($1, plymouthd_var_lib_t, plymouthd_var_lib_t) > ') > > +######################################## > +## > +## Read and write plymouthd lib files. > +## > +## > +## > +## Domain allowed access. > +## > +## > +# > +interface(`plymouthd_rw_lib_files',` > + gen_require(` > + type plymouthd_var_lib_t; > + ') > + > + files_search_var_lib($1) > + rw_files_pattern($1, plymouthd_var_lib_t, plymouthd_var_lib_t) > +') > + > ######################################## > ## > ## Create, read, write, and delete > @@ -232,6 +251,25 @@ interface(`plymouthd_read_pid_files',` > allow $1 plymouthd_var_run_t:file read_file_perms; > ') > > +######################################## > +## > +## Delete the plymouthd pid files. > +## > +## > +## > +## Domain allowed access. > +## > +## > +# > +interface(`plymouthd_delete_pid_files',` > + gen_require(` > + type plymouthd_var_run_t; > + ') > + > + files_search_pids($1) > + delete_files_pattern($1, plymouthd_var_run_t, plymouthd_var_run_t) > +') > + > ######################################## > ## > ## All of the rules required to Merged. -- Chris PeBenito