Mailing List Archive

[xen master] x86/paging: return -EINVAL for paging domctls for dying domains
commit 4e0b4ccfc504f26187939068796295340ffd0e2f
Author: Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Nov 8 12:38:50 2022 +0100
Commit: Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 9 12:04:11 2023 +0000

x86/paging: return -EINVAL for paging domctls for dying domains

The current logic returns 0 and leaves the domctl parameter uninitialized for
any parameter fetching operations (like the GET_ALLOCATION operation), which
is not helpful from a toolstack point of view, because there's no indication
that the data hasn't been fetched.

For at least the Ocaml stubs, this ends up passing back stack rubble as if it
were a correct result.

Inform the caller properly that it hasn't got any data.

Reported-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
xen/arch/x86/mm/paging.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c
index 1c5f54f92a..2991585117 100644
--- a/xen/arch/x86/mm/paging.c
+++ b/xen/arch/x86/mm/paging.c
@@ -695,9 +695,8 @@ int paging_domctl(struct domain *d, struct xen_domctl_shadow_op *sc,

if ( unlikely(d->is_dying) )
{
- gdprintk(XENLOG_INFO, "Ignoring paging op on dying domain %u\n",
- d->domain_id);
- return 0;
+ gdprintk(XENLOG_INFO, "Tried to do a paging op on dying %pd\n", d);
+ return -EINVAL;
}

if ( unlikely(d->vcpu == NULL) || unlikely(d->vcpu[0] == NULL) )
--
generated by git-patchbot for /home/xen/git/xen.git#master