From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5DE1515812D for ; Sun, 15 Dec 2024 00:30:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A628EE09A8; Sun, 15 Dec 2024 00:30:17 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 8D279E0821 for ; Sun, 15 Dec 2024 00:30:17 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BC459342F99 for ; Sun, 15 Dec 2024 00:30:16 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1EA86E96 for ; Sun, 15 Dec 2024 00:30:15 +0000 (UTC) From: "Jason Zaman" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Jason Zaman" Message-ID: <1734221959.0f30968113b88ccf367726ef169a40d13231975f.perfinion@gentoo> Subject: [gentoo-commits] proj/hardened-refpolicy:master commit in: policy/modules/system/ X-VCS-Repository: proj/hardened-refpolicy X-VCS-Files: policy/modules/system/miscfiles.if X-VCS-Directories: policy/modules/system/ X-VCS-Committer: perfinion X-VCS-Committer-Name: Jason Zaman X-VCS-Revision: 0f30968113b88ccf367726ef169a40d13231975f X-VCS-Branch: master Date: Sun, 15 Dec 2024 00:30:15 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 4424c258-b4da-4702-b2ee-969d3a0425b7 X-Archives-Hash: f4044cd04cb641ed95a64e8fafc6dee5 commit: 0f30968113b88ccf367726ef169a40d13231975f Author: Dave Sugar gmail com> AuthorDate: Mon Nov 18 02:48:53 2024 +0000 Commit: Jason Zaman gentoo org> CommitDate: Sun Dec 15 00:19:19 2024 +0000 URL: https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=0f309681 Need search perms on cert_t/tls_privkey_t when using private types Even if you create a private key for a certificate in /etc/pki/tls/certs or private key in /etc/pki/tls/private as those directories are labeled cert_t and tls_privkey_t. So you need dir search perms to be able to access your new key type. node=localhost type=AVC msg=audit(1731898795.566:33533): avc: denied { search } for pid=961 comm="monitor" name="private" dev="dm-0" ino=524539 scontext=system_u:system_r:monitor_t:s0 tcontext=system_u:object_r:tls_privkey_t:s0 tclass=dir permissive=1` Signed-off-by: Dave Sugar gmail.com> Signed-off-by: Jason Zaman gentoo.org> policy/modules/system/miscfiles.if | 49 ++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/policy/modules/system/miscfiles.if b/policy/modules/system/miscfiles.if index d3041451b..101b992bd 100644 --- a/policy/modules/system/miscfiles.if +++ b/policy/modules/system/miscfiles.if @@ -23,9 +23,9 @@ ##

##

## type mycertfile_t; -## cert_type(mycertfile_t) +## miscfiles_cert_type(mycertfile_t) ## allow mydomain_t mycertfile_t:file read_file_perms; -## files_search_etc(mydomain_t) +## miscfiles_search_generic_cert_dirs(mydomain_t) ##

## ## @@ -68,9 +68,9 @@ interface(`miscfiles_cert_type',` ##

##

## type mytlsprivkeyfile_t; -## tls_privkey_type(mytlsprivkeyfile_t) +## miscfiles_tls_privkey_type(mytlsprivkeyfile_t) ## allow mydomain_t mytlsprivkeyfile_t:file read_file_perms; -## files_search_etc(mydomain_t) +## miscfiles_search_tls_privkey_dirs(mydomain_t) ##

## ## @@ -110,6 +110,26 @@ interface(`miscfiles_read_all_certs',` read_lnk_files_pattern($1, cert_type, cert_type) ') +######################################## +## +## Search generic SSL/TLS directories. +## +## +## +## Domain allowed access. +## +## +## +# +interface(`miscfiles_search_generic_cert_dirs',` + gen_require(` + type cert_t; + ') + + files_search_etc($1) + allow $1 cert_t:dir search_dir_perms; +') + ######################################## ## ## Read generic SSL/TLS certificates. @@ -239,6 +259,27 @@ interface(`miscfiles_mounton_generic_cert_dirs',` allow $1 cert_t:dir mounton; ') + +######################################## +## +## Search SSL/TLS private key directories. +## +## +## +## Domain allowed access. +## +## +## +# +interface(`miscfiles_search_tls_privkey_dirs',` + gen_require(` + type tls_privkey_t; + ') + + miscfiles_search_generic_cert_dirs($1) + allow $1 tls_privkey_t:dir search_dir_perms; +') + ######################################## ## ## Read generic SSL/TLS private