[PATCH 0/8] Fixes for Debian package functionality and build
Stefano Brivio (8): Makefile: Honour passed CPPFLAGS, not just CFLAGS Makefile: Don't filter out -O2 from supplied flags for AVX2 builds Makefile: It's AUDIT_ARCH_MIPSEL64, not AUDIT_ARCH_MIPS64EL Makefile: Change HPPA into PARISC while building PASST_AUDIT_ARCH util, pasta: Use __clone2() instead of clone() on ia64 README: Add links to Debian package tracker contrib/apparmor: Merge pasta and passt profiles, update rules Remove contrib/debian, Debian package development now happens on Salsa Makefile | 16 ++++---- README.md | 17 ++++---- contrib/apparmor/usr.bin.passt | 73 ++++++++++++++++++++++++---------- contrib/apparmor/usr.bin.pasta | 66 ------------------------------ contrib/debian/README.Debian | 8 ---- contrib/debian/changelog | 6 --- contrib/debian/control | 22 ---------- contrib/debian/copyright | 13 ------ contrib/debian/rules | 12 ------ contrib/debian/watch | 2 - pasta.c | 9 +++++ util.h | 12 ++++++ 12 files changed, 91 insertions(+), 165 deletions(-) delete mode 100644 contrib/apparmor/usr.bin.pasta delete mode 100644 contrib/debian/README.Debian delete mode 100644 contrib/debian/changelog delete mode 100644 contrib/debian/control delete mode 100644 contrib/debian/copyright delete mode 100755 contrib/debian/rules delete mode 100644 contrib/debian/watch -- 2.35.1
CPPFLAGS allow the user to pass pre-processor flags. This is unlikely
to be needed at the moment, but the Debian Hardening Walkthrough
reasonably requests it to be handled in order to fully support
hardened build flags:
https://wiki.debian.org/HardeningWalkthrough#Handling_dpkg-buildflags_in_you...
Signed-off-by: Stefano Brivio
On Tue, Nov 15, 2022 at 02:23:42AM +0100, Stefano Brivio wrote:
CPPFLAGS allow the user to pass pre-processor flags. This is unlikely to be needed at the moment, but the Debian Hardening Walkthrough reasonably requests it to be handled in order to fully support hardened build flags: https://wiki.debian.org/HardeningWalkthrough#Handling_dpkg-buildflags_in_you...
Signed-off-by: Stefano Brivio
Reviewed-by: David Gibson
--- Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile index 6b22408..a6e3164 100644 --- a/Makefile +++ b/Makefile @@ -60,8 +60,8 @@ HEADERS = $(PASST_HEADERS) seccomp.h # csum_unaligned(). Mark csum_unaligned() as "noipa" as a quick work-around, # while we figure out if a corresponding gcc issue has already been reported. ifeq (,$(filter-out 11 12, $(shell $(CC) -dumpversion))) -ifneq (,$(filter -flto%,$(FLAGS) $(CFLAGS))) -ifneq (,$(filter -O2,$(FLAGS) $(CFLAGS))) +ifneq (,$(filter -flto%,$(FLAGS) $(CFLAGS) $(CPPFLAGS))) +ifneq (,$(filter -O2,$(FLAGS) $(CFLAGS) $(CPPFLAGS))) FLAGS += -DTCP_HASH_NOINLINE FLAGS += -DSIPHASH_20B_NOINLINE FLAGS += -DCSUM_UNALIGNED_NO_IPA @@ -121,11 +121,11 @@ seccomp.h: seccomp.sh $(PASST_SRCS) $(PASST_HEADERS) @ EXTRA_SYSCALLS="$(EXTRA_SYSCALLS)" ./seccomp.sh $(PASST_SRCS) $(PASST_HEADERS)
passt: $(PASST_SRCS) $(HEADERS) - $(CC) $(FLAGS) $(CFLAGS) $(PASST_SRCS) -o passt $(LDFLAGS) + $(CC) $(FLAGS) $(CFLAGS) $(CPPFLAGS) $(PASST_SRCS) -o passt $(LDFLAGS)
passt.avx2: FLAGS += -Ofast -mavx2 -ftree-vectorize -funroll-loops passt.avx2: $(PASST_SRCS) $(HEADERS) - $(CC) $(filter-out -O2,$(FLAGS) $(CFLAGS)) \ + $(CC) $(filter-out -O2,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) \ $(PASST_SRCS) -o passt.avx2 $(LDFLAGS)
passt.avx2: passt @@ -134,7 +134,7 @@ pasta.avx2 pasta.1 pasta: pasta%: passt% ln -s $< $@
qrap: $(QRAP_SRCS) passt.h - $(CC) $(FLAGS) $(CFLAGS) $(QRAP_SRCS) -o qrap $(LDFLAGS) + $(CC) $(FLAGS) $(CFLAGS) $(CPPFLAGS) $(QRAP_SRCS) -o qrap $(LDFLAGS)
valgrind: EXTRA_SYSCALLS += rt_sigprocmask rt_sigtimedwait rt_sigaction \ getpid gettid kill clock_gettime mmap \ @@ -283,7 +283,7 @@ clang-tidy: $(SRCS) $(HEADERS) -concurrency-mt-unsafe,\ -readability-identifier-length \ -config='{CheckOptions: [{key: bugprone-suspicious-string-compare.WarnOnImplicitComparison, value: "false"}]}' \ - --warnings-as-errors=* $(SRCS) -- $(filter-out -pie,$(FLAGS) $(CFLAGS)) + --warnings-as-errors=* $(SRCS) -- $(filter-out -pie,$(FLAGS) $(CFLAGS) $(CPPFLAGS))
SYSTEM_INCLUDES := /usr/include $(wildcard /usr/include/$(TARGET)) ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version"),1) @@ -299,5 +299,5 @@ cppcheck: $(SRCS) $(HEADERS) $(SYSTEM_INCLUDES:%=--suppress=unmatchedSuppression:%/*) \ --inline-suppr \ --suppress=unusedStructMember \ - $(filter -D%,$(FLAGS) $(CFLAGS)) \ + $(filter -D%,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) \ .
-- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Drop it from the internal FLAGS variable, but honour -O2 if passed in
CFLAGS. In Debian packages, dpkg-buildflags uses it as hardening
flag, and we get a QA warning if we drop it:
https://qa.debian.org/bls/bytag/W-dpkg-buildflags-missing.html
Signed-off-by: Stefano Brivio
On Tue, Nov 15, 2022 at 02:23:43AM +0100, Stefano Brivio wrote:
Drop it from the internal FLAGS variable, but honour -O2 if passed in CFLAGS. In Debian packages, dpkg-buildflags uses it as hardening flag, and we get a QA warning if we drop it: https://qa.debian.org/bls/bytag/W-dpkg-buildflags-missing.html
Signed-off-by: Stefano Brivio
Reviewed-by: David Gibson
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile index a6e3164..f0b8e1d 100644 --- a/Makefile +++ b/Makefile @@ -125,7 +125,7 @@ passt: $(PASST_SRCS) $(HEADERS)
passt.avx2: FLAGS += -Ofast -mavx2 -ftree-vectorize -funroll-loops passt.avx2: $(PASST_SRCS) $(HEADERS) - $(CC) $(filter-out -O2,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) \ + $(CC) $(filter-out -O2,$(FLAGS)) $(CFLAGS) $(CPPFLAGS) \ $(PASST_SRCS) -o passt.avx2 $(LDFLAGS)
passt.avx2: passt
-- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
On mips64el, gcc -dumpmachine correctly reports mips64el as
architecture prefix, but for some reason seccomp.h defines
AUDIT_ARCH_MIPSEL64 and not AUDIT_ARCH_MIPS64EL. Mangle AUDIT_ARCH
accordingly.
Build error spotted in Debian's buildd logs from Loongson build.
Signed-off-by: Stefano Brivio
On Tue, Nov 15, 2022 at 02:23:44AM +0100, Stefano Brivio wrote:
On mips64el, gcc -dumpmachine correctly reports mips64el as architecture prefix, but for some reason seccomp.h defines AUDIT_ARCH_MIPSEL64 and not AUDIT_ARCH_MIPS64EL. Mangle AUDIT_ARCH accordingly.
Build error spotted in Debian's buildd logs from Loongson build.
Signed-off-by: Stefano Brivio
Reviewed-by: David Gibson
--- Makefile | 1 + 1 file changed, 1 insertion(+)
diff --git a/Makefile b/Makefile index f0b8e1d..95b49ac 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ AUDIT_ARCH := $(shell echo $(TARGET_ARCH) | tr [a-z] [A-Z] | sed 's/^ARM.*/ARM/' AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/I[456]86/I386/') AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/PPC64/PPC/') AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/PPCLE/PPC64LE/') +AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/MIPS64EL/MIPSEL64/')
FLAGS := -Wall -Wextra -pedantic -std=c99 -D_XOPEN_SOURCE=700 -D_GNU_SOURCE FLAGS += -D_FORTIFY_SOURCE=2 -O2 -pie -fPIE
-- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
The AUDIT_ARCH defines in seccomp.h corresponding to HPPA are
AUDIT_ARCH_PARISC and AUDIT_ARCH_PARISC64.
Build error spotted in Debian's buildd log on
phantom.physik.fu-berlin.de.
Signed-off-by: Stefano Brivio
On Tue, Nov 15, 2022 at 02:23:45AM +0100, Stefano Brivio wrote:
The AUDIT_ARCH defines in seccomp.h corresponding to HPPA are AUDIT_ARCH_PARISC and AUDIT_ARCH_PARISC64.
Build error spotted in Debian's buildd log on phantom.physik.fu-berlin.de.
Signed-off-by: Stefano Brivio
Reviewed-by: David Gibson
--- Makefile | 1 + 1 file changed, 1 insertion(+)
diff --git a/Makefile b/Makefile index 95b49ac..1dc2df5 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/I[456]86/I386/') AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/PPC64/PPC/') AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/PPCLE/PPC64LE/') AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/MIPS64EL/MIPSEL64/') +AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/HPPA/PARISC/')
FLAGS := -Wall -Wextra -pedantic -std=c99 -D_XOPEN_SOURCE=700 -D_GNU_SOURCE FLAGS += -D_FORTIFY_SOURCE=2 -O2 -pie -fPIE
-- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
On ia64, clone(2) is not available: the glibc wrapper is named
__clone2() and it takes, additionally, the size of the stack area
passed by the caller.
Spotted in Debian's buildd logs.
Signed-off-by: Stefano Brivio
On Tue, Nov 15, 2022 at 02:23:46AM +0100, Stefano Brivio wrote:
On ia64, clone(2) is not available: the glibc wrapper is named __clone2() and it takes, additionally, the size of the stack area passed by the caller.
Spotted in Debian's buildd logs.
Signed-off-by: Stefano Brivio
Urgh, I'd really prefer to make our own wrapper to reduce two ifdefs to one.
--- pasta.c | 9 +++++++++ util.h | 12 ++++++++++++ 2 files changed, 21 insertions(+)
diff --git a/pasta.c b/pasta.c index db86317..1f3afa1 100644 --- a/pasta.c +++ b/pasta.c @@ -226,11 +226,20 @@ void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid, arg.argv = sh_argv; }
+#ifdef __ia64__ + pasta_child_pid = __clone2(pasta_spawn_cmd, + ns_fn_stack + sizeof(ns_fn_stack) / 2, + sizeof(ns_fn_stack) / 2, + CLONE_NEWIPC | CLONE_NEWPID | CLONE_NEWNET | + CLONE_NEWUTS, + (void *)&arg); +#else pasta_child_pid = clone(pasta_spawn_cmd, ns_fn_stack + sizeof(ns_fn_stack) / 2, CLONE_NEWIPC | CLONE_NEWPID | CLONE_NEWNET | CLONE_NEWUTS, (void *)&arg); +#endif
if (pasta_child_pid == -1) { perror("clone"); diff --git a/util.h b/util.h index 2d4e1ff..3c48992 100644 --- a/util.h +++ b/util.h @@ -81,6 +81,17 @@ (((struct in_addr *)(a))->s_addr == ((struct in_addr *)b)->s_addr)
#define NS_FN_STACK_SIZE (RLIMIT_STACK_VAL * 1024 / 8) +#ifdef __ia64__ +#define NS_CALL(fn, arg) \ + do { \ + char ns_fn_stack[NS_FN_STACK_SIZE]; \ + \ + __clone2((fn), ns_fn_stack + sizeof(ns_fn_stack) / 2, \ + sizeof(ns_fn_stack) / 2, \ + CLONE_VM | CLONE_VFORK | CLONE_FILES | SIGCHLD,\ + (void *)(arg)); \ + } while (0) +#else #define NS_CALL(fn, arg) \ do { \ char ns_fn_stack[NS_FN_STACK_SIZE]; \ @@ -89,6 +100,7 @@ CLONE_VM | CLONE_VFORK | CLONE_FILES | SIGCHLD, \ (void *)(arg)); \ } while (0) +#endif
#if __BYTE_ORDER == __BIG_ENDIAN #define L2_BUF_ETH_IP4_INIT \
-- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
On Wed, 16 Nov 2022 16:17:13 +1100
David Gibson
On Tue, Nov 15, 2022 at 02:23:46AM +0100, Stefano Brivio wrote:
On ia64, clone(2) is not available: the glibc wrapper is named __clone2() and it takes, additionally, the size of the stack area passed by the caller.
Spotted in Debian's buildd logs.
Signed-off-by: Stefano Brivio
Urgh, I'd really prefer to make our own wrapper to reduce two ifdefs to one.
Hmm, right. I'd go with: __clone(int (*fn)(void *), void *stack_base, size_t stack_size, int flags, void *arg) ...where stack_base is ns_fn_stack. Better ideas (especially for the name)? -- Stefano
Signed-off-by: Stefano Brivio
On Tue, Nov 15, 2022 at 02:23:47AM +0100, Stefano Brivio wrote:
Signed-off-by: Stefano Brivio
Reviewed-by: David Gibson
--- README.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md index 0e2ca78..3d0a5b4 100644 --- a/README.md +++ b/README.md @@ -343,19 +343,20 @@ speeding up local connections, and usually requiring NAT. _pasta_: * ⌚ drop-in replacement for VPNKit (rootless Docker)
### Availability +* ✅ official [packages](https://tracker.debian.org/pkg/passt) for Debian * ✅ official [packages](https://src.fedoraproject.org/rpms/passt) for Fedora * ✅ unofficial [packages](https://copr.fedorainfracloud.org/coprs/sbrivio/passt/) for CentOS Stream, EPEL, Mageia -* ✅ unofficial packages from x86_64 static builds for other RPM-based - distributions and Debian +* ✅ unofficial [packages](https://passt.top/builds/latest/x86_64/) from x86_64 + static builds for other RPM-based distributions +* ✅ unofficial [packages](https://passt.top/builds/latest/x86_64/) from x86_64 + static builds for Debian-based distributions * ✅ testing on non-x86_64 architectures (aarch64, armv7l, i386, ppc64, ppc64le, s390x) -* ✅ example Debian [package files](/passt/tree/contrib/debian) * 🛠 official [openSUSE packages](https://build.opensuse.org/package/show/home:dfaggioli:devel/passt) -* ⌚ official packages for Debian - ([RFP](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1010498)), Arch Linux +* ⌚ official packages for Arch Linux
### Services * ✅ built-in [ARP proxy](/passt/tree/arp.c) @@ -538,12 +539,13 @@ See also the [test logs](/builds/latest/test/).
* alternatively, install one of the available packages:
- * [Debian and Debian-based](/builds/latest/x86_64/) (unofficial, from static x86_64 builds) + * [Debian](https://tracker.debian.org/pkg/passt) (official) * [Fedora](https://src.fedoraproject.org/rpms/passt) (official) * [CentOS Stream](https://copr.fedorainfracloud.org/coprs/sbrivio/passt/) (unofficial) * [EPEL](https://copr.fedorainfracloud.org/coprs/sbrivio/passt/) (unofficial) * [Mageia](https://copr.fedorainfracloud.org/coprs/sbrivio/passt/) (unofficial) * [openSUSE](https://build.opensuse.org/package/show/home:dfaggioli:devel/passt) (unofficial) + * [Debian-based](/builds/latest/x86_64/) (unofficial, from static x86_64 builds) * [Other RPM-based distributions](/builds/latest/x86_64/) (unofficial, from static x86_64 builds)
Static binaries and packages are simply built with: @@ -587,12 +589,13 @@ See also the [test logs](/builds/latest/test/).
* alternatively, install one of the available packages:
- * [Debian and Debian-based](/builds/latest/x86_64/) (unofficial, from static x86_64 builds) + * [Debian](https://tracker.debian.org/pkg/passt) (official) * [Fedora](https://src.fedoraproject.org/rpms/passt) (official) * [CentOS Stream](https://copr.fedorainfracloud.org/coprs/sbrivio/passt/) (unofficial) * [EPEL](https://copr.fedorainfracloud.org/coprs/sbrivio/passt/) (unofficial) * [Mageia](https://copr.fedorainfracloud.org/coprs/sbrivio/passt/) (unofficial) * [openSUSE](https://build.opensuse.org/package/show/home:dfaggioli:devel/passt) (unofficial) + * [Debian-based](/builds/latest/x86_64/) (unofficial, from static x86_64 builds) * [Other RPM-based distributions](/builds/latest/x86_64/) (unofficial, from static x86_64 builds)
Static binaries and packages are simply built with:
-- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
AppArmor resolves executable links before profile attachment rules
are evaluated, so, as long as pasta is installed as a link to passt,
there's no way to differentiate the two cases. Merge the two profiles
and leave a TODO note behind, explaining two possible ways forward.
Update the rules so that passt and pasta are actually usable, once
the profile is installed. Most required changes are related to
isolation and sandboxing features.
Signed-off-by: Stefano Brivio
The development of the Debian package is now at:
https://salsa.debian.org/sbrivio/passt
Drop contrib/debian, it's finally obsolete.
Signed-off-by: Stefano Brivio
participants (2)
-
David Gibson
-
Stefano Brivio