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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 C7D10C433E0 for ; Wed, 27 Jan 2021 07:03:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 891CF20723 for ; Wed, 27 Jan 2021 07:03:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232474AbhA0HDA (ORCPT ); Wed, 27 Jan 2021 02:03:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232270AbhA0HBH (ORCPT ); Wed, 27 Jan 2021 02:01:07 -0500 Received: from smtp.sws.net.au (smtp.sws.net.au [IPv6:2a01:4f8:140:71f5::dada:cafe]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28A25C06174A for ; Tue, 26 Jan 2021 23:00:27 -0800 (PST) Received: from liv.coker.com.au (unknown [103.75.204.226]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: russell@coker.com.au) by smtp.sws.net.au (Postfix) with ESMTPSA id 0E855169E9; Wed, 27 Jan 2021 18:00:23 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coker.com.au; s=2008; t=1611730825; bh=W3uvnUzCdI8fbsnwrF6gRZqo0+PTvNos6RXgN1VjWz8=; l=4609; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y819z2Gy7BlPTLMgneHM3Uu3CA5x9j5IW9BSLlD33c0ZPFMt2bqeV79FLnd6lNJdm WWrd3tBBhaB1Q/1uK4F3d6XEMcnvLtCq+NYqn6jcYxv6oA2j+8OXN4386J2h3Doqbi ESlAmnY+zCHlEuCNeCaTrc1WnIRmSpFHgfkAJLVE= From: Russell Coker To: Dominick Grift Cc: selinux-refpolicy@vger.kernel.org Subject: Re: [PATCH] misc network patches Date: Wed, 27 Jan 2021 18:00:20 +1100 Message-ID: <1818414.Kogm6ZmNZq@liv> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org On Thursday, 21 January 2021 12:23:29 AM AEDT Dominick Grift wrote: > > Index: refpolicy-2.20210120/policy/modules/roles/staff.te > > =================================================================== > > --- refpolicy-2.20210120.orig/policy/modules/roles/staff.te > > +++ refpolicy-2.20210120/policy/modules/roles/staff.te > > @@ -15,6 +15,10 @@ userdom_unpriv_user_template(staff) > > > > # > > corenet_ib_access_unlabeled_pkeys(staff_t) > > > > +corenet_tcp_bind_all_unreserved_ports(staff_t) > > +corenet_udp_bind_all_unreserved_ports(staff_t) > > +corenet_tcp_bind_generic_node(staff_t) > > staff_t is a "unpriv user" and so "userdom_unpriv_user_template()" > applies to staff_t. OK, I'll remove that. > this template has two booleans: user_tcp_server and user_udp_server > these booleans currently allow unpriv users to bind tcp and udp sockets > to generic ports respectively. > > This is old, inaccurate and outdated. Instead those booleans should > probably be modernized: > > tunable_policy(`user_tcp_server',` > corenet_tcp_bind_generic_node($1_t) > corenet_tcp_bind_all_unreserved_ports($1_t) > ') > > tunable_policy(`user_udp_server',` > corenet_udp_bind_generic_node($1_t) > corenet_udp_bind_all_unreserved_ports($1_t) > ') Unreserved ports means all ports >1023. I don't think that's what we want. There are lots of daemons using ports >1023, many of which are IANA assigned. > > optional_policy(` > > > > apache_role(staff_r, staff_t) > > > > ') > > > > @@ -36,6 +40,10 @@ optional_policy(` > > > > ') > > > > optional_policy(` > > > > + netutils_domtrans_ping(staff_t) > > +') > > + > > This is already (conditionlly) allowed in the userdom_unpriv_user_template() > To make it work requires a boolean to be set to true (i believe) OK, I'll remove that. > > +optional_policy(` > > > > postgresql_role(staff_r, staff_t) > > > > ') > > > > @@ -65,6 +73,11 @@ optional_policy(` > > > > ') > > > > optional_policy(` > > > > + # for torbrowser-launcher > > + xdg_exec_data(staff_t) > > What location is this exactly? ~/.local/bin? ~/.local/share/torbrowser/tbb/x86_64/tor-browser_en-US/Browser/ > I would associate a "bin_home_t" with ~/.local/bin and only allow that > to be executed, rather than all of ~/.local > > But regardless this, or similar rule should apply to > userdom_unpriv_user_template() instead. Use the templates. OK, I'll remove it for now. > > +') > > + > > +optional_policy(` > > > > xscreensaver_role(staff_r, staff_t) > > > > ') > > > > Index: refpolicy-2.20210120/policy/modules/roles/unprivuser.te > > =================================================================== > > --- refpolicy-2.20210120.orig/policy/modules/roles/unprivuser.te > > +++ refpolicy-2.20210120/policy/modules/roles/unprivuser.te > > @@ -7,11 +7,23 @@ policy_module(unprivuser, 2.10.0) > > > > # > > # Declarations > > # > > > > +## > > +##

> > +## Allow user to bind all unreserved ports > > +##

> > +##
> > +gen_tunable(user_bind_unreserved, false) > > Modernize and use the existing user_tcp_server and user_udp_server > booleans in userdom_unpriv_user_template() instead? See above comment. OK. > > #role user_r; > > > > userdom_unpriv_user_template(user) > > > > +tunable_policy(`user_bind_unreserved', ` > > + corenet_tcp_bind_all_unreserved_ports(user_t) > > + corenet_udp_bind_all_unreserved_ports(user_t) > > + corenet_tcp_bind_generic_node(user_t) > > +') > > See above comment about user_tcp_server and user_udp_server booleans in > userdom_unpriv_user_template() OK. > > ') > > > > @@ -25,6 +37,10 @@ optional_policy(` > > > > ') > > > > optional_policy(` > > > > + netutils_domtrans_ping(user_t) > > +') > > + > > This is already allowed conditionally in userdom_unpriv_user_template() > requires a boolean to be set to true to work. Adding this rule would > break that existing model. OK. > > +######################################## > > +## > > +## Restart and get status of samba daemon > > +## > > +## > > +## > > +## Domain allowed access. > > +## > > +## > > +# > > +interface(`samba_restart',` > > + gen_require(` > > + type samba_unit_t; > > + ') > > + > > + allow $1 samba_unit_t:file getattr; > > + allow $1 samba_unit_t:service { start stop status reload }; > > This interface seems a bit broad OK. -- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/