xen: fix build race condition

It has been reported that xen can fail to build with the
following error:

| In file included from xsm/flask/ss/services.c:46:
| ./xsm/flask/include/avc.h:18:10: fatal error: av_permissions.h: No
such file or directory
|    18 | #include "av_permissions.h"
|       |          ^~~~~~~~~~~~~~~~~~

This fix has been proposed upstream:
https://lore.kernel.org/xen-devel/20230120133626.55680-1-anthony.perard@citrix.com/T/#u

It doesn't break our build, so we include it for stress testing.

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Bruce Ashfield 2023-01-20 13:21:05 -05:00
parent 33e6cb346f
commit f79a5f962a
3 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,54 @@
From mboxrd@z Thu Jan 1 00:00:00 1970
From: Anthony PERARD <anthony.perard@citrix.com>
Subject: [XEN PATCH] build: fix building flask headers before descending in flask/ss/
Date: Fri, 20 Jan 2023 13:36:26 +0000
Message-ID: <20230120133626.55680-1-anthony.perard@citrix.com>
X-Mailer: git-send-email 2.30.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
Unfortunatly, adding prerequisite to "$(obj)/ss/built_in.o" doesn't
work because we have "$(obj)/%/built_in.o: $(obj)/% ;" in Rules.mk.
So, make is allow to try to build objects in "xsm/flask/ss/" before
generating the headers.
Adding a prerequisite on "$(obj)/ss" instead will fix the issue has
that the target used to run make in this subdirectory.
Unfortunatly, that target is also used when running `make clean`, so
we need to ignore it in this case. $(MAKECMDGOALS) can't be used in
this case as it is empty, but we can guess which operation is done by
looking at the list of loaded makefiles.
Upstream-Status: backport [https://lore.kernel.org/xen-devel/20230120133626.55680-1-anthony.perard@citrix.com/T/#u]
Fixes: 7a3bcd2babcc ("build: build everything from the root dir, use obj=$subdir")
Reported-by: "Daniel P. Smith" <dpsmith@apertussolutions.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
xen/xsm/flask/Makefile | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/xen/xsm/flask/Makefile b/xen/xsm/flask/Makefile
index d25312f4fa..2d24346ee3 100644
--- a/xen/xsm/flask/Makefile
+++ b/xen/xsm/flask/Makefile
@@ -16,7 +16,11 @@ FLASK_H_FILES := flask.h class_to_string.h initial_sid_to_string.h
AV_H_FILES := av_perm_to_string.h av_permissions.h
ALL_H_FILES := $(addprefix include/,$(FLASK_H_FILES) $(AV_H_FILES))
-$(addprefix $(obj)/,$(obj-y)) $(obj)/ss/built_in.o: $(addprefix $(obj)/,$(ALL_H_FILES))
+# Adding prerequisite to descending into ss/ folder only when not running `make
+# clean`.
+ifeq ($(filter %/Makefile.clean,$(MAKEFILE_LIST)),)
+$(addprefix $(obj)/,$(obj-y)) $(obj)/ss: $(addprefix $(obj)/,$(ALL_H_FILES))
+endif
extra-y += $(ALL_H_FILES)
mkflask := $(srcdir)/policy/mkflask.sh
--
Anthony PERARD

View File

@ -7,6 +7,7 @@ XEN_BRANCH ?= "stable-${XEN_REL}"
SRC_URI = " \
git://xenbits.xen.org/xen.git;branch=${XEN_BRANCH} \
file://0001-menuconfig-mconf-cfg-Allow-specification-of-ncurses-location.patch \
file://xen-flask-race-fix.patch \
"
LIC_FILES_CHKSUM ?= "file://COPYING;md5=d1a1e216f80b6d8da95fec897d0dbec9"

View File

@ -7,6 +7,7 @@ XEN_BRANCH ?= "master"
SRC_URI = " \
git://xenbits.xen.org/xen.git;branch=${XEN_BRANCH} \
file://0001-menuconfig-mconf-cfg-Allow-specification-of-ncurses-location.patch \
file://xen-flask-race-fix.patch \
"
LIC_FILES_CHKSUM ?= "file://COPYING;md5=d1a1e216f80b6d8da95fec897d0dbec9"