summaryrefslogtreecommitdiff
path: root/include/xen
diff options
context:
space:
mode:
authorJuergen Gross <jgross@suse.com>2022-02-25 16:05:41 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-03-11 11:22:38 +0100
commit44d86dccd2a5f02a66c6784378d1429412d84bf0 (patch)
treeea1b969bd982bb8ded526e4f0eff9bb676cc3784 /include/xen
parent95ff82383266a7720d596eb8b4499ed01746a730 (diff)
xen/grant-table: add gnttab_try_end_foreign_access()
Commit 6b1775f26a2da2b05a6dc8ec2b5d14e9a4701a1a upstream. Add a new grant table function gnttab_try_end_foreign_access(), which will remove and free a grant if it is not in use. Its main use case is to either free a grant if it is no longer in use, or to take some other action if it is still in use. This other action can be an error exit, or (e.g. in the case of blkfront persistent grant feature) some special handling. This is CVE-2022-23036, CVE-2022-23038 / part of XSA-396. Reported-by: Demi Marie Obenour <demi@invisiblethingslab.com> Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/xen')
-rw-r--r--include/xen/grant_table.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index a9978350b45b..7628ab25f686 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -97,10 +97,22 @@ int gnttab_end_foreign_access_ref(grant_ref_t ref, int readonly);
* access has been ended, free the given page too. Access will be ended
* immediately iff the grant entry is not in use, otherwise it will happen
* some time later. page may be 0, in which case no freeing will occur.
+ * Note that the granted page might still be accessed (read or write) by the
+ * other side after gnttab_end_foreign_access() returns, so even if page was
+ * specified as 0 it is not allowed to just reuse the page for other
+ * purposes immediately.
*/
void gnttab_end_foreign_access(grant_ref_t ref, int readonly,
unsigned long page);
+/*
+ * End access through the given grant reference, iff the grant entry is
+ * no longer in use. In case of success ending foreign access, the
+ * grant reference is deallocated.
+ * Return 1 if the grant entry was freed, 0 if it is still in use.
+ */
+int gnttab_try_end_foreign_access(grant_ref_t ref);
+
int gnttab_grant_foreign_transfer(domid_t domid, unsigned long pfn);
unsigned long gnttab_end_foreign_transfer_ref(grant_ref_t ref);