Better Xen support
cover Better Xen support
Hi. As maintainer of the Xen Project upstream CI, I do testing of upstream Xen builds onto Debian systems.
We use grub's 20_linux_xen to do the bootloader setup. However, it is missing some features so we are carrying some patches. Here they are for your consideration.
Regards, Ian.
Ian Jackson (2):
20_linux_xen: Ignore xenpolicy and config files too 20_linux_xen: Support Xen Security Modules (XSM/FLASK)
util/grub.d/20_linux_xen.in | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/2 20_linux_xen: Ignore xenpolicy and config files too
"file_is_not_sym" currently only checks for xen-syms. Extend it to disregard xenpolicy (XSM policy files) and files ending .config (which are built by the Xen upstream build system in some configurations and can therefore end up in /boot).
Rename the function accordingly, to "file_is_not_xen_garbage".
--- util/grub.d/20_linux_xen.in | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
util/grub.d/20_linux_xen.in +6 -2
@@ -181,10 +181,14 @@ if [ "x${linux_list}" = "x" ] ; then exit 0 fi -file_is_not_sym () { +file_is_not_xen_garbage () { case "$1" in */xen-syms-*) return 1;; + */xenpolicy-*) + return 1;; + */*.config) + return 1;; *) return 0;; esac
@@ -192,7 +196,7 @@ file_is_not_sym () { xen_list= for i in /boot/xen*; do - if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then xen_list="$xen_list $i" ; fi + if grub_file_is_not_garbage "$i" && file_is_not_xen_garbage "$i" ; then xen_list="$xen_list $i" ; fi done prepare_boot_cache= boot_device_id=
Signature · 1 line
2.20.1
PATCH 2/2 20_linux_xen: Support Xen Security Modules (XSM/FLASK)
In reply to Ian JacksonXSM is enabled by adding "flask=enforcing" as a Xen command line argument, and providing the policy file as a grub module.
We make entries for both with and without XSM. If XSM is not compiled into Xen, then there are no policy files, so no change to the boot options.
--- util/grub.d/20_linux_xen.in | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
util/grub.d/20_linux_xen.in +24 -0
@@ -94,6 +94,11 @@ esac title_correction_code= linux_entry () +{ + linux_entry_xsm "$@" false + linux_entry_xsm "$@" true +} +linux_entry_xsm () { os="$1" version="$2"
@@ -101,6 +106,18 @@ linux_entry () type="$4" args="$5" xen_args="$6" + xsm="$7" + # If user wants to enable XSM support, make sure there's + # corresponding policy file. + if ${xsm} ; then + xenpolicy="xenpolicy-$xen_version" + if test ! -e "${xen_dirname}/${xenpolicy}" ; then + return + fi + xen_args="$xen_args flask=enforcing" + xen_version="$(gettext_printf "%s (XSM enabled)" "$xen_version")" + # xen_version is used for messages only; actual file is xen_basename + fi if [ -z "$boot_device_id" ]; then boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" fi
@@ -154,6 +171,13 @@ EOF sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' ${module_loader} --nounzip $(echo $initrd_path) +EOF + fi + if test -n "${xenpolicy}" ; then + message="$(gettext_printf "Loading XSM policy ...")" + sed "s/^/$submenu_indentation/" << EOF + echo '$(echo "$message" | grub_quote)' + ${module_loader} ${rel_dirname}/${xenpolicy} EOF fi sed "s/^/$submenu_indentation/" << EOF
Signature · 1 line
2.20.1
Quoted 7 lines · Ian Jackson
Hi. As maintainer of the Xen Project upstream CI, I do testing of upstream Xen builds onto Debian systems.
We use grub's 20_linux_xen to do the bootloader setup. However, it is missing some features so we are carrying some patches. Here they are for your consideration.
Quoted 5 lines
Regards, Ian.
Ian Jackson (2):
20_linux_xen: Ignore xenpolicy and config files too 20_linux_xen: Support Xen Security Modules (XSM/FLASK)
Daniel