From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id CD39A5A0277; Thu, 7 Sep 2023 00:35:15 +0200 (CEST) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 5/5] apparmor: Add pasta's own profile Date: Thu, 7 Sep 2023 00:35:15 +0200 Message-Id: <20230906223515.2533706-6-sbrivio@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230906223515.2533706-1-sbrivio@redhat.com> References: <20230906223515.2533706-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: YOQPJ57QC3EWVS6LIITRLOF5QON7XSQA X-Message-ID-Hash: YOQPJ57QC3EWVS6LIITRLOF5QON7XSQA X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Paul Holzinger , David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: If pasta and pasta.avx2 are hard links to passt and passt.avx2, AppArmor will attach their own profiles on execution, and we can restrict passt's profile to what it actually needs. Note that pasta needs to access all the resources that passt needs, so the pasta abstraction still includes passt's one. I plan to push the adaptation required for the Debian package in commit 5bb812e79143 ("debian/rules: Override pasta symbolic links with hard links"), on Salsa. If other distributions need to support AppArmor profiles they can follow a similar approach. The profile itself will be installed, there, via dh_apparmor, in a separate commit, b52557fedcb1 ("debian/rules: Install new pasta profile using dh_apparmor"). Signed-off-by: Stefano Brivio --- contrib/apparmor/abstractions/pasta | 2 ++ contrib/apparmor/usr.bin.passt | 12 ++---------- contrib/apparmor/usr.bin.pasta | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 contrib/apparmor/usr.bin.pasta diff --git a/contrib/apparmor/abstractions/pasta b/contrib/apparmor/abstractions/pasta index 05c5d46..a890391 100644 --- a/contrib/apparmor/abstractions/pasta +++ b/contrib/apparmor/abstractions/pasta @@ -40,3 +40,5 @@ owner @{PROC}/sys/net/ipv4/ping_group_range w, # pasta_spawn_cmd(), pasta.c /{usr/,}bin/** Ux, + + /usr/bin/pasta.avx2 ix, # arch_avx2_exec(), arch.c diff --git a/contrib/apparmor/usr.bin.passt b/contrib/apparmor/usr.bin.passt index 652051d..564f82f 100644 --- a/contrib/apparmor/usr.bin.passt +++ b/contrib/apparmor/usr.bin.passt @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# contrib/apparmor/usr.bin.passt - AppArmor profile for passt(1) and pasta(1) +# contrib/apparmor/usr.bin.passt - AppArmor profile for passt(1) # # Copyright (c) 2022 Red Hat GmbH # Author: Stefano Brivio @@ -15,13 +15,7 @@ abi , include -profile passt /usr/bin/passt{,.avx2} flags=(attach_disconnected) { - ### TODO: AppArmor doesn't give us the chance to attach a separate profile - ### depending on the executable symlink. That's possible with SELinux. Two - ### alternatives: implement that in AppArmor, or consider aa_change_hat(2). - ### With this, rules for passt(1) could be restricted significantly. Note that - ### the attach_disconnected flag is not needed for passt(1). - +profile passt /usr/bin/passt{,.avx2} { include # Alternatively: include @@ -30,6 +24,4 @@ profile passt /usr/bin/passt{,.avx2} flags=(attach_disconnected) { # logfile_init() owner @{HOME}/** w, # pcap(), write_pidfile() - - include } diff --git a/contrib/apparmor/usr.bin.pasta b/contrib/apparmor/usr.bin.pasta new file mode 100644 index 0000000..e5ee4df --- /dev/null +++ b/contrib/apparmor/usr.bin.pasta @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# contrib/apparmor/usr.bin.pasta - AppArmor profile for pasta(1) +# +# Copyright (c) 2022 Red Hat GmbH +# Author: Stefano Brivio + +abi , + +include + +profile pasta /usr/bin/pasta{,.avx2} flags=(attach_disconnected) { + include + + # Alternatively: include + owner /tmp/** w, # tap_sock_unix_init(), pcap(), + # write_pidfile(), + # logfile_init() + + owner @{HOME}/** w, # pcap(), write_pidfile() +} -- 2.39.2