Bug 14336 - Update Apparmor to 2.13.6 on dunfell
Summary: Update Apparmor to 2.13.6 on dunfell
Status: RESOLVED FIXED
Alias: None
Product: Other YP Layers
Classification: Build System, Metadata & Runtime
Component: meta-security (show other bugs)
Version: 3.1.7
Hardware: x86 Multiple
: Undecided normal
Target Milestone: ---
Assignee: akuster
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2021-04-03 22:47 UTC by om26er
Modified: 2021-04-16 01:27 UTC (History)
0 users

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
Update apparmor to 2.13.6 (8.77 KB, patch)
2021-04-04 21:41 UTC, om26er
no flags Details | Diff
patch1 (8.77 KB, patch)
2021-04-12 17:44 UTC, om26er
no flags Details | Diff
patch2-fix-python-binding (964 bytes, patch)
2021-04-12 17:45 UTC, om26er
no flags Details | Diff
compile-capabilities-yocto-cpreprocessor (2.36 KB, patch)
2021-04-12 17:47 UTC, om26er
no flags Details | Diff
correctly-escape-in-makefile (2.03 KB, patch)
2021-04-12 18:02 UTC, om26er
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description om26er 2021-04-03 22:47:55 UTC
The dunfell branch is lagging behind a few bug fix releases of apparmor. The latest version is 2.13.6. however the dunfell branch currently has 2.13.4. There are multiple bug fixes that went in during between the two releases.

I guess it's time to update to the latest version. I am willing to help anyway possible
Comment 1 akuster 2021-04-04 00:11:55 UTC
(In reply to comment #0)
> The dunfell branch is lagging behind a few bug fix releases of apparmor. The
> latest version is 2.13.6. however the dunfell branch currently has 2.13.4.
> There are multiple bug fixes that went in during between the two releases.

Cool, thanks for the info.

> 
> I guess it's time to update to the latest version. I am willing to help
> anyway possible

You are welcome to send an update patch if your time permits.
Comment 2 om26er 2021-04-04 21:41:44 UTC
Created attachment 4782 [details]
Update apparmor to 2.13.6
Comment 3 om26er 2021-04-04 21:59:10 UTC
I have attached the patch, it builds and works fine for me.
Comment 4 om26er 2021-04-05 16:21:33 UTC
Armin, is this the right place to attach the patch or is there some procedure that I am missing ?
Comment 5 akuster 2021-04-08 15:02:22 UTC
(In reply to comment #4)
> Armin, is this the right place to attach the patch or is there some
> procedure that I am missing ?

this take the patch from here.

The README does the optional sending to the mailing list.

git send-email -1 --to yocto@lists.yoctoproject.org --subject-prefix=meta-security][PATCH
Comment 6 om26er 2021-04-08 17:20:53 UTC
Cool then, I guess this could land now ;-)

I will also send any future patches to the mailing list
Comment 7 akuster 2021-04-08 19:31:21 UTC
pulled in for testing.
Comment 8 om26er 2021-04-08 20:45:20 UTC
Comment on attachment 4782 [details]
Update apparmor to 2.13.6

>From c135251e03de78120edcac1c348cbff992a3ff01 Mon Sep 17 00:00:00 2001
>From: Omer Akram <omer@thing.com>
>Date: Mon, 5 Apr 2021 02:40:02 +0500
>Subject: [PATCH] Update apparmor to 2.13.6
>
>---
> ...{apparmor_2.13.4.bb => apparmor_2.13.6.bb} |  4 +-
> ...-Don-t-build-syscall_sysctl-if-missi.patch | 96 -------------------
> ...-fix-failure-on-older-versions-of-Ma.patch | 40 --------
> recipes-mac/AppArmor/files/disable_pdf.patch  | 33 -------
> 4 files changed, 1 insertion(+), 172 deletions(-)
> rename recipes-mac/AppArmor/{apparmor_2.13.4.bb => apparmor_2.13.6.bb} (96%)
> delete mode 100644 recipes-mac/AppArmor/files/0001-regression-tests-Don-t-build-syscall_sysctl-if-missi.patch
> delete mode 100644 recipes-mac/AppArmor/files/0001-tests-regression-fix-failure-on-older-versions-of-Ma.patch
> delete mode 100644 recipes-mac/AppArmor/files/disable_pdf.patch
>
>diff --git a/recipes-mac/AppArmor/apparmor_2.13.4.bb b/recipes-mac/AppArmor/apparmor_2.13.6.bb
>similarity index 96%
>rename from recipes-mac/AppArmor/apparmor_2.13.4.bb
>rename to recipes-mac/AppArmor/apparmor_2.13.6.bb
>index ba58fc5..3e7247a 100644
>--- a/recipes-mac/AppArmor/apparmor_2.13.4.bb
>+++ b/recipes-mac/AppArmor/apparmor_2.13.6.bb
>@@ -23,11 +23,9 @@ SRC_URI = " \
>     file://apparmor.service \
>     file://0001-Makefile.am-suppress-perllocal.pod.patch \
>     file://run-ptest \
>-    file://0001-regression-tests-Don-t-build-syscall_sysctl-if-missi.patch \
>-    file://0001-tests-regression-fix-failure-on-older-versions-of-Ma.patch \
>     "
> 
>-SRCREV = "df0ac742f7a1146181d8734d03334494f2015134"
>+SRCREV = "c16fff8cb487cf150e3e5ad536b7ff2d4cb4f784"
> S = "${WORKDIR}/git"
> 
> PARALLEL_MAKE = ""
>diff --git a/recipes-mac/AppArmor/files/0001-regression-tests-Don-t-build-syscall_sysctl-if-missi.patch b/recipes-mac/AppArmor/files/0001-regression-tests-Don-t-build-syscall_sysctl-if-missi.patch
>deleted file mode 100644
>index 3cd1e88..0000000
>--- a/recipes-mac/AppArmor/files/0001-regression-tests-Don-t-build-syscall_sysctl-if-missi.patch
>+++ /dev/null
>@@ -1,96 +0,0 @@
>-From 7a7c7fb346ded6f017c8df44486778a5f032d41a Mon Sep 17 00:00:00 2001
>-From: John Johansen <john.johansen@canonical.com>
>-Date: Tue, 29 Sep 2020 03:05:22 -0700
>-Subject: [PATCH] regression tests: Don't build syscall_sysctl if missing
>- kernel headers
>-
>-sys/sysctl.h is not guaranteed to exist anymore since
>-https://sourceware.org/pipermail/glibc-cvs/2020q2/069366.html
>-
>-which is a follow on to the kernel commit
>-61a47c1ad3a4 sysctl: Remove the sysctl system call
>-
>-While the syscall_sysctl currently checks if the kernel supports
>-sysctrs before running the tests. The tests can't even build if the
>-kernel headers don't have the sysctl defines.
>-
>-Fixes: https://gitlab.com/apparmor/apparmor/-/issues/119
>-Fixes: https://bugs.launchpad.net/apparmor/+bug/1897288
>-MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/637
>-Signed-off-by: John Johansen <john.johansen@canonical.com>
>-Acked-by: Steve Beattie <steve.beattie@canonical.com>
>-(cherry picked from commit 2e5a266eb715fc7e526520235a6450444775791f)
>-
>-Upstream-Status: Backport
>-Signed-off-by: Armin Kuster <akuster808@gmail.com>
>-
>----
>- tests/regression/apparmor/Makefile          | 10 +++++++++-
>- tests/regression/apparmor/syscall_sysctl.sh | 15 +++++++++++----
>- 2 files changed, 20 insertions(+), 5 deletions(-)
>-
>-diff --git a/tests/regression/apparmor/Makefile b/tests/regression/apparmor/Makefile
>-index 198ca421..c3d0cfb7 100644
>---- a/tests/regression/apparmor/Makefile
>-+++ b/tests/regression/apparmor/Makefile
>-@@ -69,6 +69,9 @@ endif # USE_SYSTEM
>- 
>- CFLAGS += -g -O0 -Wall -Wstrict-prototypes
>- 
>-+USE_SYSCTL:=$(shell echo "#include <sys/sysctl.h>" | cpp -dM >/dev/null 2>/dev/null && echo true)
>-+
>-+
>- SRC=access.c \
>-     at_secure.c \
>-     introspect.c \
>-@@ -130,7 +133,6 @@ SRC=access.c \
>-     syscall_sethostname.c \
>-     syscall_setdomainname.c \
>-     syscall_setscheduler.c \
>--    syscall_sysctl.c \
>-     sysctl_proc.c \
>-     tcp.c \
>-     transition.c \
>-@@ -146,6 +148,12 @@ ifneq (,$(findstring $(shell uname -i),i386 i486 i586 i686 x86 x86_64))
>- SRC+=syscall_ioperm.c syscall_iopl.c
>- endif
>- 
>-+#only do sysctl syscall test if defines installed and OR supported by the
>-+# kernel
>-+ifeq ($(USE_SYSCTL),true)
>-+SRC+=syscall_sysctl.c
>-+endif
>-+
>- #only do dbus if proper libs are installl
>- ifneq (,$(shell pkg-config --exists dbus-1 && echo TRUE))
>- SRC+=dbus_eavesdrop.c dbus_message.c dbus_service.c dbus_unrequested_reply.c
>-diff --git a/tests/regression/apparmor/syscall_sysctl.sh b/tests/regression/apparmor/syscall_sysctl.sh
>-index f93946f3..5f856984 100644
>---- a/tests/regression/apparmor/syscall_sysctl.sh
>-+++ b/tests/regression/apparmor/syscall_sysctl.sh
>-@@ -148,11 +148,18 @@ test_sysctl_proc()
>- # check if the kernel supports CONFIG_SYSCTL_SYSCALL
>- # generally we want to encourage kernels to disable it, but if it's
>- # enabled we want to test against it
>--settest syscall_sysctl
>--if ! res="$(${test} ro 2>&1)" && [ "$res" = "FAIL: sysctl read failed - Function not implemented" ] ; then
>--    echo "	WARNING: syscall sysctl not implemented, skipping tests ..."
>-+# In addition test that sysctl exists in the kernel headers, if it does't
>-+# then we can't even built the syscall_sysctl test
>-+if  echo "#include <sys/sysctl.h>" | cpp -dM >/dev/null 2>/dev/null ; then
>-+    settest syscall_sysctl
>-+
>-+    if ! res="$(${test} ro 2>&1)" && [ "$res" = "FAIL: sysctl read failed - Function not implemented" ] ; then
>-+	echo "	WARNING: syscall sysctl not implemented, skipping tests ..."
>-+    else
>-+	test_syscall_sysctl
>-+    fi
>- else
>--    test_syscall_sysctl
>-+    echo "	WARNING: syscall sysctl not supported by kernel headers, skipping tests ..."
>- fi
>- 
>- # now test /proc/sys/ paths
>--- 
>-2.17.1
>-
>diff --git a/recipes-mac/AppArmor/files/0001-tests-regression-fix-failure-on-older-versions-of-Ma.patch b/recipes-mac/AppArmor/files/0001-tests-regression-fix-failure-on-older-versions-of-Ma.patch
>deleted file mode 100644
>index a23d889..0000000
>--- a/recipes-mac/AppArmor/files/0001-tests-regression-fix-failure-on-older-versions-of-Ma.patch
>+++ /dev/null
>@@ -1,40 +0,0 @@
>-From bf8c4ca570c27cf58e882e03680b40357223e6e7 Mon Sep 17 00:00:00 2001
>-From: John Johansen <john.johansen@canonical.com>
>-Date: Wed, 30 Sep 2020 13:36:23 -0700
>-Subject: [PATCH] tests regression: fix failure on older versions of Make
>-
>-Older versions of Make will choke on the # character in the $(shell
>-expression, treating it as the beginning of a comment. Resulting in
>-the following error
>-
>-make unterminated call to function 'shell': missing ')'.  Stop.
>-
>-MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/639
>-Signed-off-by: John Johansen <john.johansen@canonical.com>
>-Acked-by: Steve Beattie <steve.beattie@canonical.com>
>-(cherry picked from commit 8cf3534a5b11643c5913e5eb74e491f2f014d792)
>-
>-Upstream-Status: Backport
>-[Minor fixup]
>-Signed-off-by: Armin Kuster <akuster808@gmail.com>
>----
>- tests/regression/apparmor/Makefile | 3 ++-
>- 1 file changed, 2 insertions(+), 1 deletion(-)
>-
>-diff --git a/tests/regression/apparmor/Makefile b/tests/regression/apparmor/Makefile
>-index c3d0cfb7..1d55547c 100644
>---- a/tests/regression/apparmor/Makefile
>-+++ b/tests/regression/apparmor/Makefile
>-@@ -69,7 +69,8 @@ endif # USE_SYSTEM
>- 
>- CFLAGS += -g -O0 -Wall -Wstrict-prototypes
>- 
>--USE_SYSCTL:=$(shell echo "#include <sys/sysctl.h>" | cpp -dM >/dev/null 2>/dev/null && echo true)
>-+SYSCTL_INCLUDE="\#include <sys/sysctl.h>"
>-+USE_SYSCTL:=$(shell echo $(SYSCTL_INCLUDE) | cpp -dM >/dev/null 2>/dev/null && echo true)
>- 
>- 
>- SRC=access.c \
>--- 
>-2.17.1
>-
>diff --git a/recipes-mac/AppArmor/files/disable_pdf.patch b/recipes-mac/AppArmor/files/disable_pdf.patch
>deleted file mode 100644
>index c6b4bdd..0000000
>--- a/recipes-mac/AppArmor/files/disable_pdf.patch
>+++ /dev/null
>@@ -1,33 +0,0 @@
>-Index: apparmor-2.10.95/parser/Makefile
>-===================================================================
>---- apparmor-2.10.95.orig/parser/Makefile
>-+++ apparmor-2.10.95/parser/Makefile
>-@@ -139,17 +139,6 @@ export Q VERBOSE BUILD_OUTPUT
>- po/${NAME}.pot: ${SRCS} ${HDRS}
>- 	$(MAKE) -C po ${NAME}.pot NAME=${NAME} SOURCES="${SRCS} ${HDRS}"
>- 
>--techdoc.pdf: techdoc.tex
>--	timestamp=$(shell date --utc "+%Y%m%d%H%M%S%z" -r $< );\
>--	while pdflatex "\def\fixedpdfdate{$$timestamp}\input $<" ${BUILD_OUTPUT} || exit 1 ; \
>--		grep -q "Label(s) may have changed" techdoc.log; \
>--	do :; done
>--
>--techdoc/index.html: techdoc.pdf
>--	latex2html -show_section_numbers -split 0 -noinfo -nonavigation -noaddress techdoc.tex ${BUILD_OUTPUT}
>--
>--techdoc.txt: techdoc/index.html
>--	w3m -dump $< > $@
>- 
>- # targets arranged this way so that people who don't want full docs can
>- # pick specific targets they want.
>-@@ -159,9 +148,7 @@ manpages:	$(MANPAGES)
>- 
>- htmlmanpages:	$(HTMLMANPAGES)
>- 
>--pdf:	techdoc.pdf
>--
>--docs:	manpages htmlmanpages pdf
>-+docs:	manpages htmlmanpages 
>- 
>- indep: docs
>- 	$(Q)$(MAKE) -C po all
>-- 
>2.25.1
>
Comment 9 om26er 2021-04-08 20:47:56 UTC
Sorry for the spam in last comment, not very familiar with bugzilla.
Comment 10 akuster 2021-04-09 15:12:39 UTC
qemuarm64 build fails.

https://errors.yoctoproject.org/Errors/Build/119792/


DISTRO_FEATURES_append = " apparmor pam smack systemd"
Comment 11 akuster 2021-04-09 17:06:04 UTC
qemux86_64 failed with ptest.

https://errors.yoctoproject.org/Errors/Build/119818/
Comment 12 om26er 2021-04-12 16:40:21 UTC
(In reply to comment #10)
> qemuarm64 build fails.
> 
> https://errors.yoctoproject.org/Errors/Build/119792/
> 
> 
> DISTRO_FEATURES_append = " apparmor pam smack systemd"

The cross-compilation issue is due to https://bugzilla.yoctoproject.org/show_bug.cgi?id=14239 -- I didn't face this issue because I had a bbapend to disable python binding. Need to investigate a bit into this more
Comment 13 om26er 2021-04-12 17:44:55 UTC
Created attachment 4786 [details]
patch1
Comment 14 om26er 2021-04-12 17:45:35 UTC
Created attachment 4787 [details]
patch2-fix-python-binding
Comment 15 om26er 2021-04-12 17:47:39 UTC
Created attachment 4788 [details]
compile-capabilities-yocto-cpreprocessor

In a Yocto based build environment use the C preprocessor not from the host, rather use the one that's in the build environment.
Comment 16 om26er 2021-04-12 18:02:36 UTC
Created attachment 4789 [details]
correctly-escape-in-makefile

This fixes the failing ptest. See https://stackoverflow.com/questions/53836858/shell-function-in-gnu-makefile-results-in-unterminated-call-to-function-shel
Comment 17 om26er 2021-04-15 11:14:12 UTC
Armin, the attached set of patches should fix all the issues you highlighted. Kindly take a look when you have some time
Comment 18 akuster 2021-04-16 01:04:28 UTC
this set was run on my builder and I should be updating the main repo soon.

thanks for the update and fixes.
Comment 19 akuster 2021-04-16 01:27:55 UTC
merged.