Skip to contentSkip to conversation

xen/flask: Wire up missing hypercalls

PATCH In review Michal Orzel 3 participants 8 messages Jan 7, 2025 – Jan 8, 2025

lore
Share & tools
lore
#0 lore raw

cover xen/flask: Wire up missing hypercalls

It's been noted by Juergen that recently added XEN_DOMCTL_set_llc_colors is not wired up in FLASK. While preparing a fix, I noticed two other Arm hypercalls from the past that were missing the linking as well. These two are latent bugs while the LLC one is a release blocker for 4.20.

Michal Orzel (3):
xen/flask: Wire up XEN_DOMCTL_vuart_op
xen/flask: Wire up XEN_DOMCTL_dt_overlay
xen/flask: Wire up XEN_DOMCTL_set_llc_colors

 tools/flask/policy/modules/dom0.te  | 2 +-
 tools/flask/policy/modules/xen.if   | 4 ++--
 xen/xsm/flask/hooks.c               | 9 +++++++++
 xen/xsm/flask/policy/access_vectors | 6 ++++++
 4 files changed, 18 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 xen/flask: Wire up XEN_DOMCTL_vuart_op

Addition of FLASK permission for this hypercall was overlooked in the original patch. Fix it. The only VUART operation is initialization that can occur only during domain creation.

Fixes 86039f2e8c20 ("xen/arm: vpl011: Add a new domctl API to initialize vpl011")
---
 tools/flask/policy/modules/xen.if   | 2 +-
 xen/xsm/flask/hooks.c               | 3 +++
 xen/xsm/flask/policy/access_vectors | 2 ++
 3 files changed, 6 insertions(+), 1 deletion(-)
tools/flask/policy/modules/xen.if +1 -1
index 11c1562aa5da..ba9e91d30201 100644
@@ -54,7 +54,7 @@ define(`create_domain_common', `
 	allow $1 $2:domain2 { set_cpu_policy settsc setscheduler setclaim
 			set_vnumainfo get_vnumainfo cacheflush
 			psr_cmt_op psr_alloc soft_reset
-			resource_map get_cpu_policy };
+			resource_map get_cpu_policy vuart_op };
 	allow $1 $2:security check_context;
 	allow $1 $2:shadow enable;
 	allow $1 $2:mmu { map_read map_write adjust memorymap physmap pinpage mmuext_op updatemp };
xen/xsm/flask/hooks.c +3 -0
index 2b4efde6896d..5118f86cf030 100644
@@ -832,6 +832,9 @@ static int cf_check flask_domctl(struct domain *d, unsigned int cmd,
     case XEN_DOMCTL_soft_reset:
         return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__SOFT_RESET);
 
+    case XEN_DOMCTL_vuart_op:
+        return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__VUART_OP);
+
     case XEN_DOMCTL_get_cpu_policy:
         return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__GET_CPU_POLICY);
 
xen/xsm/flask/policy/access_vectors +2 -0
index a35e3d4c51e1..7cbdb7ea6408 100644
@@ -251,6 +251,8 @@ class domain2
     resource_map
 # XEN_DOMCTL_get_cpu_policy
     get_cpu_policy
+# XEN_DOMCTL_vuart_op
+    vuart_op
 }
 
 # Similar to class domain, but primarily contains domctls related to HVM domains
Signature · 1 line
2.25.1
Acked-by on v1 1/3
#2 lore raw

Re: [for-4.20][PATCH 1/3] xen/flask: Wire up XEN_DOMCTL_vuart_op

Quoted 6 lines · Michal Orzel

Addition of FLASK permission for this hypercall was overlooked in the original patch. Fix it. The only VUART operation is initialization that can occur only during domain creation.

Fixes 86039f2e8c20 ("xen/arm: vpl011: Add a new domctl API to initialize vpl011")
#3 lore raw

PATCH 2/3 xen/flask: Wire up XEN_DOMCTL_dt_overlay

In reply to Michal Orzel

Addition of FLASK permission for this hypercall was overlooked in the original patch. Fix it. The only dt overlay operation is attaching that can happen only after the domain is created. Dom0 can attach overlay to itself as well.

Fixes 4c733873b5c2 ("xen/arm: Add XEN_DOMCTL_dt_overlay and device attachment to domains")
---
 tools/flask/policy/modules/dom0.te  | 2 +-
 tools/flask/policy/modules/xen.if   | 2 +-
 xen/xsm/flask/hooks.c               | 3 +++
 xen/xsm/flask/policy/access_vectors | 2 ++
 4 files changed, 7 insertions(+), 2 deletions(-)
tools/flask/policy/modules/dom0.te +1 -1
index 16b8c9646d1b..f148bfbf274e 100644
@@ -40,7 +40,7 @@ allow dom0_t dom0_t:domain {
 };
 allow dom0_t dom0_t:domain2 {
 	set_cpu_policy gettsc settsc setscheduler set_vnumainfo
-	get_vnumainfo psr_cmt_op psr_alloc get_cpu_policy
+	get_vnumainfo psr_cmt_op psr_alloc get_cpu_policy dt_overlay
 };
 allow dom0_t dom0_t:resource { add remove };
 
tools/flask/policy/modules/xen.if +1 -1
index ba9e91d30201..def60da88301 100644
@@ -94,7 +94,7 @@ define(`manage_domain', `
 			getaddrsize pause unpause trigger shutdown destroy
 			setaffinity setdomainmaxmem getscheduler resume
 			setpodtarget getpodtarget getpagingmempool setpagingmempool };
-    allow $1 $2:domain2 set_vnumainfo;
+    allow $1 $2:domain2 { set_vnumainfo dt_overlay };
 ')
 
 # migrate_domain_out(priv, target)
xen/xsm/flask/hooks.c +3 -0
index 5118f86cf030..e263e745d441 100644
@@ -844,6 +844,9 @@ static int cf_check flask_domctl(struct domain *d, unsigned int cmd,
     case XEN_DOMCTL_set_paging_mempool_size:
         return current_has_perm(d, SECCLASS_DOMAIN, DOMAIN__SETPAGINGMEMPOOL);
 
+    case XEN_DOMCTL_dt_overlay:
+        return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__DT_OVERLAY);
+
     default:
         return avc_unknown_permission("domctl", cmd);
     }
xen/xsm/flask/policy/access_vectors +2 -0
index 7cbdb7ea6408..78fe37583b18 100644
@@ -253,6 +253,8 @@ class domain2
     get_cpu_policy
 # XEN_DOMCTL_vuart_op
     vuart_op
+# XEN_DOMCTL_dt_overlay
+    dt_overlay
 }
 
 # Similar to class domain, but primarily contains domctls related to HVM domains
Signature · 1 line
2.25.1
Acked-by on v1 2/3
#4 lore raw

Re: [for-4.20][PATCH 2/3] xen/flask: Wire up XEN_DOMCTL_dt_overlay

Quoted 7 lines · Michal Orzel

Addition of FLASK permission for this hypercall was overlooked in the original patch. Fix it. The only dt overlay operation is attaching that can happen only after the domain is created. Dom0 can attach overlay to itself as well.

Fixes 4c733873b5c2 ("xen/arm: Add XEN_DOMCTL_dt_overlay and device attachment to domains")
#5 lore raw

PATCH 3/3 xen/flask: Wire up XEN_DOMCTL_set_llc_colors

In reply to Michal Orzel

Addition of FLASK permission for this hypercall was overlooked in the original patch. Fix it. Setting LLC colors is only possible during domain creation.

Fixes 6985aa5e0c3c ("xen: extend domctl interface for cache coloring")
---
 tools/flask/policy/modules/xen.if   | 2 +-
 xen/xsm/flask/hooks.c               | 3 +++
 xen/xsm/flask/policy/access_vectors | 2 ++
 3 files changed, 6 insertions(+), 1 deletion(-)
tools/flask/policy/modules/xen.if +1 -1
index def60da88301..f7cf7c43c80b 100644
@@ -54,7 +54,7 @@ define(`create_domain_common', `
 	allow $1 $2:domain2 { set_cpu_policy settsc setscheduler setclaim
 			set_vnumainfo get_vnumainfo cacheflush
 			psr_cmt_op psr_alloc soft_reset
-			resource_map get_cpu_policy vuart_op };
+			resource_map get_cpu_policy vuart_op set_llc_colors };
 	allow $1 $2:security check_context;
 	allow $1 $2:shadow enable;
 	allow $1 $2:mmu { map_read map_write adjust memorymap physmap pinpage mmuext_op updatemp };
xen/xsm/flask/hooks.c +3 -0
index e263e745d441..14d84df9cad6 100644
@@ -847,6 +847,9 @@ static int cf_check flask_domctl(struct domain *d, unsigned int cmd,
     case XEN_DOMCTL_dt_overlay:
         return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__DT_OVERLAY);
 
+    case XEN_DOMCTL_set_llc_colors:
+        return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__SET_LLC_COLORS);
+
     default:
         return avc_unknown_permission("domctl", cmd);
     }
xen/xsm/flask/policy/access_vectors +2 -0
index 78fe37583b18..320d77706dee 100644
@@ -255,6 +255,8 @@ class domain2
     vuart_op
 # XEN_DOMCTL_dt_overlay
     dt_overlay
+# XEN_DOMCTL_set_llc_colors
+    set_llc_colors
 }
 
 # Similar to class domain, but primarily contains domctls related to HVM domains
Signature · 1 line
2.25.1
Acked-by on v1 3/3
#6 lore raw

Re: [for-4.20][PATCH 3/3] xen/flask: Wire up XEN_DOMCTL_set_llc_colors

Quoted 6 lines · Michal Orzel

Addition of FLASK permission for this hypercall was overlooked in the original patch. Fix it. Setting LLC colors is only possible during domain creation.

Fixes 6985aa5e0c3c ("xen: extend domctl interface for cache coloring")
#7 lore raw
In reply to Michal Orzel

Hi Michal,

Quoted 4 lines · Michal Orzel

It's been noted by Juergen that recently added XEN_DOMCTL_set_llc_colors is not wired up in FLASK. While preparing a fix, I noticed two other Arm hypercalls from the past that were missing the linking as well. These two are latent bugs while the LLC one is a release blocker for 4.20.

Thanks.

~ Oleksii

Quoted 12 lines

Michal Orzel (3):
xen/flask: Wire up XEN_DOMCTL_vuart_op
xen/flask: Wire up XEN_DOMCTL_dt_overlay
xen/flask: Wire up XEN_DOMCTL_set_llc_colors

  tools/flask/policy/modules/dom0.te  | 2 +-
  tools/flask/policy/modules/xen.if   | 4 ++--
  xen/xsm/flask/hooks.c               | 9 +++++++++
  xen/xsm/flask/policy/access_vectors | 6 ++++++
  4 files changed, 18 insertions(+), 3 deletions(-)