tools/libxencalls: add new function to query hypercall buffer safety

Add a new function to query whether hypercall buffers are always safe
to access by the hypervisor or might result in EFAULT.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
Juergen Gross authored and Ian Jackson committed 2018-06-18 12:31:48 +01:00
1 parent 33be2c3858
commit 171d6ecec1
8 files changed
+38 -1

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@ XEN_ROOT = $(CURDIR)/../../..
include $(XEN_ROOT)/tools/Rules.mk
MAJOR = 1
MINOR = 0
MINOR = 1
SHLIB_LDFLAGS += -Wl,--version-script=libxencall.map
CFLAGS += -Werror -Wmissing-prototypes
+5
View File
@@ -107,6 +107,11 @@ void osdep_free_pages(xencall_handle *xcall, void *ptr, size_t npages)
errno = saved_errno;
}
int xencall_buffers_never_fault(xencall_handle *xcall)
{
return 1;
}
/*
* Local variables:
* mode: C
+7
View File
@@ -115,6 +115,13 @@ void xencall_free_buffer_pages(xencall_handle *xcall, void *p, size_t nr_pages);
void *xencall_alloc_buffer(xencall_handle *xcall, size_t size);
void xencall_free_buffer(xencall_handle *xcall, void *p);
/*
* Are allocated hypercall buffers safe to be accessed by the hypervisor all
* the time?
* Returns 0 if EFAULT might be possible.
*/
int xencall_buffers_never_fault(xencall_handle *xcall);
#endif
/*
+5
View File
@@ -17,3 +17,8 @@ VERS_1.0 {
xencall_free_buffer_pages;
local: *; /* Do not expose anything by default */
};
VERS_1.1 {
global:
xencall_buffers_never_fault;
} VERS_1.0;
+5
View File
@@ -171,6 +171,11 @@ void osdep_free_pages(xencall_handle *xcall, void *ptr, size_t npages)
errno = saved_errno;
}
int xencall_buffers_never_fault(xencall_handle *xcall)
{
return xcall->buf_fd >= 0;
}
/*
* Local variables:
* mode: C
+5
View File
@@ -70,6 +70,11 @@ void osdep_free_pages(xencall_handle *xcall, void *ptr, size_t npages)
free(ptr);
}
int xencall_buffers_never_fault(xencall_handle *xcall)
{
return 1;
}
/*
* Local variables:
* mode: C
+5
View File
@@ -110,6 +110,11 @@ int do_xen_hypercall(xencall_handle *xcall, privcmd_hypercall_t *hypercall)
return hypercall->retval;
}
int xencall_buffers_never_fault(xencall_handle *xcall)
{
return 1;
}
/*
* Local variables:
* mode: C
+5
View File
@@ -86,6 +86,11 @@ int do_xen_hypercall(xencall_handle *xcall, privcmd_hypercall_t *hypercall)
return ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
}
int xencall_buffers_never_fault(xencall_handle *xcall)
{
return 1;
}
/*
* Local variables:
* mode: C
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.