Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3573556pxb; Mon, 16 Nov 2020 19:46:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrSMU7ftzrXjL3vkNSvL6evtfWuzkABBLv4vtjFT7dMVM5eDSSNzARKHFxx8zZqYmxMRQR X-Received: by 2002:aa7:d890:: with SMTP id u16mr18897949edq.159.1605584812269; Mon, 16 Nov 2020 19:46:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605584812; cv=none; d=google.com; s=arc-20160816; b=qZ9aFv/JdLMfu0OzeVDU9QtjMHoiimKJ5ibJS2aaiOYF2/aPxA6Dng9+AvOqo4eABN e5BeQSMPMs1yhDDJCceLC81drjwGbWSH5Ui/Zoj/g/zYJhyt6/c25Ark9lby3PuuSkjn g1TDWI5jkx2Wb8rkvVFz/ot/IPTG4iwo5kcaM2IQ2gh2C8525FYuezL3E0WCGltgrPPF LOvy+RMIYgwDJItuDfP5dQcg6rlmt7UbB1aGQiZzewojh912QdsidWMkljc6hfhDbuwO zC194EL8CPKpTY3MD1TQ8CRelQ2XLfkbNS0R9L0ZH/b+KaNzdJB8yLnHXocFkDGAmrSV AELA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ry/grlrwAYhAppgY6XzXb/u0/JUtINorUIX1oaiw220=; b=Vab4DbZUTE+tQRL//c5atsqUJ+BQZ5/t/sLnz5r1humqaRBFHCsEiN6o8Hh/dLxCcN rnhWXmwyWA92Mx0lp7lcwzi/UuE9D+UDieXi55LiH1fR4/kGLJnuLAYsx2LC5yMUmEN2 TXpPltbry4f8wsnom94Mr6Kp5qZjiM3sc3q7uDod0mpbJkE+xFqAKU5rBT3ojbJlSHEX 8EzG/LT8iM5O6CjsIKtKP2k0T/Q5B8HiCr+GkYytWebOZWyd0WAQSLoBZCxmQTn5Elx0 o5fRvs/mS2ElOq8nlwnYLKUaWgAVE2LljmEJ9KI3Hr6/zphUDSJejBw8Ms8q0DMyHVjx ldBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@perfinion-com.20150623.gappssmtp.com header.s=20150623 header.b=P81R8t+9; spf=pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hh13si13124503ejb.360.2020.11.16.19.46.44; Mon, 16 Nov 2020 19:46:52 -0800 (PST) Received-SPF: pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@perfinion-com.20150623.gappssmtp.com header.s=20150623 header.b=P81R8t+9; spf=pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727323AbgKQDql (ORCPT + 17 others); Mon, 16 Nov 2020 22:46:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727236AbgKQDqk (ORCPT ); Mon, 16 Nov 2020 22:46:40 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EFA3C0613CF for ; Mon, 16 Nov 2020 19:46:39 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id p68so4666183pga.6 for ; Mon, 16 Nov 2020 19:46:39 -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:mime-version :content-transfer-encoding; bh=ry/grlrwAYhAppgY6XzXb/u0/JUtINorUIX1oaiw220=; b=P81R8t+9jByDVa2MndaxDQgZcxloX3KTIN3kdslUndob8x2t+HZJWJI8/DWzsSAfIP Zr6DUFyi31ihO9ouwhhF7PonvsNbgdQ3sclLU/g0M4UEU7pZLd+hWFinmQWo/J3ffQ8r AedoN9wsvmwDQqQDTaiciJxutmS+Y0Y8V4a4CLXwxN1l0wOwErHu54ZkFQYywN0qRRFZ g/pSApnqp7LFmwYj+DRICPdwJV6d1AlBClLLLeSr45KZW4/woclkQ/Sx8VljcYGQTZEL iKkzct601LRhk0pqkp7jkBzBrz4Wy7NF4JcKyVsDt1wiXMuwwyDpx9g88BFYSCwVd760 cY2Q== 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:mime-version :content-transfer-encoding; bh=ry/grlrwAYhAppgY6XzXb/u0/JUtINorUIX1oaiw220=; b=jaXUY2OW2Fqh0bKjxccxpcGMlobbSGYCABC5nFNC6SwHQHlMLtGiD9C1Wv2zx8yIhZ bSu0bo9KZghZ8qD+zRczC3IlALAQSFoH9M0ZULweoLMH2aaQ74AmXXr4edIlTPeMooSO mzQyeQPE1oTaGNLcKODQ20tm3TCHJH3pMT9+5Nr0QbTjgX9P2Wf4S1yNNyEZvEqowou/ 6mqjz111R4dm9AfIVN2n5usNjoLzhsUFJkhksWDQ/ZkgxEZSTnr8MZIK6usTpETqtVwh rLhloVe561FHY1pKNgWcVwyk3hgNd7llzANUbpXQRGUSM7KFWmQBAjsnJhKatMj1GWwK CR+g== X-Gm-Message-State: AOAM533G2Gj6QXm1/IEK3z5cYbe97kfPfJ3Uwz3Yz0d24c0M+qty2tDX TDTgWEaN0Jqvje2R1RoZJ6IxVuRby8wWQgkd X-Received: by 2002:a05:6a00:213a:b029:18b:4b8b:68c with SMTP id n26-20020a056a00213ab029018b4b8b068cmr16625348pfj.18.1605584798655; Mon, 16 Nov 2020 19:46:38 -0800 (PST) Received: from localhost (115.42.24.136.in-addr.arpa. [136.24.42.115]) by smtp.gmail.com with ESMTPSA id l62sm18437889pga.63.2020.11.16.19.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Nov 2020 19:46:37 -0800 (PST) From: Jason Zaman To: selinux-refpolicy@vger.kernel.org Cc: Jason Zaman , Jason Zaman Subject: [PATCH 1/8] userdomain: Add watch on home dirs Date: Mon, 16 Nov 2020 19:46:21 -0800 Message-Id: <20201117034628.2461-1-jason@perfinion.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org From: Jason Zaman 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 Signed-off-by: Jason Zaman --- policy/modules/services/xserver.if | 11 +- policy/modules/system/miscfiles.if | 18 +++ policy/modules/system/userdomain.if | 15 ++- policy/modules/system/xdg.if | 198 ++++++++++++++++++++++++++++ 4 files changed, 240 insertions(+), 2 deletions(-) diff --git a/policy/modules/services/xserver.if b/policy/modules/services/xserver.if index baa39ef87..d5d6c7914 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) #selint-disable:S-004 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 e633217fe..354fe6fb3 100644 --- a/policy/modules/system/miscfiles.if +++ b/policy/modules/system/miscfiles.if @@ -824,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 02ead5b2a..482af588b 100644 --- a/policy/modules/system/userdomain.if +++ b/policy/modules/system/userdomain.if @@ -289,6 +289,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:file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_t:lnk_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_t:sock_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_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) @@ -368,7 +374,11 @@ 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_dir_t:dir watch; + 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:file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_t:lnk_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_t:sock_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_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") @@ -623,6 +633,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) @@ -1171,6 +1183,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 11fc43069..823042414 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.26.2