Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp78095pxp; Tue, 8 Mar 2022 20:57:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVVJevoUBh9KmsJE8auT3vrLt4LF5TPgMg1qcUPjAsKtokYKHqnwomImc4HPKVVeD6gEGX X-Received: by 2002:a05:6402:11cf:b0:407:1939:9a4e with SMTP id j15-20020a05640211cf00b0040719399a4emr19929980edw.298.1646801874056; Tue, 08 Mar 2022 20:57:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646801874; cv=none; d=google.com; s=arc-20160816; b=ky7Nip4URZMQk6j7mXu2ngOCDHY9IfAN+3P/BMKHm756DIGQAz+r3ewtDEf5HeinNo rXrQ1Wvl2fV4x1O+w4OOlD34N1jdYThaXQZF6DXnZLzgaiZax+8PyOzDu8u3d7V1Ijza Jw4SyY2wdZGdaVrvaWBp49lhy3+Q7h3Z49Z7h0B4MKp/EUy/O4KhP/DCGFIbsOxmK1j/ +uxQ+c1VPxfKGsGXJ9d1W5M/pv65PkbWeIG2YD+qa8bkjAnekcGlydvf58dI85EJYf+W Sr/eF7kc2xO3IQnM6EfUQSMMjPfv4zDg4NrkJcNNQlQXAeYSD/suPXeMv9IqtSUbqUqk pjNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date:dkim-signature; bh=8PL2da6PD42P5RyJhgI/NvM9REaj3D+utdMJ3PuyPyk=; b=U3p3DI+FMqCNg8HW9QuawdmEn89EgzdMoufBSTmjOkgnQWCvtB8PWX+vdbfCVTpGa4 z4vcW/Suxfi3yLyOPUEh48v/Gp2Ru58IiroENmW59prHm2f8TUyfdM8vOR7j2IZ7HTne CKAaGaiGuwa/7U+6IFn5FcRUjg4apUOYhbIYDTi//aoz0cYsz0NzSFFhEKxnCoEguaA+ OSQbFLRf0fPHA1vWtzWhCeBOF+pJYBO3+PlP+zX+WOMwoYJX7fuRcm68XXHsjQX70//v cT+A5OMc5cuJVyphYu9FDUXOmxtKAlUsev+nopbI2y3J2WBq5k4JAfa9UqCffDCgjTBi Ohjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@coker.com.au header.s=2008 header.b=NuvzmYcz; spf=pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=coker.com.au Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd38-20020a17090796a600b006cf5489da60si572562ejc.36.2022.03.08.20.57.48; Tue, 08 Mar 2022 20:57:54 -0800 (PST) Received-SPF: pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@coker.com.au header.s=2008 header.b=NuvzmYcz; spf=pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=coker.com.au Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229495AbiCIEzZ (ORCPT + 23 others); Tue, 8 Mar 2022 23:55:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiCIEzY (ORCPT ); Tue, 8 Mar 2022 23:55:24 -0500 Received: from smtp.sws.net.au (smtp.sws.net.au [IPv6:2a01:4f8:201:1e6::dada:cafe]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 236527C14B for ; Tue, 8 Mar 2022 20:54:25 -0800 (PST) Received: from xev.coker.com.au (localhost [127.0.0.1]) by smtp.sws.net.au (Postfix) with ESMTP id BB81DEB84 for ; Wed, 9 Mar 2022 15:54:22 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coker.com.au; s=2008; t=1646801663; bh=8PL2da6PD42P5RyJhgI/NvM9REaj3D+utdMJ3PuyPyk=; l=13114; h=Date:From:To:Subject:From; b=NuvzmYczNLza7vdusuh7gfV0ZcGIEw/s+w6aUrUQQdFUzY94BPDyNIQOOniwZX701 mlE3Sf1mpgqxhCTLoG4f+6P5fclEq2+6uZvhUKj+D6Gcm44hueQ8m6ZYYM0GKo0Sf8 opsyPLLj4Mdc6Ky8zMxeeG4U8tmZYpDXOY7M4XN0= Received: by xev.coker.com.au (Postfix, from userid 1001) id 1A5441763566; Wed, 9 Mar 2022 15:54:18 +1100 (AEDT) Date: Wed, 9 Mar 2022 15:54:18 +1100 From: Russell Coker To: selinux-refpolicy@vger.kernel.org Subject: [PATCH] mailman3 V3 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org Fixed the issues Chris raised with the previous patch. I think this is ready to merge. Signed-off-by: Russell Coker Index: refpolicy-2.20220309/policy/modules/services/mailman.if =================================================================== --- refpolicy-2.20220309.orig/policy/modules/services/mailman.if +++ refpolicy-2.20220309/policy/modules/services/mailman.if @@ -109,6 +109,44 @@ interface(`mailman_domtrans_cgi',` ####################################### ## +## Talk to mailman_cgi_t via Unix domain socket +## +## +## +## Domain talking to mailman +## +## +# +interface(`mailman_stream_connect_cgi',` + gen_require(` + type mailman_cgi_t, mailman_runtime_t; + ') + + files_search_runtime($1) + stream_connect_pattern($1, mailman_runtime_t, mailman_runtime_t, mailman_cgi_t) +') + +####################################### +## +## Manage mailman runtime files +## +## +## +## Domain to manage the files +## +## +# +interface(`mailman_manage_runtime_files',` + gen_require(` + type mailman_runtime_t; + ') + + files_search_runtime($1) + manage_files_pattern($1, mailman_runtime_t, mailman_runtime_t) +') + +####################################### +## ## Execute mailman in the caller domain. ## ## @@ -186,6 +224,24 @@ interface(`mailman_read_data_files',` ####################################### ## +## map mailman data content. +## +## +## +## Domain allowed access. +## +## +# +interface(`mailman_map_data_files',` + gen_require(` + type mailman_data_t; + ') + + allow $1 mailman_data_t:file map; +') + +####################################### +## ## Create, read, write, and delete ## mailman data files. ## @@ -342,3 +398,21 @@ interface(`mailman_domtrans_queue',` libs_search_lib($1) domtrans_pattern($1, mailman_queue_exec_t, mailman_queue_t) ') + +####################################### +## +## Manage mailman lock dir +## +## +## +## Domain allowed to manage it. +## +## +# +interface(`mailman_manage_lockdir',` + gen_require(` + type mailman_lock_t; + ') + + allow $1 mailman_lock_t:dir manage_dir_perms; +') Index: refpolicy-2.20220309/policy/modules/services/mailman.te =================================================================== --- refpolicy-2.20220309.orig/policy/modules/services/mailman.te +++ refpolicy-2.20220309/policy/modules/services/mailman.te @@ -10,6 +10,7 @@ attribute mailman_domain; attribute_role mailman_roles; mailman_domain_template(cgi) +init_daemon_domain(mailman_cgi_t, mailman_cgi_exec_t) type mailman_data_t; files_type(mailman_data_t) @@ -22,15 +23,25 @@ logging_log_file(mailman_log_t) type mailman_lock_t; files_lock_file(mailman_lock_t) +optional_policy(` + systemd_tmpfilesd_managed(mailman_lock_t) +') type mailman_runtime_t alias mailman_var_run_t; files_runtime_file(mailman_runtime_t) +type mailman_cgi_tmpfs_t; +files_tmpfs_file(mailman_cgi_tmpfs_t) + +type mailman_queue_tmpfs_t; +files_tmpfs_file(mailman_queue_tmpfs_t) + mailman_domain_template(mail) init_daemon_domain(mailman_mail_t, mailman_mail_exec_t) role mailman_roles types mailman_mail_t; mailman_domain_template(queue) +init_daemon_domain(mailman_queue_t, mailman_queue_exec_t) ######################################## # @@ -89,13 +100,16 @@ miscfiles_read_localization(mailman_doma # CGI local policy # -allow mailman_cgi_t self:unix_dgram_socket { create connect }; +allow mailman_cgi_t self:process { signal signull sigkill }; +allow mailman_cgi_t self:fifo_file rw_fifo_file_perms; +allow mailman_cgi_t self:capability { dac_override setgid setuid }; +allow mailman_cgi_t self:unix_dgram_socket create_socket_perms; allow mailman_cgi_t mailman_archive_t:dir search_dir_perms; allow mailman_cgi_t mailman_archive_t:file read_file_perms; allow mailman_cgi_t mailman_data_t:dir rw_dir_perms; -allow mailman_cgi_t mailman_data_t:file manage_file_perms; +allow mailman_cgi_t mailman_data_t:file { map manage_file_perms }; allow mailman_cgi_t mailman_data_t:lnk_file read_lnk_file_perms; allow mailman_cgi_t mailman_lock_t:dir manage_dir_perms; @@ -104,11 +118,27 @@ allow mailman_cgi_t mailman_lock_t:file allow mailman_cgi_t mailman_log_t:file { append_file_perms read_file_perms }; allow mailman_cgi_t mailman_log_t:dir search_dir_perms; +allow mailman_cgi_t mailman_runtime_t:dir rw_dir_perms; +allow mailman_cgi_t mailman_runtime_t:file read_file_perms; +allow mailman_cgi_t mailman_runtime_t:sock_file manage_file_perms; + +fs_tmpfs_filetrans(mailman_cgi_t, mailman_cgi_tmpfs_t, file) +allow mailman_cgi_t mailman_cgi_tmpfs_t:file { map manage_file_perms }; + kernel_read_crypto_sysctls(mailman_cgi_t) +kernel_read_net_sysctls(mailman_cgi_t) kernel_read_system_state(mailman_cgi_t) +kernel_read_vm_overcommit_sysctl(mailman_cgi_t) +# need SELinuxContext=system_u:system_r:mailman_cgi_t:s0 in the systemd +# service file for the correct context on running /usr/bin/uwsgi for +# mailman3-web +corecmd_bin_entry_type(mailman_cgi_t) corecmd_exec_bin(mailman_cgi_t) +corenet_tcp_bind_generic_node(mailman_cgi_t) +corenet_tcp_connect_all_unreserved_ports(mailman_cgi_t) + dev_read_urand(mailman_cgi_t) files_search_locks(mailman_cgi_t) @@ -120,9 +150,9 @@ libs_dontaudit_write_lib_dirs(mailman_cg logging_search_logs(mailman_cgi_t) +miscfiles_read_generic_certs(mailman_cgi_t) miscfiles_read_localization(mailman_cgi_t) - optional_policy(` apache_sigchld(mailman_cgi_t) apache_use_fds(mailman_cgi_t) @@ -133,6 +163,15 @@ optional_policy(` ') optional_policy(` + cron_rw_inherited_tmp_files(mailman_cgi_t) + cron_system_entry(mailman_cgi_t, mailman_cgi_exec_t) +') + +optional_policy(` + mysql_stream_connect(mailman_cgi_t) +') + +optional_policy(` postfix_read_config(mailman_cgi_t) ') @@ -142,7 +181,9 @@ optional_policy(` # allow mailman_mail_t self:capability { dac_override kill setgid setuid sys_tty_config }; -allow mailman_mail_t self:process { signal signull setsched }; +allow mailman_mail_t self:process { execmem signal signull setsched }; +allow mailman_mail_t self:netlink_audit_socket { nlmsg_relay create_socket_perms }; +allow mailman_mail_t self:fifo_file rw_file_perms; allow mailman_mail_t mailman_archive_t:dir manage_dir_perms; allow mailman_mail_t mailman_archive_t:file manage_file_perms; @@ -167,8 +208,12 @@ manage_files_pattern(mailman_mail_t, mai manage_dirs_pattern(mailman_mail_t, mailman_runtime_t, mailman_runtime_t) files_runtime_filetrans(mailman_mail_t, mailman_runtime_t, { file dir }) +kernel_read_network_state(mailman_mail_t) kernel_read_system_state(mailman_mail_t) +corenet_tcp_bind_all_unreserved_ports(mailman_mail_t) +corenet_tcp_bind_generic_node(mailman_mail_t) +corenet_tcp_connect_http_port(mailman_mail_t) corenet_tcp_connect_smtp_port(mailman_mail_t) corenet_sendrecv_spamd_client_packets(mailman_mail_t) corenet_sendrecv_innd_client_packets(mailman_mail_t) @@ -193,6 +238,7 @@ libs_read_lib_files(mailman_mail_t) logging_search_logs(mailman_mail_t) +miscfiles_read_generic_certs(mailman_mail_t) miscfiles_read_localization(mailman_mail_t) mta_use_mailserver_fds(mailman_mail_t) @@ -200,14 +246,26 @@ mta_dontaudit_rw_delivery_tcp_sockets(ma mta_dontaudit_rw_queue(mailman_mail_t) optional_policy(` + apache_search_config(mailman_mail_t) +') + +optional_policy(` courier_read_spool(mailman_mail_t) ') optional_policy(` cron_read_pipes(mailman_mail_t) + cron_rw_inherited_tmp_files(mailman_mail_t) + cron_search_spool(mailman_mail_t) + cron_system_entry(mailman_mail_t, mailman_mail_exec_t) ') optional_policy(` + corenet_tcp_connect_mysqld_port(mailman_mail_t) +') + +optional_policy(` + postfix_read_config(mailman_mail_t) postfix_search_spool(mailman_mail_t) postfix_rw_inherited_master_pipes(mailman_mail_t) ') @@ -217,15 +275,18 @@ optional_policy(` # Queue local policy # -allow mailman_queue_t self:capability { setgid setuid }; +allow mailman_queue_t self:capability { dac_override setgid setuid }; allow mailman_queue_t self:process { setsched signal_perms }; allow mailman_queue_t self:fifo_file rw_fifo_file_perms; +allow mailman_queue_t mailman_runtime_t:dir rw_dir_perms; +allow mailman_queue_t mailman_runtime_t:file manage_file_perms; + allow mailman_queue_t mailman_archive_t:dir manage_dir_perms; allow mailman_queue_t mailman_archive_t:file manage_file_perms; allow mailman_queue_t mailman_data_t:dir rw_dir_perms; -allow mailman_queue_t mailman_data_t:file manage_file_perms; +allow mailman_queue_t mailman_data_t:file { map manage_file_perms }; allow mailman_queue_t mailman_data_t:lnk_file read_lnk_file_perms; allow mailman_queue_t mailman_lock_t:dir rw_dir_perms; @@ -234,15 +295,25 @@ allow mailman_queue_t mailman_lock_t:fil allow mailman_queue_t mailman_log_t:dir list_dir_perms; allow mailman_queue_t mailman_log_t:file manage_file_perms; +fs_tmpfs_filetrans(mailman_queue_t, mailman_queue_tmpfs_t, file) +allow mailman_queue_t mailman_queue_tmpfs_t:file { map manage_file_perms }; + +kernel_read_network_state(mailman_queue_t) kernel_read_system_state(mailman_queue_t) +kernel_search_vm_sysctl(mailman_queue_t) auth_domtrans_chk_passwd(mailman_queue_t) corecmd_read_bin_files(mailman_queue_t) corenet_sendrecv_innd_client_packets(mailman_queue_t) +corenet_tcp_bind_all_unreserved_ports(mailman_queue_t) +corenet_tcp_bind_generic_node(mailman_queue_t) +corenet_tcp_connect_generic_port(mailman_queue_t) +corenet_tcp_connect_http_port(mailman_queue_t) corenet_tcp_connect_innd_port(mailman_queue_t) files_dontaudit_search_runtime(mailman_queue_t) +files_read_usr_files(mailman_queue_t) files_search_locks(mailman_queue_t) miscfiles_read_localization(mailman_queue_t) @@ -251,14 +322,24 @@ seutil_dontaudit_search_config(mailman_q userdom_search_user_home_dirs(mailman_queue_t) -cron_rw_tmp_files(mailman_queue_t) - optional_policy(` apache_read_config(mailman_queue_t) ') optional_policy(` + cron_rw_tmp_files(mailman_queue_t) + cron_search_spool(mailman_queue_t) cron_system_entry(mailman_queue_t, mailman_queue_exec_t) + cron_use_fds(mailman_queue_t) +') + +optional_policy(` + mysql_stream_connect(mailman_queue_t) + mysql_tcp_connect(mailman_queue_t) +') + +optional_policy(` + postfix_read_config(mailman_queue_t) ') optional_policy(` Index: refpolicy-2.20220309/policy/modules/services/apache.te =================================================================== --- refpolicy-2.20220309.orig/policy/modules/services/apache.te +++ refpolicy-2.20220309/policy/modules/services/apache.te @@ -815,8 +815,10 @@ optional_policy(` ') optional_policy(` + mailman_stream_connect_cgi(httpd_t) mailman_signal_cgi(httpd_t) mailman_domtrans_cgi(httpd_t) + mailman_map_data_files(httpd_t) mailman_read_data_files(httpd_t) mailman_search_data(httpd_t) mailman_read_archive(httpd_t) Index: refpolicy-2.20220309/policy/modules/services/cron.te =================================================================== --- refpolicy-2.20220309.orig/policy/modules/services/cron.te +++ refpolicy-2.20220309/policy/modules/services/cron.te @@ -604,6 +604,12 @@ optional_policy(` ') optional_policy(` + mailman_domtrans_queue(system_cronjob_t) + # for flock + mailman_manage_runtime_files(system_cronjob_t) +') + +optional_policy(` mrtg_append_create_logs(system_cronjob_t) mrtg_read_config(system_cronjob_t) ') Index: refpolicy-2.20220309/policy/modules/services/mailman.fc =================================================================== --- refpolicy-2.20220309.orig/policy/modules/services/mailman.fc +++ refpolicy-2.20220309/policy/modules/services/mailman.fc @@ -20,6 +20,7 @@ /usr/lib/cgi-bin/mailman/.* -- gen_context(system_u:object_r:mailman_cgi_exec_t,s0) /usr/lib/mailman/bin/qrunner -- gen_context(system_u:object_r:mailman_queue_exec_t,s0) +/usr/lib/mailman3/bin/.* -- gen_context(system_u:object_r:mailman_queue_exec_t,s0) /usr/lib/mailman/cgi-bin/.* -- gen_context(system_u:object_r:mailman_cgi_exec_t,s0) /usr/lib/mailman/mail/mailman -- gen_context(system_u:object_r:mailman_mail_exec_t,s0) /usr/lib/mailman/mail/wrapper -- gen_context(system_u:object_r:mailman_mail_exec_t,s0) @@ -28,3 +29,4 @@ /usr/mailman/mail/wrapper -- gen_context(system_u:object_r:mailman_mail_exec_t,s0) /usr/share/doc/mailman/mm-handler.* -- gen_context(system_u:object_r:mailman_mail_exec_t,s0) +/usr/share/mailman3-web/manage.py -- gen_context(system_u:object_r:mailman_queue_exec_t,s0)