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=-5.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS 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 52107C282DD for ; Thu, 9 Jan 2020 21:42:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1764C20721 for ; Thu, 9 Jan 2020 21:42:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vJsWwcCf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725775AbgAIVmq (ORCPT ); Thu, 9 Jan 2020 16:42:46 -0500 Received: from mail-wm1-f44.google.com ([209.85.128.44]:37444 "EHLO mail-wm1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbgAIVmq (ORCPT ); Thu, 9 Jan 2020 16:42:46 -0500 Received: by mail-wm1-f44.google.com with SMTP id f129so4483851wmf.2 for ; Thu, 09 Jan 2020 13:42:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=zjW9CW//LvVO4+iRUZZNTU2sUkApxEhTuBn/c119p5M=; b=vJsWwcCfRoK9ndKFEMmp11XHMY1vI7/bCvjl8XN7QWFS+wbMxGMs7ag0a6T2XTXFOI 6kNIkycycQ9ATmgTOo+v6AU2x0KhAg14E1bpqhcs1URPmeOL2QGPMxPrqw0SQyhjLZcU XesACFsZmGjLW6WmIAi1IJmx2iTHUvFuIgDChqHsNnuwaUEjiLgjkn1ovlPAMVZ999LQ MQ3blekRUmS94QI4dpFB6IofT/ZtuhDFJpzdP+ybrMWqiTphHhWh5ll6Jg915jMXerrW eJEErUiS0yPtw9c32B4Bd1Vsj2+N5Lc25mDjSc++c4a0D1VrqBtOp4NdklAXyZnkIKBA QP4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=zjW9CW//LvVO4+iRUZZNTU2sUkApxEhTuBn/c119p5M=; b=dp4zxM//MR4ziHnRDoqczgT5DuxHhbA4w0oEfqL6mPxCiQazpieSQGjd14EIfiM9GF rR/qyfVn0xpxEBAzAIEuYBiKNgmacINtbHu9BUJOBN2qDq8OGeLp3Zrvx4xkc80SE4U9 951CeV9unRMhO77gi05IeAr+UePxSkC4ucEish8wVAMg0BBZ+dKRJRcCXkQ7M83s4miU e4nH1IHO6izo1hlsrZE9ERs1/xXFTUlqm7+wUqa3tEbI/97dAIVhJGO7Pol9f5PO+DvU pjrb1nsrhIkBxrvMxbbFw/32Hf83BDYdVH8skLhxotjuIit4mcOd0U3+fU48p1/2D0ug a/1w== X-Gm-Message-State: APjAAAWpqYu6AOHMKH8EMuFDP/UQFhDeooFdi2domUj+TtOGwnkL0QDB 2PJyM0skTkSu65iphiHYmdT3FIiz X-Google-Smtp-Source: APXvYqxzWeUC8Ft+uxg5QEtaBHH0nlYxCYn6poXTD47sDZ9YWotCC3/inlMacHwrrw5rg4Ni9LTgTQ== X-Received: by 2002:a05:600c:2050:: with SMTP id p16mr52438wmg.176.1578606164197; Thu, 09 Jan 2020 13:42:44 -0800 (PST) Received: from brutus.lan (brutus.defensec.nl. [2001:985:d55d::438]) by smtp.gmail.com with ESMTPSA id b16sm9836582wrj.23.2020.01.09.13.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 13:42:43 -0800 (PST) Date: Thu, 9 Jan 2020 22:42:40 +0100 From: Dominick Grift To: Chris PeBenito Cc: refpolicy Subject: Re: [RFC] refining systemd mountpoints Message-ID: <20200109214240.GA2283901@brutus.lan> Mail-Followup-To: Chris PeBenito , refpolicy References: <3418ebca-80c0-b10e-c0a2-a80427fdbf71@ieee.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="M9NhX3UHpAaciwkO" Content-Disposition: inline In-Reply-To: <3418ebca-80c0-b10e-c0a2-a80427fdbf71@ieee.org> User-Agent: Every email client sucks, this one just sucks less. X-PGP-Key: https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02 Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 09, 2020 at 04:06:38PM -0500, Chris PeBenito wrote: > I'd like to refine how the policy handles systemd's mounton so that it wo= rks > similar to how we manage mountpoints for mount_t. Since systemd can be ma= de > to mount over just about anything, I'm looking at adding a new conditional > that would allow init_t to mounton non_security_file_type, and then an > interface like files_mountpoint(). >=20 > The question is for the implementation of the interface; I see two option= s, > either the interface allows mounton for all file-like classes, or the > classes are specified as a parameter: >=20 > -------- > init.te: > attribute init_mountpoint_type; > allow init_t init_mountpoint_type:dir_file_class_set mounton; >=20 > init.if: > interface(`init_mountpoint',` > typeattribute $1 init_mountpoint_type; > ') > -------- >=20 > or >=20 > -------- > init.if: > interface(`init_mountpoint',` > allow init_t $1:$2 mounton; > ') > -------- >=20 > I like the first option because it is clearer since you can see the mount= on > in init.te, but that is excessive access. The second option could be made > to look like the first option, but it would need several attributes and > interfaces, e.g. init_dir_mountpoint_type, init_file_mountpoint_type, etc. > which isn't so desirable. >=20 > Any thoughts on this? I implemented the former in my policy. ie the dir_file_class_set equiv.. 4163 (allow subj bind_path_obj_type_attribute (dirs (create))) 4164 (allow subj bind_path_obj_type_attribute list_dir_perms) 4165 (allow subj bind_path_obj_type_attribute (dir (mounton))) 4166 (allow subj bind_path_obj_type_attribute create_file_per= ms) 4167 (allow subj bind_path_obj_type_attribute (file (mounton)= )) As you can see i even allow systemd to create the mountpoint in case it doe= s not exist. For example if /etc/machine-id does not exist and I have a Bin= dReadOnlyPath=3D/etc/machine-id then systemd will touch /etc/machine-id and= mount it ro It also generally buggy. Systemd does not (alway's) use setfscreatecon to c= reate the mountpoints. And sometimes it does use setfscreatecon where it sh= ouldnt. https://github.com/systemd/systemd/issues/13762 >=20 > --=20 > Chris PeBenito --=20 Key fingerprint =3D 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02 https://sks-keyservers.net/pks/lookup?op=3Dget&search=3D0x3B6C5F1D2C7B6B02 Dominick Grift --M9NhX3UHpAaciwkO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGyBAEBCAAdFiEEujmXliIBLFTc2Y4AJXSOVTf5R2kFAl4XnksACgkQJXSOVTf5 R2kV2Av2JgAK2SgH9qdYZYULNw+nqyTjk6umYOQy54rv6LUG+Vmk23a8HhHZTWJN lk5CTm4mnKf1fpxVdQ/198wRcJd7/WaKF7m4KlT83hwl4aDnUePV/ATsQkRWOYuq cKzXYv87WdZlblHG2j3Kn745eI6ug2uKfdwdcys9j3uIgqLVR8aNAv0fg++8/Oku izLQjhLkseqC5Ah6zQfgtPWf4TQQ1LydnMXpBc4rbZ9n5AbuaxfJiKuWngSUmnRd nMBFTiTGnERHnulddfeojjrNsVmNsGZ4LS1Zhwit/3Ar+jTCbRgxZf+qS6cW19Vg EDroCuwEhSkpTudH4kni6UDRhDJyVs1KWb1W6EYZPJEVnXS41u8BO/qJ0TGuVVS4 bQvP39nVTVowTJAjyp+DUDj8wIzmIpUimyKYoxqO7kFOxlp4ONWfkAL7FkXa4zm8 XRxI9q7fPyvY4S2+D7yLgG3iMbaS27ZWalLbpeUCakr1JY0wzIkDemv9z5mSs4ot SIziCns= =q/sC -----END PGP SIGNATURE----- --M9NhX3UHpAaciwkO--