Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4035469ybv; Sun, 16 Feb 2020 12:04:08 -0800 (PST) X-Google-Smtp-Source: APXvYqwn+FRFJn+kw9sc6JXNFlrl5B0qPqK3RYZ/kQIy0dBuol+TtEip3lk+L1xG0VLVYTpbf9Vs X-Received: by 2002:a9d:864:: with SMTP id 91mr7121608oty.289.1581883448415; Sun, 16 Feb 2020 12:04:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581883448; cv=none; d=google.com; s=arc-20160816; b=duaaDLLLeDFsBodUZVDz4FdTdf5hJSSSq81RzzyUXXk/eQR9WiqssYe5IqhTh+Xkuk Dh7FKxWFjz9hMifdnPCmAw91g/jHgeJZChSU5VdgGi9cLbMyLAJfEwSgoQHUWeZg6beN jVw7FmkQXlj8x9Zw0ldf8x7D1HLMxRGlgXPe9yc/vRfw0OXi4BDuYUUplyBvLGZDLYFn iVjWDMFlWe+K4lLVJZpug+f05e9r5FhgiG0aW+ynf6MvU6FBYUZy/py81Z6IkNmw+0St K4XCTwAQdGZqYNADt1UGtMweHZr4FY5D0/+97KzhD9bnFirxQplz8KZNkYzn+Q3X/eeq uWuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2kTSv217Jk2ACrWEodNY+kNSQ7GaXs9WjTSNSQP1kp8=; b=sUVNZxmaoTOFFxhCT82HKklCerf0sz5TI+9FabzC+/yooHkBGiuIanZVrOleIk579B 1rhSvXkvJm18IHTWVmOzdZaKvhHZhcu/QsgfDZNhVPXdU5+5MMmuP/pwDNLoT2Qo8z/m qUBErUBDunj+BbcmQShfXYgPoqUWyQEm2ao2CEVgMx1xRNsWgeqR754lDq1UDW3ZQQOE M7omKd7Yb7mUO2CAQYQwAEzH4gCkrrZF8GVROjdExkmxbuwqFHXzMnuTBwiJ87RoiYXa JtpuOhVXtF1nSCG3bHG/AtCg1Vd0R2NiO1JcMvcM3d1lY3ZWbANxMrX5aq0QyhktIR0z jmPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@perfinion-com.20150623.gappssmtp.com header.s=20150623 header.b=LjaNdevP; spf=pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s22si5287396oij.35.2020.02.16.12.04.06; Sun, 16 Feb 2020 12:04:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@perfinion-com.20150623.gappssmtp.com header.s=20150623 header.b=LjaNdevP; spf=pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726043AbgBPUEG (ORCPT + 13 others); Sun, 16 Feb 2020 15:04:06 -0500 Received: from mail-pj1-f53.google.com ([209.85.216.53]:35457 "EHLO mail-pj1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725989AbgBPUEF (ORCPT ); Sun, 16 Feb 2020 15:04:05 -0500 Received: by mail-pj1-f53.google.com with SMTP id q39so6254596pjc.0 for ; Sun, 16 Feb 2020 12:04:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perfinion-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2kTSv217Jk2ACrWEodNY+kNSQ7GaXs9WjTSNSQP1kp8=; b=LjaNdevPSe1Ec1vU8NW2bKYeEin6+NVCgKeBKldmQ07ZcGzVkbCFOCISzL+xGIxZWK XQNn/kOIgeKFjOnovFRf/SiduV+0V33Blsqbyccqaqk5SClNbEd6kfFEIp2i1qR9jFiU 6c+waTlTJnFfj9QU6yoTMjp5EJgk+E80Q60ioRT7pozmi2X2IaupGxJ4FoNmjrJbl1on 2HgDcD9L1phcDbLdx37B8VUzg1FWyn++5SpL07shp/zfF2/BSd99cEX4TXU3mntqKqGj F2O2/i6VRKxNB6Yhq0WrBGLuM1irpeLxKHP98xLbtxLF7LOdgBEdTsug3jyzzbSzsCkJ x5VQ== 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2kTSv217Jk2ACrWEodNY+kNSQ7GaXs9WjTSNSQP1kp8=; b=WuI+DdY9Lxso/wjlRPVdgGe3KtiDmTHYWgEK30YRMnG/X0Jyr6HzLhknoTWx2nYaKG V7sWoX8fw/88RTD5bwL05+d9/UNxDLanWB8Q4hJAaBgPxd8Q+E5gsp1Wxawsh4L1KV0q 8DoYOIXJ5Ce6S8KiU3XmUncf5Dj9orvq7vtce1czFYXRS+dMsw6+1p9AdGqXEFSMXoyt tjopMgin8/yo/xwC7WQol1gdaa4uektbGh8RpeIq+COcXuh2wUtamYp/fbu14HSikGLe faRL6WdM+rEpExTk8LynOEM1wtA6WB2xKVWZGsNGGvn4sndWRoLpyUCNgVeKW8UeuGeF gsiw== X-Gm-Message-State: APjAAAVRlfeW2CmML5wZSrdIHrikQv7UxEGyLtFGNS0VUBfoGsuHiQ4e u2pHKLUCe1VebGhBRZ/yzUiq9eFsgCQ= X-Received: by 2002:a17:902:8ec9:: with SMTP id x9mr12971915plo.182.1581883444351; Sun, 16 Feb 2020 12:04:04 -0800 (PST) Received: from localhost ([101.127.140.252]) by smtp.gmail.com with ESMTPSA id 13sm13480739pfi.78.2020.02.16.12.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2020 12:04:03 -0800 (PST) From: Jason Zaman To: selinux-refpolicy@vger.kernel.org Cc: Jason Zaman Subject: [PATCH 07/10] userdomain: Add watch on home dirs Date: Mon, 17 Feb 2020 04:03:16 +0800 Message-Id: <20200216200319.39337-7-jason@perfinion.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200216200319.39337-1-jason@perfinion.com> References: <20200216200319.39337-1-jason@perfinion.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org avc: denied { watch } for pid=12351 comm="gmain" path="/usr/share/backgrounds/xfce" dev="zfs" ino=366749 scontext=staff_u:staff_r:staff_t:s0-s0:c0.c1023 tcontext=system_u:object_r:usr_t:s0 tclass=dir permissive=0 avc: denied { watch } for pid=11646 comm="gmain" path="/etc/fonts" dev="zfs" ino=237700 scontext=staff_u:staff_r:staff_t:s0-s0:c0.c1023 tcontext=system_u:object_r:fonts_t:s0 tclass=dir permissive=0 avc: denied { watch } for pid=12351 comm="gmain" path="/home/jason/Desktop" dev="zfs" ino=33153 scontext=staff_u:staff_r:staff_t:s0-s0:c0.c1023 tcontext=staff_u:object_r:user_home_t:s0 tclass=dir permissive=0 avc: denied { watch } for pid=12574 comm="gmain" path="/home/jason/.local/share/icc" dev="zfs" ino=1954514 scontext=staff_u:staff_r:staff_t:s0-s0:c0.c1023 tcontext=staff_u:object_r:xdg_data_t:s0 tclass=dir permissive=0 avc: denied { watch } for pid=11795 comm="gmain" path="/home/jason/.config/xfce4/panel/launcher-19" dev="zfs" ino=35464 scontext=staff_u:staff_r:staff_t:s0-s0:c0.c1023 tcontext=staff_u:object_r:xdg_config_t:s0 tclass=dir permissive=0 avc: denied { watch } for pid=12351 comm="gmain" path="/home/jason/downloads/pics" dev="zfs" ino=38173 scontext=staff_u:staff_r:staff_t:s0-s0:c0.c1023 tcontext=staff_u:object_r:xdg_downloads_t:s0 tclass=dir permissive=0 Signed-off-by: Jason Zaman --- policy/modules/services/xserver.if | 11 +- policy/modules/system/miscfiles.if | 37 ++++++ policy/modules/system/userdomain.if | 15 +++ policy/modules/system/xdg.if | 198 ++++++++++++++++++++++++++++ 4 files changed, 260 insertions(+), 1 deletion(-) diff --git a/policy/modules/services/xserver.if b/policy/modules/services/xserver.if index c95a6b04..99c1a7ea 100644 --- a/policy/modules/services/xserver.if +++ b/policy/modules/services/xserver.if @@ -95,6 +95,7 @@ interface(`xserver_restricted_role',` dev_rw_usbfs($2) miscfiles_read_fonts($2) + miscfiles_watch_fonts_dirs($2) xserver_common_x_domain_template(user, $2) xserver_domtrans($2) @@ -186,10 +187,13 @@ interface(`xserver_role',` optional_policy(` xdg_manage_all_cache($2) xdg_relabel_all_cache($2) + xdg_watch_all_cache_dirs($2) xdg_manage_all_config($2) xdg_relabel_all_config($2) + xdg_watch_all_config_dirs($2) xdg_manage_all_data($2) xdg_relabel_all_data($2) + xdg_watch_all_data_dirs($2) xdg_generic_user_home_dir_filetrans_cache($2, dir, ".cache") xdg_generic_user_home_dir_filetrans_config($2, dir, ".config") @@ -203,14 +207,19 @@ interface(`xserver_role',` xdg_manage_documents($2) xdg_relabel_documents($2) + xdg_watch_documents_dirs($2) xdg_manage_downloads($2) xdg_relabel_downloads($2) + xdg_watch_downloads_dirs($2) xdg_manage_music($2) xdg_relabel_music($2) + xdg_watch_music_dirs($2) xdg_manage_pictures($2) xdg_relabel_pictures($2) + xdg_watch_pictures_dirs($2) xdg_manage_videos($2) xdg_relabel_videos($2) + xdg_watch_videos_dirs($2) xdg_cache_filetrans($2, mesa_shader_cache_t, dir, "mesa_shader_cache") ') @@ -508,7 +517,7 @@ interface(`xserver_use_user_fonts',` ') # Read per user fonts - allow $1 user_fonts_t:dir list_dir_perms; + allow $1 user_fonts_t:dir { list_dir_perms watch }; allow $1 user_fonts_t:file { map read_file_perms }; # Manipulate the global font cache diff --git a/policy/modules/system/miscfiles.if b/policy/modules/system/miscfiles.if index 47330a48..6fbacc04 100644 --- a/policy/modules/system/miscfiles.if +++ b/policy/modules/system/miscfiles.if @@ -252,6 +252,25 @@ interface(`miscfiles_manage_generic_tls_privkey_files',` read_lnk_files_pattern($1, tls_privkey_t, tls_privkey_t) ') +######################################## +## +## Watch fonts. +## +## +## +## Domain allowed access. +## +## +## +# +interface(`miscfiles_watch_fonts_dirs',` + gen_require(` + type fonts_t; + ') + + allow $1 fonts_t:dir watch; +') + ######################################## ## ## Read fonts. @@ -805,6 +824,24 @@ interface(`miscfiles_manage_public_files',` manage_lnk_files_pattern($1, public_content_rw_t, public_content_rw_t) ') +######################################## +## +## Watch public files +## +## +## +## Domain allowed access. +## +## +# +interface(`miscfiles_watch_public_dirs',` + gen_require(` + type public_content_rw_t; + ') + + allow $1 public_content_rw_t:dir watch; +') + ######################################## ## ## Read TeX data diff --git a/policy/modules/system/userdomain.if b/policy/modules/system/userdomain.if index dd555850..6645c56a 100644 --- a/policy/modules/system/userdomain.if +++ b/policy/modules/system/userdomain.if @@ -285,6 +285,12 @@ interface(`userdom_ro_home_role',` read_sock_files_pattern($2, { user_home_t user_home_dir_t }, user_home_t) files_list_home($2) + allow $2 { user_home_t user_home_dir_t }:dir { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 { user_home_t user_home_dir_t }:file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 { user_home_t user_home_dir_t }:lnk_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 { user_home_t user_home_dir_t }:sock_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 { user_home_t user_home_dir_t }:fifo_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + tunable_policy(`use_nfs_home_dirs',` fs_list_nfs($2) fs_read_nfs_files($2) @@ -364,6 +370,12 @@ interface(`userdom_manage_home_role',` # cjp: this should probably be removed: allow $2 user_home_dir_t:dir { manage_dir_perms relabel_dir_perms }; + allow $2 { user_home_t user_home_dir_t }:dir { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 { user_home_t user_home_dir_t }:file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 { user_home_t user_home_dir_t }:lnk_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 { user_home_t user_home_dir_t }:sock_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 { user_home_t user_home_dir_t }:fifo_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + userdom_manage_user_certs($2) userdom_user_home_dir_filetrans($2, user_cert_t, dir, ".pki") @@ -618,6 +630,8 @@ template(`userdom_common_user_template',` files_read_var_lib_files($1_t) # Stat lost+found. files_getattr_lost_found_dirs($1_t) + files_watch_etc_dirs($1_t) + files_watch_usr_dirs($1_t) fs_rw_cgroup_files($1_t) @@ -1166,6 +1180,7 @@ template(`userdom_unpriv_user_template', ` files_exec_usr_files($1_t) miscfiles_manage_public_files($1_t) + miscfiles_watch_public_dirs($1_t) tunable_policy(`user_dmesg',` kernel_read_ring_buffer($1_t) diff --git a/policy/modules/system/xdg.if b/policy/modules/system/xdg.if index 11fc4306..82304241 100644 --- a/policy/modules/system/xdg.if +++ b/policy/modules/system/xdg.if @@ -83,6 +83,42 @@ interface(`xdg_search_cache_dirs',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg cache home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_cache_dirs',` + gen_require(` + type xdg_cache_t; + ') + + allow $1 xdg_cache_t:dir watch; +') + +######################################## +## +## Watch all the xdg cache home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_all_cache_dirs',` + gen_require(` + attribute xdg_cache_type; + ') + + allow $1 xdg_cache_type:dir watch; +') + ######################################## ## ## Read the xdg cache home files @@ -333,6 +369,42 @@ interface(`xdg_search_config_dirs',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg config home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_config_dirs',` + gen_require(` + type xdg_config_t; + ') + + allow $1 xdg_config_t:dir watch; +') + +######################################## +## +## Watch all the xdg config home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_all_config_dirs',` + gen_require(` + attribute xdg_config_type; + ') + + allow $1 xdg_config_type:dir watch; +') + ######################################## ## ## Read the xdg config home files @@ -563,6 +635,42 @@ interface(`xdg_relabel_all_config',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg data home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_data_dirs',` + gen_require(` + type xdg_data_t; + ') + + allow $1 xdg_data_t:dir watch; +') + +######################################## +## +## Watch all the xdg data home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_all_data_dirs',` + gen_require(` + attribute xdg_data_type; + ') + + allow $1 xdg_data_type:dir watch; +') + ######################################## ## ## Read the xdg data home files @@ -793,6 +901,24 @@ interface(`xdg_relabel_all_data',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg documents home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_documents_dirs',` + gen_require(` + type xdg_documents_t; + ') + + allow $1 xdg_documents_t:dir watch; +') + ######################################## ## ## Create objects in the user home dir with an automatic type transition to @@ -865,6 +991,24 @@ interface(`xdg_relabel_documents',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg downloads home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_downloads_dirs',` + gen_require(` + type xdg_downloads_t; + ') + + allow $1 xdg_downloads_t:dir watch; +') + ######################################### ## ## Read downloaded content @@ -1006,6 +1150,24 @@ interface(`xdg_relabel_downloads',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg pictures home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_pictures_dirs',` + gen_require(` + type xdg_pictures_t; + ') + + allow $1 xdg_pictures_t:dir watch; +') + ######################################### ## ## Read user pictures content @@ -1101,6 +1263,24 @@ interface(`xdg_relabel_pictures',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg music home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_music_dirs',` + gen_require(` + type xdg_music_t; + ') + + allow $1 xdg_music_t:dir watch; +') + ######################################### ## ## Read user music content @@ -1196,6 +1376,24 @@ interface(`xdg_relabel_music',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg video content +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_videos_dirs',` + gen_require(` + type xdg_videos_t; + ') + + allow $1 xdg_videos_t:dir watch; +') + ######################################### ## ## Read user video content -- 2.24.1