-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an AppArmor profile for BenchExec to its .deb package
On Ubuntu since 24.04, user namespaces are forbidden for regular users (cf. #1041 and #1042). There is a global sysctl switch to enable them again, but applications whose AppArmor profile allows this can also use it. (Typically, AppArmor only restricts application, but in this case an AppArmor profile can actually provide a privilege than an unconfined application does not have.) More explanations are at https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces In order to make BenchExec usable out-of-the-box after installing the .deb package we want to ship such an AppArmor profile. This is made complicated by the fact that the AppArmor profile that is necessary on Ubuntu 24.04+ breaks AppArmor on previous Ubuntu versions. So we have to install this profile conditionally. I found a way to do so using ucf (a tool for handling config files) and this seems to work in my tests on Ubuntu 22.04 (old AppArmor), Ubuntu 24.04 (new AppArmor), and Debian 12 (old AppArmor), as well as installation without AppArmor present. There are two known remaining problems: - If one upgrades from Ubuntu 22.04 to Ubuntu 24.04 while having BenchExec installed, the AppArmor profile will not be installed, so BenchExec will not work. Upgrading or reinstalling the BenchExec package makes it work. - The command "python3 -m benchexec.test_tool_info" will not work, because the AppArmor profile won't match it. One has to either disable container mode or temporarily allow the use of user namespaces for the whole system. If we implement #1053 this would just work. Part of #1041.
- Loading branch information
1 parent
765e3ee
commit 7753c4a
Showing
7 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
debian/additional_files/usr/share/benchexec/apparmor.d/benchexec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
|
||
# This file is part of BenchExec, a framework for reliable benchmarking: | ||
# https://github.com/sosy-lab/benchexec | ||
# | ||
# SPDX-FileCopyrightText: 2024 Dirk Beyer <https://www.sosy-lab.org> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# based on example in | ||
# https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces | ||
|
||
abi <abi/4.0>, | ||
|
||
include <tunables/global> | ||
|
||
profile benchexec /usr/bin/{bench,container,run}exec flags=(default_allow) { | ||
userns, | ||
|
||
# Site-specific additions and overrides. See local/README for details. | ||
include if exists <local/benchexec> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
|
||
# This file is part of BenchExec, a framework for reliable benchmarking: | ||
# https://github.com/sosy-lab/benchexec | ||
# | ||
# SPDX-FileCopyrightText: 2024 Dirk Beyer <https://www.sosy-lab.org> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -e | ||
|
||
# Only relevant for Ubuntu 24.04+, but works safely everywhere. | ||
# Based on what dh_ucf/13.6ubuntu1 would produce. | ||
if [ "$1" = "purge" ]; then | ||
for ext in .ucf-new .ucf-old .ucf-dist ""; do | ||
rm -f "/etc/apparmor.d/benchexec$ext" | ||
done | ||
|
||
if [ -x "`command -v ucf`" ]; then | ||
ucf --purge "/etc/apparmor.d/benchexec" | ||
fi | ||
if [ -x "`command -v ucfr`" ]; then | ||
ucfr --purge benchexec "/etc/apparmor.d/benchexec" | ||
fi | ||
fi | ||
|
||
#DEBHELPER# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ Section: utils | |
Priority: optional | ||
Maintainer: Philipp Wendler <[email protected]> | ||
Build-Depends: debhelper (>= 11), | ||
dh-apparmor, | ||
dh-python, | ||
python3 (>= 3.7), | ||
python3-setuptools, | ||
|
@@ -17,7 +18,7 @@ Vcs-Browser: https://github.com/sosy-lab/benchexec | |
|
||
Package: benchexec | ||
Architecture: all | ||
Depends: ${python3:Depends}, python3-pkg-resources, ${misc:Depends} | ||
Depends: ${python3:Depends}, python3-pkg-resources, ${misc:Depends}, ucf | ||
Recommends: cpu-energy-meter, libseccomp2, lxcfs, python3-coloredlogs, python3-pystemd | ||
Description: Framework for Reliable Benchmarking and Resource Measurement | ||
BenchExec allows benchmarking non-interactive tools on Linux systems. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
debian/additional_files/lib/* lib/ | ||
debian/additional_files/usr/* usr/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters