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=-2.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT 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 F4169C43387 for ; Thu, 10 Jan 2019 01:40:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AD3D5214DA for ; Thu, 10 Jan 2019 01:40:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=perfinion-com.20150623.gappssmtp.com header.i=@perfinion-com.20150623.gappssmtp.com header.b="mrjPN9NX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726580AbfAJBkJ (ORCPT ); Wed, 9 Jan 2019 20:40:09 -0500 Received: from mail-pg1-f179.google.com ([209.85.215.179]:41514 "EHLO mail-pg1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726425AbfAJBkJ (ORCPT ); Wed, 9 Jan 2019 20:40:09 -0500 Received: by mail-pg1-f179.google.com with SMTP id m1so4105169pgq.8 for ; Wed, 09 Jan 2019 17:40:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perfinion-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MlY4Ec79emqSqRYKMYCp7wMgL8sw+MzUZQZ9C74tHU0=; b=mrjPN9NXVx7bKD06DtYRe+ohckFjfQ5USHMqs9xkuEy4ZSNO4RmDk0aGWbEI86E6WH GoiUQegOSYqulwIuOCmW6dsW/pAuhF8t1KbWI56f8eP5xsNQQX0af21CsH8vpSXvb1H5 +Mr2buYlOzcsfns5/KL0FFSSgLKZ83FLEjzFTKzSKWaBUkX4JYd1HP9dZlJIcVNITrcn dIuGiwvi6lwTS5DG5lHxkT261iRqgIOGuzCfIFXzIEgKJLs+gIOVHD3MMedKiHLrR5NN Ddu7wrUUAS5AkQXlb2NSmJJs5TrKYOY/KKK3KtlgbpfH3dS7B+5MIASaLzCTpKowCxC3 LYsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=MlY4Ec79emqSqRYKMYCp7wMgL8sw+MzUZQZ9C74tHU0=; b=JxWO0degMv0OWjYBgxx/Vl3KrDAV/foc/c/mEvc1QjaHsFL3jmKBRl2I1Z+9RyPkNu Fo7I4NkMBxrI7mIS9AvHd8bKmK0+e0osdya98lGwQH1LOOI+orkXmoxxdPYW4/b3zIGM 7CKBBf7eJltvQghzPSFP8P2sR0XmE+YLyanmcq+lcBs/xjtO7Jdlh+AcACUMFV6+bgcT qT49/0oMW6VZ6Jt38qzJqVnb4uSC2BbQplJ9Bbxorelm8ugzyJqOMhgR2lJbYZr1tkMy 2wQlJNwbqRr7Q+/fKVtwqS29DrZ/2Ahsg4zLUirW0zfr/hjfJogqw8mwQGCDSExOK/cK PzlA== X-Gm-Message-State: AJcUukdUjIMuMM2OW6/lGT9mSc9FpdnBSk8BL3e08miGCoZi2/9jxmG4 fXrCyTBUokzk8Uk4mZj8/EQyfQ== X-Google-Smtp-Source: ALg8bN6Iq4zytbpqkEJn8th6WNvXoi3hDv7dzotPtzZBsF7efidneOzw1/3QiXc5Oxe4b6DPPW+FqQ== X-Received: by 2002:a62:d2c1:: with SMTP id c184mr8341094pfg.248.1547084407866; Wed, 09 Jan 2019 17:40:07 -0800 (PST) Received: from localhost ([2406:3003:2002:40c2:7952:f8f0:5b6c:6fa3]) by smtp.gmail.com with ESMTPSA id p67sm125315448pfg.44.2019.01.09.17.40.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 17:40:07 -0800 (PST) Date: Thu, 10 Jan 2019 09:40:05 +0800 From: Jason Zaman To: Russell Coker Cc: selinux-refpolicy@vger.kernel.org Subject: Re: [PATCH] gpg Message-ID: <20190110014005.GB6715@baraddur.perfinion.com> References: <20190108085110.GA28727@xev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190108085110.GA28727@xev> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org Can you hold off on merging this first, I had done some GPG changes in the gentoo policy not that long ago to work with the new way gpg / gpg_agent works and I want to compare that to this before it goes in. -- Jason On Tue, Jan 08, 2019 at 07:51:10PM +1100, 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. > Also remove gpg_helper_t and gpg_pinentry_t because they don't do any good. > . > 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(`