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=-5.7 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 A4B0DC43387 for ; Thu, 10 Jan 2019 00:37:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 60E94214C6 for ; Thu, 10 Jan 2019 00:37:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ieee.org header.i=@ieee.org header.b="MLFd7BTw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726492AbfAJAhK (ORCPT ); Wed, 9 Jan 2019 19:37:10 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:35436 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726286AbfAJAhJ (ORCPT ); Wed, 9 Jan 2019 19:37:09 -0500 Received: by mail-qt1-f196.google.com with SMTP id v11so10568021qtc.2 for ; Wed, 09 Jan 2019 16:37:08 -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=Sa2KQfA+tFb3dzayX/2dtrHaLdT3i3djarmuvg9zVOg=; b=MLFd7BTwJ8sYE76VvktYJBkB+ZPXjYS+qWtr1yws6JKiasqG/7EPCn5bU2WHv+FwSf og2/qlRMjmyk9VNCwbYXTaGHV/BiJN1bRSGvqFXWfq6nigNyfrPExZGcJ09Int+F4RmD 1NnVwCsVQjSw8kmgSvkEG/kWCWi+svMZZWfzk= 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=Sa2KQfA+tFb3dzayX/2dtrHaLdT3i3djarmuvg9zVOg=; b=mnq+rzQkjH5RyU47a4jQRMgib4qSOtIl0p5z9pzZ0RYZFC9yBSsmquHfPdPiD/7uwQ iCa4myTUQ2FzI1Z1C0ZvKVN4QwlEPco2eCK5Braav2V/D3px1kwvU5OrTOEpkf0JvSTT YIRelYTsf82uYtYyPZUjHanCePhgWvPH4zq28+iv8K6oyGsHC1mZ2fj1Np2kG0FpGPVt koA3hRaN/Z9+cBD3icpZygJx1WKx4Ela4oxCVPcutt2HLI0XZjXRxMzgkAgPn/+GSYYp 62XFbpsQPlw3hUnnuHZtpCw/redF4v0G+1rY+6B3PjQFuxHaF2RqSUugpQYGNjCiwGwZ QkSg== X-Gm-Message-State: AJcUukdvbUalZM5NJhCOHWpm8XuOY6Yb9JM0CoHKXPox+Q65r6ggxQB9 XxBrvKyqjOKGfYrL0Ea5R7pn2CP87go= X-Google-Smtp-Source: ALg8bN6qS24HUXR6sVZLgh9grdJ7+JlNrT8gBA1ofUl2BOiX6gCmFozY8yeXF6zHZci5Rw3T102XLg== X-Received: by 2002:a0c:baa8:: with SMTP id x40mr7951774qvf.18.1547080627909; Wed, 09 Jan 2019 16:37:07 -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 o8sm7813615qkg.60.2019.01.09.16.37.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 16:37:07 -0800 (PST) Subject: Re: [PATCH] gpg To: Russell Coker , selinux-refpolicy@vger.kernel.org References: <20190108085110.GA28727@xev> From: Chris PeBenito Message-ID: Date: Wed, 9 Jan 2019 19:11:20 -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: <20190108085110.GA28727@xev> 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/8/19 3:51 AM, Russell Coker wrote: > > Description: Create user_gpg_t etc domains, remove gpg_helper_t & gpg_pinentry_t > Only transition to gpg_t from user_t to solve problems with X sessions. I'd keep staff too, as that is also an unpriv role. > Also remove gpg_helper_t and gpg_pinentry_t because they don't do any good. Can you give a little more of an argument as to why they're not helpful? I'm not against this, but I don't see what the argument is. Also, if they are removed, all the rules need to be removed, not just eliminate the labeling. > Author: Russell Coker > Last-Update: 2015-01-12 > > Index: refpolicy-2.20180701/policy/modules/apps/gpg.fc > =================================================================== > --- refpolicy-2.20180701.orig/policy/modules/apps/gpg.fc > +++ refpolicy-2.20180701/policy/modules/apps/gpg.fc > @@ -6,10 +6,10 @@ HOME_DIR/\.gnupg/S\.scdaemon -s gen_con > /usr/bin/gpg(2)? -- gen_context(system_u:object_r:gpg_exec_t,s0) > /usr/bin/gpgsm -- gen_context(system_u:object_r:gpg_exec_t,s0) > /usr/bin/gpg-agent -- gen_context(system_u:object_r:gpg_agent_exec_t,s0) > -/usr/bin/pinentry.* -- gen_context(system_u:object_r:gpg_pinentry_exec_t,s0) > +/usr/bin/pinentry.* -- gen_context(system_u:object_r:gpg_exec_t,s0) > > /usr/lib/gnupg/.* -- gen_context(system_u:object_r:gpg_exec_t,s0) > -/usr/lib/gnupg/gpgkeys.* -- gen_context(system_u:object_r:gpg_helper_exec_t,s0) > +/usr/lib/gnupg/gpgkeys.* -- gen_context(system_u:object_r:gpg_exec_t,s0) > > /run/user/%{USERID}/gnupg(/.*)? gen_context(system_u:object_r:gpg_runtime_t,s0) > /run/user/%{USERID}/gnupg/S\.gpg-agent.* -s gen_context(system_u:object_r:gpg_agent_tmp_t,s0) > Index: refpolicy-2.20180701/policy/modules/roles/staff.te > =================================================================== > --- refpolicy-2.20180701.orig/policy/modules/roles/staff.te > +++ refpolicy-2.20180701/policy/modules/roles/staff.te > @@ -118,10 +118,6 @@ ifndef(`distro_redhat',` > ') > > optional_policy(` > - gpg_role(staff_r, staff_t) > - ') > - > - optional_policy(` > irc_role(staff_r, staff_t) > ') > > Index: refpolicy-2.20180701/policy/modules/roles/sysadm.te > =================================================================== > --- refpolicy-2.20180701.orig/policy/modules/roles/sysadm.te > +++ refpolicy-2.20180701/policy/modules/roles/sysadm.te > @@ -1304,10 +1304,6 @@ ifndef(`distro_redhat',` > ') > > optional_policy(` > - gpg_role(sysadm_r, sysadm_t) > - ') > - > - optional_policy(` > irc_role(sysadm_r, sysadm_t) > ') > > Index: refpolicy-2.20180701/policy/modules/apps/gpg.if > =================================================================== > --- refpolicy-2.20180701.orig/policy/modules/apps/gpg.if > +++ refpolicy-2.20180701/policy/modules/apps/gpg.if > @@ -31,6 +31,11 @@ interface(`gpg_role',` > domtrans_pattern($2, gpg_exec_t, gpg_t) > domtrans_pattern($2, gpg_agent_exec_t, gpg_agent_t) > > + # transition to user_t when running ck-launch-session or other bin_t > + corecmd_bin_domtrans(gpg_agent_t, $2) > + allow gpg_agent_t $2:process signull; > + allow $2 gpg_agent_t:fd use; > + > allow $2 self:process setrlimit; > allow $2 { gpg_t gpg_agent_t gpg_helper_t gpg_pinentry_t }:process { ptrace signal_perms }; > ps_process_pattern($2, { gpg_t gpg_agent_t gpg_helper_t gpg_pinentry_t }) > @@ -46,6 +51,9 @@ interface(`gpg_role',` > filetrans_pattern($2, gpg_secret_t, gpg_agent_tmp_t, sock_file, "log-socket") > userdom_user_home_dir_filetrans($2, gpg_secret_t, dir, ".gnupg") > > + # so gpg_agent_t can append to .xsession-errors > + userdom_append_inherited_user_home_content_files(gpg_agent_t) > + > optional_policy(` > gpg_pinentry_dbus_chat($2) > ') > @@ -179,6 +187,28 @@ interface(`gpg_signal',` > allow $1 gpg_t:process signal; > ') > > +####################################### > +## > +## Transition to $2_gpg_agent_t from another domain via gpg_agent_exec_t > +## > +## > +## > +## source domain > +## > +## > +## > +## > +## base of target domain > +## > +## > +# > +interface(`gpg_enter_user_gpg_agent_domain',` > + gen_require(` > + type gpg_agent_exec_t, $2_gpg_agent_t; > + ') > + domain_auto_transition_pattern($1, gpg_agent_exec_t, $2_gpg_agent_t) > +') > + > ######################################## > ## > ## Read and write gpg agent pipes. > Index: refpolicy-2.20180701/policy/modules/roles/unprivuser.te > =================================================================== > --- refpolicy-2.20180701.orig/policy/modules/roles/unprivuser.te > +++ refpolicy-2.20180701/policy/modules/roles/unprivuser.te > @@ -157,8 +157,9 @@ ifndef(`distro_redhat',` > spamassassin_role(user_r, user_t) > ') > > - optional_policy(` > + optional_policy(` > ssh_role_template(user, user_r, user_t) > + gpg_enter_user_gpg_agent_domain(user_ssh_agent_t) > ') > > optional_policy(` > Index: refpolicy-2.20180701/policy/modules/system/userdomain.if > =================================================================== > --- refpolicy-2.20180701.orig/policy/modules/system/userdomain.if > +++ refpolicy-2.20180701/policy/modules/system/userdomain.if > @@ -2139,6 +2139,24 @@ interface(`userdom_dontaudit_append_user > > ######################################## > ## > +## Allow append on inherited user home files. > +## > +## > +## > +## Domain to allow. > +## > +## > +# > +interface(`userdom_append_inherited_user_home_content_files',` > + gen_require(` > + type user_home_t; > + ') > + > + allow $1 user_home_t:file { append getattr ioctl }; > +') > + > +######################################## > +## > ## Do not audit attempts to write user home files. > ## > ## > Index: refpolicy-2.20180701/policy/modules/services/ssh.if > =================================================================== > --- refpolicy-2.20180701.orig/policy/modules/services/ssh.if > +++ refpolicy-2.20180701/policy/modules/services/ssh.if > @@ -373,6 +373,7 @@ template(`ssh_role_template',` > ps_process_pattern($3, $1_ssh_agent_t) > > domtrans_pattern($3, ssh_agent_exec_t, $1_ssh_agent_t) > + userdom_append_inherited_user_home_content_files($1_ssh_agent_t) > > kernel_read_kernel_sysctls($1_ssh_agent_t) > > Index: refpolicy-2.20180701/policy/modules/services/dbus.if > =================================================================== > --- refpolicy-2.20180701.orig/policy/modules/services/dbus.if > +++ refpolicy-2.20180701/policy/modules/services/dbus.if > @@ -75,6 +75,9 @@ template(`dbus_role_template',` > domain_entry_file($1_dbusd_t, dbusd_exec_t) > ubac_constrained($1_dbusd_t) > > + # for .xsession-errors > + userdom_append_inherited_user_home_content_files($1_dbusd_t) > + > role $2 types $1_dbusd_t; > > ############################## > @@ -82,7 +85,7 @@ template(`dbus_role_template',` > # Local policy > # > > - allow $3 $1_dbusd_t:unix_stream_socket connectto; > + allow $3 $1_dbusd_t:unix_stream_socket { connectto rw_socket_perms }; > allow $3 $1_dbusd_t:dbus { send_msg acquire_svc }; > allow $3 $1_dbusd_t:fd use; > > @@ -213,7 +216,7 @@ interface(`dbus_all_session_bus_client', > allow $1 { session_bus_type self }:dbus send_msg; > allow session_bus_type $1:dbus send_msg; > > - allow $1 session_bus_type:unix_stream_socket connectto; > + allow $1 session_bus_type:unix_stream_socket { connectto rw_socket_perms }; > allow $1 session_bus_type:fd use; > ') > > @@ -246,7 +249,7 @@ interface(`dbus_spec_session_bus_client' > allow $2 { $1_dbusd_t self }:dbus send_msg; > allow $1_dbusd_t $2:dbus send_msg; > > - allow $2 $1_dbusd_t:unix_stream_socket connectto; > + allow $2 $1_dbusd_t:unix_stream_socket { connectto rw_socket_perms }; > allow $2 $1_dbusd_t:fd use; > ') > > Index: refpolicy-2.20180701/policy/modules/services/cron.if > =================================================================== > --- refpolicy-2.20180701.orig/policy/modules/services/cron.if > +++ refpolicy-2.20180701/policy/modules/services/cron.if > @@ -862,10 +862,31 @@ interface(`cron_read_system_job_tmp_file > ') > > files_search_tmp($1) > + allow $1 system_cronjob_tmp_t:dir search_dir_perms; > allow $1 system_cronjob_tmp_t:file read_file_perms; > ') > > ######################################## > +## > +## Read/write system cron job temporary files. > +## > +## > +## > +## Domain allowed access. > +## > +## > +# > +interface(`cron_rw_system_job_tmp_files',` > + gen_require(` > + type system_cronjob_tmp_t; > + ') > + > + files_search_tmp($1) > + allow $1 system_cronjob_tmp_t:dir search_dir_perms; > + allow $1 system_cronjob_tmp_t:file rw_file_perms; > +') > + > +######################################## > ## > ## Do not audit attempts to append temporary > ## system cron job files. > Index: refpolicy-2.20180701/policy/modules/apps/gpg.te > =================================================================== > --- refpolicy-2.20180701.orig/policy/modules/apps/gpg.te > +++ refpolicy-2.20180701/policy/modules/apps/gpg.te > @@ -184,8 +184,9 @@ optional_policy(` > ') > > optional_policy(` > - cron_system_entry(gpg_t, gpg_exec_t) > cron_read_system_job_tmp_files(gpg_t) > + cron_rw_system_job_tmp_files(gpg_t) > + cron_system_entry(gpg_t, gpg_exec_t) > ') > > optional_policy(` > -- Chris PeBenito