flask: build policy in different locations
PATCH 1/1 flask: build policy in different locations
The flask policy can be build twice -- one for hypervisor and one for tools.
Before this patch, everything is built inside tools/flask/policy directory. It is possible to have a race to write to the same output file when running parallel builds.
Prepend output file names with FLASK_BUILD_DIR. Hypervisor and tools build will set that variable to different directories, so that we can be safe from races.
Adjust other bits of the build system as needed.
---
Cc: Daniel De Graaf <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
--- .gitignore | 2 ++ tools/flask/policy/Makefile | 2 ++ tools/flask/policy/Makefile.common | 12 ++++++++---- xen/xsm/flask/Makefile | 7 ++++--- 4 files changed, 16 insertions(+), 7 deletions(-)
.gitignore +2 -0
@@ -285,6 +285,8 @@ xen/xsm/flask/include/av_permissions.h xen/xsm/flask/include/class_to_string.h xen/xsm/flask/include/flask.h xen/xsm/flask/include/initial_sid_to_string.h +xen/xsm/flask/policy.* +xen/xsm/flask/xenpolicy-* tools/flask/policy/policy.conf tools/flask/policy/xenpolicy-* xen/xen
tools/flask/policy/Makefile +2 -0
@@ -1,4 +1,6 @@ XEN_ROOT=$(CURDIR)/../../.. include $(XEN_ROOT)/tools/Rules.mk +FLASK_BUILD_DIR=$(CURDIR) + include $(CURDIR)/Makefile.common
tools/flask/policy/Makefile.common +8 -4
@@ -3,6 +3,10 @@ XEN_ROOT=$(CURDIR)/../../.. +ifeq ($(FLASK_BUILD_DIR),) +$(error FLASK_BUILD_DIR not set) +endif + ######################################## # # Configurable portions of the Makefile
@@ -31,7 +35,7 @@ OUTPUT_POLICY ?= $(BEST_POLICY_VER) # ######################################## -POLICY_FILENAME = xenpolicy-$(shell $(MAKE) -C $(XEN_ROOT)/xen xenversion --no-print-directory) +POLICY_FILENAME = $(FLASK_BUILD_DIR)/xenpolicy-$(shell $(MAKE) -C $(XEN_ROOT)/xen xenversion --no-print-directory) POLICY_LOADPATH = /boot # List of policy versions supported by the hypervisor
@@ -114,14 +118,14 @@ install: $(POLICY_FILENAME) $(INSTALL_DIR) $(DESTDIR)/$(POLICY_LOADPATH) $(INSTALL_DATA) $^ $(DESTDIR)/$(POLICY_LOADPATH) -$(POLICY_FILENAME): policy.conf +$(POLICY_FILENAME): $(FLASK_BUILD_DIR)/policy.conf $(CHECKPOLICY) $(CHECKPOLICY_PARAM) $^ -o $@ -policy.conf: $(POLICY_SECTIONS) $(MOD_CONF) +$(FLASK_BUILD_DIR)/policy.conf: $(POLICY_SECTIONS) $(MOD_CONF) $(M4) $(M4PARAM) $(POLICY_SECTIONS) > $@ clean: - $(RM) tmp policy.conf $(POLICY_FILENAME) + $(RM) $(FLASK_BUILD_DIR)/tmp $(FLASK_BUILD_DIR)/policy.conf $(POLICY_FILENAME) distclean: clean
xen/xsm/flask/Makefile +4 -3
@@ -29,10 +29,11 @@ $(AV_H_FILES): $(AV_H_DEPEND) obj-$(CONFIG_XSM_POLICY) += policy.o -POLICY_SRC := $(XEN_ROOT)/tools/flask/policy/xenpolicy-$(XEN_FULLVERSION) +FLASK_BUILD_DIR := $(CURDIR) +POLICY_SRC := $(FLASK_BUILD_DIR)/xenpolicy-$(XEN_FULLVERSION) policy.bin: FORCE - $(MAKE) -f $(XEN_ROOT)/tools/flask/policy/Makefile.common -C $(XEN_ROOT)/tools/flask/policy + $(MAKE) -f $(XEN_ROOT)/tools/flask/policy/Makefile.common -C $(XEN_ROOT)/tools/flask/policy FLASK_BUILD_DIR=$(FLASK_BUILD_DIR) cmp -s $(POLICY_SRC) $@ || cp $(POLICY_SRC) $@ policy.c: policy.bin gen-policy.py
@@ -40,4 +41,4 @@ policy.c: policy.bin gen-policy.py .PHONY: clean clean:: - rm -f $(ALL_H_FILES) *.o $(DEPS) policy.c policy.bin + rm -f $(ALL_H_FILES) *.o $(DEPS) policy.* $(POLICY_SRC)
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
.gitignore xen/xsm/flask/include/av_permissions.h · line 289
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 28.10.16 at 17:17, <[email protected]> wrote:
.gitignore +2
-0@@ -285,6 +285,8 @@ xen/xsm/flask/include/av_permissions.h xen/xsm/flask/include/class_to_string.h xen/xsm/flask/include/flask.h xen/xsm/flask/include/initial_sid_to_string.h +xen/xsm/flask/policy.* +xen/xsm/flask/xenpolicy-*
The two entries getting added here aren't in line with ...
.gitignore xen/xsm/flask/include/av_permissions.h · line 291
Quoted 3 lines
.gitignore +1
-1clean: - $(RM) tmp policy.conf $(POLICY_FILENAME) + $(RM) $(FLASK_BUILD_DIR)/tmp $(FLASK_BUILD_DIR)/policy.conf $(POLICY_FILENAME)
... the altered tmp removal here. I can't, however, tell which side needs updating.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 12 lines · Jan Beulich
.gitignore xen/xsm/flask/include/av_permissions.h · line 289
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 28.10.16 at 17:17, <[email protected]> wrote:
.gitignore +2
-0@@ -285,6 +285,8 @@ xen/xsm/flask/include/av_permissions.h xen/xsm/flask/include/class_to_string.h xen/xsm/flask/include/flask.h xen/xsm/flask/include/initial_sid_to_string.h +xen/xsm/flask/policy.* +xen/xsm/flask/xenpolicy-*The two entries getting added here aren't in line with ...
Quoted 7 lines
.gitignore xen/xsm/flask/include/av_permissions.h · line 291
Quoted 3 lines
.gitignore +1
-1clean: - $(RM) tmp policy.conf $(POLICY_FILENAME) + $(RM) $(FLASK_BUILD_DIR)/tmp $(FLASK_BUILD_DIR)/policy.conf $(POLICY_FILENAME)... the altered tmp removal here. I can't, however, tell which side needs updating.
tmp should be removed because there is no such thing.
Wei.
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 11 lines · Wei Liu
The flask policy can be build twice -- one for hypervisor and one for tools.
Before this patch, everything is built inside
tools/flask/policydirectory. It is possible to have a race to write to the same output file when running parallel builds.Prepend output file names with
FLASK_BUILD_DIR. Hypervisor and tools build will set that variable to different directories, so that we can be safe from races.
Quoted 7 lines
Adjust other bits of the build system as needed.
Signed-off-by Wei Liu <[email protected]>---
Cc: Daniel De Graaf <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Daniel and Ian, do you have opinions on this patch?
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 7 lines · Wei Liu
The flask policy can be build twice -- one for hypervisor and one for tools.
Before this patch, everything is built inside
tools/flask/policydirectory. It is possible to have a race to write to the same output file when running parallel builds.
Quoted 7 lines
Prepend output file names with
FLASK_BUILD_DIR. Hypervisor and tools build will set that variable to different directories, so that we can be safe from races.Adjust other bits of the build system as needed.
Signed-off-by Wei Liu <[email protected]>
Pulling the definition of POLICY_FILENAME out of Makefile.common might remove the need for the cmp||cp line in the xen-side Makefile, but that probably belongs in another patch.
Signature · 7 lines
Daniel De Graaf National Security Agency _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 12 lines · Daniel De Graaf
Quoted 11 lines · Wei Liu
The flask policy can be build twice -- one for hypervisor and one for tools.
Before this patch, everything is built inside
tools/flask/policydirectory. It is possible to have a race to write to the same output file when running parallel builds.Prepend output file names with
FLASK_BUILD_DIR. Hypervisor and tools build will set that variable to different directories, so that we can be safe from races.
Quoted 6 lines
Quoted 3 lines
Adjust other bits of the build system as needed.
Signed-off-by Wei Liu <[email protected]>Acked-by Daniel De Graaf <[email protected]>
Thanks.
Quoted 4 lines
Pulling the definition of
POLICY_FILENAMEout of Makefile.common might remove the need for the cmp||cp line in the xen-sideMakefile, but that probably belongs in another patch.
Yes, I think that's better done with another patch.
I will remove the redundant "tmp" in Makefile.common as discussed with Jan and commit the updated patch with your ack.
Wei.
Quoted 3 lines
Signature · 2 lines
Daniel De Graaf National Security Agency
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 27 lines · Wei Liu
Quoted 12 lines · Daniel De Graaf
Quoted 11 lines · Wei Liu
The flask policy can be build twice -- one for hypervisor and one for tools.
Before this patch, everything is built inside
tools/flask/policydirectory. It is possible to have a race to write to the same output file when running parallel builds.Prepend output file names with
FLASK_BUILD_DIR. Hypervisor and tools build will set that variable to different directories, so that we can be safe from races.Quoted 6 lines
Quoted 3 lines
Adjust other bits of the build system as needed.
Signed-off-by Wei Liu <[email protected]>Acked-by Daniel De Graaf <[email protected]>Thanks.
Quoted 4 lines
Pulling the definition of
POLICY_FILENAMEout of Makefile.common might remove the need for the cmp||cp line in the xen-sideMakefile, but that probably belongs in another patch.
Quoted 4 lines
Yes, I think that's better done with another patch.
I will remove the redundant "tmp" in Makefile.common as discussed with Jan and commit the updated patch with your ack.
Now applied.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel