Even more XSA-409 fixes
cover Even more XSA-409 fixes
Once more, with feeling...
Patch 1 has been posted previously, but has accumulated another bugfix.
Patch 2 has been discussed on list, but this is the first posting. I've confirmed that it fixes the issue reported by OSSTest.
Andrew Cooper (2):
tools/libxl: Fixes to libxl__domain_set_paging_mempool_size() xen/flask: Wire up XEN_DOMCTL_{get,set}_paging_mempool_size
tools/flask/policy/modules/dom0.te | 3 ++- tools/flask/policy/modules/xen.if | 2 +- tools/libs/light/libxl_dom.c | 10 +++++++++- xen/xsm/flask/hooks.c | 6 ++++++ xen/xsm/flask/policy/access_vectors | 4 ++++ 5 files changed, 22 insertions(+), 3 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/2 tools/libxl: Fixes to libxl__domain_set_paging_mempool_size()
The error message accidentally printed the bytes value as if it were kB.
Furthermore, both b_info.shadow_memkb and shadow_mem are uint64_t, meaning there is a risk of overflow if the user specified a stupidly large value in the vm.cfg file. Check and reject such a condition.
---
CC: Anthony PERARD <[email protected]>
CC: Henry Wang <[email protected]>
v2:
* Retain PRIu64
* Check for overflow
For 4.17. This is a low risk change, removes one overflow case, and makes an error message accurate.
--- tools/libs/light/libxl_dom.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
tools/libs/light/libxl_dom.c +9 -1
@@ -1458,10 +1458,18 @@ int libxl__domain_set_paging_mempool_size( shadow_mem = d_config->b_info.shadow_memkb; shadow_mem <<=10 ; +if ((shadow_mem >>10 ) != d_config->b_info.shadow_memkb) { +LOGED (ERROR , domid, +"shadow_memkb value %" PRIu64"kB too large" , + d_config->b_info.shadow_memkb); +return ERROR_FAIL ; + } +int r =xc_set_paging_mempool_size (CTX ->xch, domid, shadow_mem);if (r) {LOGED (ERROR , domid, -"Failed to set paging mempool size to %" PRIu64"kB" , shadow_mem); +"Failed to set paging mempool size to %" PRIu64"kB" , + d_config->b_info.shadow_memkb);return ERROR_FAIL ; }
Signature · 1 line
2.11.0
Re: [PATCH 1/2] tools/libxl: Fixes to libxl__domain_set_paging_mempool_size()
Quoted 8 lines · Andrew Cooper
The error message accidentally printed the bytes value as if it were kB.
Furthermore, both b_info.shadow_memkb and
shadow_memareuint64_t, meaning there is a risk of overflow if the user specified a stupidly large value in the vm.cfg file. Check and reject such a condition.Fixes 7c3bbd940dd8 ("xen/arm, libxl: Revert XEN_DOMCTL_shadow_op; use p2m mempool hypercalls")Signed-off-by Andrew Cooper <[email protected]>
Quoted 8 lines
---
v2:
* Retain PRIu64
* Check for overflowFor 4.17. This is a low risk change, removes one overflow case, and makes an error message accurate.
Thanks,
Signature · 1 line
Anthony PERARD
RE: [PATCH 1/2] tools/libxl: Fixes to libxl__domain_set_paging_mempool_size()
Hi Andrew,
Quoted 21 lines
-----Original Message-----
Subject: Re: [PATCH 1/2]tools/libxl: Fixes tolibxl__domain_set_paging_mempool_size()Quoted 3 lines · Andrew Cooper
The error message accidentally printed the bytes value as if it were kB.
Furthermore, both b_info.shadow_memkb and
shadow_memareuint64_t,meaning
Quoted 4 lines
there is a risk of overflow if the user specified a stupidly large value in the vm.cfg file. Check and reject such a condition.
Fixes 7c3bbd940dd8 ("xen/arm, libxl: Revert XEN_DOMCTL_shadow_op;use p2m mempool hypercalls")
Quoted 7 lines
Signed-off-by Andrew Cooper <[email protected]>---
v2:
* Retain PRIu64
* Check for overflow
Quoted 5 lines
Quoted 1 line
For 4.17. This is a low risk change, removes one overflow case, and makes
an
Quoted 1 line
error message accurate.
Reviewed-by Anthony PERARD <[email protected]>
Kind regards,
Henry
PATCH 2/2 xen/flask: Wire up XEN_DOMCTL_{get,set}_paging_mempool_size
In reply to Andrew CooperThese were overlooked in the original patch, and noticed by OSSTest which does run some Flask tests.
---
CC: Daniel De Graaf <[email protected]>
CC: Daniel Smith <[email protected]>
CC: Jason Andryuk <[email protected]>
CC: Henry Wang <[email protected]>
It should be noted that the original XSA-409 fix broke Flask on ARM but no testing noticed. c/s 7c3bbd940dd8 ("xen/arm, libxl: Revert XEN_DOMCTL_shadow_op; use p2m mempool hypercalls") "fixes" the original breakage and introduced this breakage instead.
For 4.17. It's a fix for an issue that OSSTest is currently blocking as a regression.
--- tools/flask/policy/modules/dom0.te | 3 ++- tools/flask/policy/modules/xen.if | 2 +- xen/xsm/flask/hooks.c | 6 ++++++ xen/xsm/flask/policy/access_vectors | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-)
tools/flask/policy/modules/dom0.te +2 -1
@@ -35,7 +35,8 @@ allow dom0_t dom0_t:domain { setvcpucontext max_vcpus setaffinity getaffinity getscheduler getdomaininfo getvcpuinfo getvcpucontext setdomainmaxmem setdomainhandle setdebugging hypercall settime setaddrsize getaddrsize trigger - getpodtarget setpodtarget set_misc_info set_virq_handler + getpodtarget setpodtarget getpagingmempool setpagingmempool set_misc_info + set_virq_handler }; allow dom0_t dom0_t:domain2 { set_cpu_policy gettsc settsc setscheduler set_vnumainfo
tools/flask/policy/modules/xen.if +1 -1
@@ -92,7 +92,7 @@ define(`manage_domain', ` allow $1 $2:domain { getdomaininfo getvcpuinfo getaffinity getaddrsize pause unpause trigger shutdown destroy setaffinity setdomainmaxmem getscheduler resume - setpodtarget getpodtarget }; + setpodtarget getpodtarget getpagingmempool setpagingmempool }; allow $1 $2:domain2 set_vnumainfo; ')
xen/xsm/flask/hooks.c +6 -0
@@ -822,6 +822,12 @@ static int cf_check flask_domctl(struct domain *d, int cmd)case XEN_DOMCTL_get_cpu_policy:return current_has_perm (d,SECCLASS_DOMAIN2 ,DOMAIN2__GET_CPU_POLICY ); +case XEN_DOMCTL_get_paging_mempool_size: +return current_has_perm (d,SECCLASS_DOMAIN ,DOMAIN__GETPAGINGMEMPOOL ); + +case XEN_DOMCTL_set_paging_mempool_size: +return current_has_perm (d,SECCLASS_DOMAIN ,DOMAIN__SETPAGINGMEMPOOL ); +default :return avc_unknown_permission ("domctl" , cmd); }
xen/xsm/flask/policy/access_vectors +4 -0
@@ -180,6 +180,10 @@ class domain set_misc_info # XEN_DOMCTL_set_virq_handler set_virq_handler +# XEN_DOMCTL_get_paging_mempool_size + getpagingmempool +# XEN_DOMCTL_set_paging_mempool_size + setpagingmempool } # This is a continuation of class domain, since only 32 permissions can be
Signature · 1 line
2.11.0
RE: [PATCH 2/2] xen/flask: Wire up XEN_DOMCTL_{get,set}_paging_mempool_size
Hi Andrew,
Quoted 11 lines
-----Original Message-----
From: Andrew Cooper <[email protected]>
Sent: Monday, November 21, 2022 10:38 PM
To: Xen-devel <[email protected]>
Cc: Andrew Cooper <[email protected]>; Daniel De Graaf <[email protected]>; Daniel Smith <[email protected]>; Jason Andryuk <[email protected]>; Henry Wang <[email protected]>
Subject: [PATCH 2/2] xen/flask: Wire up XEN_DOMCTL_{get,set}_paging_mempool_size
Quoted 8 lines
These were overlooked in the original patch, and noticed by OSSTest which does
run some Flask tests.Fixes 22b20bd98c02 ("xen: Introduce non-broken hypercalls for the pagingmempool size")
Suggested-by Daniel Smith <[email protected]>Signed-off-by Andrew Cooper <[email protected]>
Kind regards,
Henry
Re: [PATCH 2/2] xen/flask: Wire up XEN_DOMCTL_{get,set}_paging_mempool_size
In reply to Andrew CooperQuoted 4 lines · Andrew Cooper
These were overlooked in the original patch, and noticed by OSSTest which does run some Flask tests.
Quoted 8 lines
Fixes 22b20bd98c02 ("xen: Introduce non-broken hypercalls for the paging mempool size")Suggested-by Daniel Smith <[email protected]>Signed-off-by Andrew Cooper <[email protected]>---
CC: Daniel De Graaf <[email protected]>
CC: Daniel Smith <[email protected]>
CC: Jason Andryuk <[email protected]>
CC: Henry Wang <[email protected]>
Thanks, Andrew. Though we might want a small tweak - possibly as a follow up?
tools/flask/policy/modules/xen.if define(`manage_domain', ` · line 95
Quoted 10 lines
tools/flask/policy/modules/xen.if +1
-1@@ -92,7 +92,7 @@ define(`manage_domain', ` allow $1 $2:domain { getdomaininfo getvcpuinfo getaffinity getaddrsize pause unpause trigger shutdown destroy setaffinity setdomainmaxmem getscheduler resume - setpodtarget getpodtarget }; + setpodtarget getpodtarget getpagingmempool setpagingmempool };
There is also create_domain_common which is for a dedicated "domain builder" that creates but does not manage domains. I think that should gain setpagingmempool permission?
Regards,
Jason
Re: [PATCH 2/2] xen/flask: Wire up XEN_DOMCTL_{get,set}_paging_mempool_size
Quoted 16 lines · Jason Andryuk
Quoted 11 lines · Andrew Cooper
These were overlooked in the original patch, and noticed by OSSTest which does run some Flask tests.
Fixes 22b20bd98c02 ("xen: Introduce non-broken hypercalls for the paging mempool size")Suggested-by Daniel Smith <[email protected]>Signed-off-by Andrew Cooper <[email protected]>---
CC: Daniel De Graaf <[email protected]>
CC: Daniel Smith <[email protected]>
CC: Jason Andryuk <[email protected]>
CC: Henry Wang <[email protected]>Reviewed-by Jason Andryuk <[email protected]>Thanks, Andrew. Though we might want a small tweak - possibly as a follow up?
Quoted 13 lines
tools/flask/policy/modules/xen.if define(`manage_domain', ` · line 95
Quoted 10 lines
tools/flask/policy/modules/xen.if +1
-1@@ -92,7 +92,7 @@ define(`manage_domain', ` allow $1 $2:domain { getdomaininfo getvcpuinfo getaffinity getaddrsize pause unpause trigger shutdown destroy setaffinity setdomainmaxmem getscheduler resume - setpodtarget getpodtarget }; + setpodtarget getpodtarget getpagingmempool setpagingmempool };There is also
create_domain_commonwhich is for a dedicated "domain builder" that creates but does not manage domains. I think that should gain setpagingmempool permission?
Sounds like it should. Something like this?
(quoted diff) +0 -0
b/tools/flask/policy/modules/xen.if
index 6b7b7d403ab4..11c1562aa5da 100644
tools/flask/policy/modules/xen.if +0 -0
@@ -49,7 +49,8 @@ define(`create_domain_common', `
allow $1 $2:domain { create max_vcpus setdomainmaxmem setaddrsize getdomaininfo hypercall setvcpucontext getscheduler getvcpuinfo getaddrsize getaffinity setaffinity - settime setdomainhandle getvcpucontext set_misc_info };
+ settime setdomainhandle getvcpucontext set_misc_info + getpagingmempool setpagingmempool }; allow $1 $2:domain2 { set_cpu_policy settsc setscheduler setclaim set_vnumainfo get_vnumainfo cacheflush psr_cmt_op psr_alloc soft_reset
I can fold this in on commit.
~Andrew
Re: [PATCH 2/2] xen/flask: Wire up XEN_DOMCTL_{get,set}_paging_mempool_size
Quoted 51 lines · Andrew Cooper
Quoted 16 lines · Jason Andryuk
Quoted 11 lines · Andrew Cooper
These were overlooked in the original patch, and noticed by OSSTest which does run some Flask tests.
Fixes 22b20bd98c02 ("xen: Introduce non-broken hypercalls for the paging mempool size")Suggested-by Daniel Smith <[email protected]>Signed-off-by Andrew Cooper <[email protected]>---
CC: Daniel De Graaf <[email protected]>
CC: Daniel Smith <[email protected]>
CC: Jason Andryuk <[email protected]>
CC: Henry Wang <[email protected]>Reviewed-by Jason Andryuk <[email protected]>Thanks, Andrew. Though we might want a small tweak - possibly as a follow up?
Quoted 13 lines
tools/flask/policy/modules/xen.if define(`manage_domain', ` · line 95
Quoted 10 lines
tools/flask/policy/modules/xen.if +1
-1@@ -92,7 +92,7 @@ define(`manage_domain', ` allow $1 $2:domain { getdomaininfo getvcpuinfo getaffinity getaddrsize pause unpause trigger shutdown destroy setaffinity setdomainmaxmem getscheduler resume - setpodtarget getpodtarget }; + setpodtarget getpodtarget getpagingmempool setpagingmempool };There is also
create_domain_commonwhich is for a dedicated "domain builder" that creates but does not manage domains. I think that should gain setpagingmempool permission?Sounds like it should. Something like this?
tools/flask/policy/modules/xen.if +2
-1@@ -49,7 +49,8 @@ define(`create_domain_common', ` allow $1 $2:domain { create max_vcpus setdomainmaxmem setaddrsize getdomaininfo hypercall setvcpucontext getscheduler getvcpuinfo getaddrsize getaffinity setaffinity - settime setdomainhandle getvcpucontext set_misc_info }; + settime setdomainhandle getvcpucontext set_misc_info + getpagingmempool setpagingmempool }; allow $1 $2:domain2 { set_cpu_policy settsc setscheduler setclaim set_vnumainfo get_vnumainfo cacheflush
psr_cmt_oppsr_allocsoft_reset
Quoted 1 line
I can fold this in on commit.
Yes, though strictly speaking it may only need setpagingmempool and not getpagingmempool. These are all calls that would execute before the domain is run. But adding both is probably fine since the builder is setting these itself. i.e. allowing it to read what it set is fine.
So, yes, I'd just fold this in.
Thanks,
Jason
Re: [PATCH 2/2] xen/flask: Wire up XEN_DOMCTL_{get,set}_paging_mempool_size
In reply to Andrew CooperQuoted 12 lines · Andrew Cooper
These were overlooked in the original patch, and noticed by OSSTest which does run some Flask tests.
Fixes 22b20bd98c02 ("xen: Introduce non-broken hypercalls for the paging mempool size")Suggested-by Daniel Smith <[email protected]>Signed-off-by Andrew Cooper <[email protected]>---
CC: Daniel De Graaf <[email protected]>
CC: Daniel Smith <[email protected]>
CC: Jason Andryuk <[email protected]>
CC: Henry Wang <[email protected]>
Quoted 7 lines
It should be noted that the original XSA-409 fix broke Flask on ARM but no testing noticed. c/s
7c3bbd940dd8("xen/arm, libxl: RevertXEN_DOMCTL_shadow_op; use p2m mempool hypercalls") "fixes" the original breakage and introduced this breakage instead.For 4.17. It's a fix for an issue that OSSTest is currently blocking as a regression.