tools/libxenforeignmemory: add a call to restrict the handle
PATCH 1/1 tools/libxenforeignmemory: add a call to restrict the handle
Commit 8ef5f344d061 "tools/libxendevicemodel: add a call to restrict the handle" added a function to the devicemodel interface to restrict operations through the API to a specific domain, where a capable under- lying privcmd driver exists.
This patch adds similar functionality to the xenforeignmemory API. This will be necessary (as much as xendevicemodel restriction) for limiting the scope of device models to specific domains.
NOTE: My patch to the linux kernel [1] added the appropriate checks to
the foreign memory ioctls.
[1] https://git.kernel.org/cgit/linux/kernel/git/ostr/linux.git/commit/?id=4610d240
---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
--- tools/libs/foreignmemory/core.c | 6 ++++++ tools/libs/foreignmemory/freebsd.c | 7 +++++++ tools/libs/foreignmemory/include/xenforeignmemory.h | 11 +++++++++++ tools/libs/foreignmemory/libxenforeignmemory.map | 1 + tools/libs/foreignmemory/linux.c | 6 ++++++ tools/libs/foreignmemory/minios.c | 7 +++++++ tools/libs/foreignmemory/netbsd.c | 7 +++++++ tools/libs/foreignmemory/private.h | 3 +++ tools/libs/foreignmemory/solaris.c | 7 +++++++ 9 files changed, 55 insertions(+)
tools/libs/foreignmemory/core.c +6 -0
@@ -106,6 +106,12 @@ int xenforeignmemory_unmap(xenforeignmemory_handle *fmem,return osdep_xenforeignmemory_unmap (fmem, addr, num); } +int xenforeignmemory_restrict (xenforeignmemory_handle *fmem, +domid_t domid) +{ +return osdep_xenforeignmemory_restrict (fmem, domid); +} +/* * Local variables: * mode: C
tools/libs/foreignmemory/freebsd.c +7 -0
@@ -96,6 +96,13 @@ int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,return munmap (addr, num <<PAGE_SHIFT ); } +int osdep_xenforeignmemory_restrict (xenforeignmemory_handle *fmem, +domid_t domid) +{ + errno = -EOPNOTSUPP ; +return -1 ; +} +/* * Local variables: * mode: C
tools/libs/foreignmemory/include/xenforeignmemory.h +11 -0
@@ -115,6 +115,17 @@ void *xenforeignmemory_map(xenforeignmemory_handle *fmem, uint32_t dom,int xenforeignmemory_unmap (xenforeignmemory_handle *fmem,void *addr,size_t pages); +/** +* This function restricts the use of this handle to the specified +* domain. +* +* @parm fmem handle to the open foreignmemory interface +* @parm domid the domain id +* @return 0 on success, -1 on failure. +*/ +int xenforeignmemory_restrict (xenforeignmemory_handle *fmem, +domid_t domid); +#endif /*
tools/libs/foreignmemory/libxenforeignmemory.map +1 -0
@@ -4,5 +4,6 @@ VERS_1.0 { xenforeignmemory_close; xenforeignmemory_map; xenforeignmemory_unmap; + xenforeignmemory_restrict; local: *; /* Do not expose anything by default */ };
tools/libs/foreignmemory/linux.c +6 -0
@@ -272,6 +272,12 @@ int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,return munmap (addr, num <<PAGE_SHIFT ); } +int osdep_xenforeignmemory_restrict (xenforeignmemory_handle *fmem, +domid_t domid) +{ +return ioctl (fmem->fd,IOCTL_PRIVCMD_RESTRICT , &domid); +} +/* * Local variables: * mode: C
tools/libs/foreignmemory/minios.c +7 -0
@@ -58,6 +58,13 @@ int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,return munmap (addr, num <<PAGE_SHIFT ); } +int osdep_xenforeignmemory_restrict (xenforeignmemory_handle *fmem, +domid_t domid) +{ + errno = -EOPNOTSUPP ; +return -1 ; +} +/* * Local variables: * mode: C
tools/libs/foreignmemory/netbsd.c +7 -0
@@ -100,6 +100,13 @@ int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,return munmap (addr, num*XC_PAGE_SIZE ); } +int osdep_xenforeignmemory_restrict (xenforeignmemory_handle *fmem, +domid_t domid) +{ + errno = -EOPNOTSUPP ; +return -1 ; +} +/* * Local variables: * mode: C
tools/libs/foreignmemory/private.h +3 -0
@@ -32,6 +32,9 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,int osdep_xenforeignmemory_unmap (xenforeignmemory_handle *fmem,void *addr,size_t num); +int osdep_xenforeignmemory_restrict (xenforeignmemory_handle *fmem, +domid_t domid); +#if defined(__NetBSD__) || defined(__sun__)/* Strictly compat for those two only only */ void *compat_mapforeign_batch(xenforeignmem_handle *fmem, uint32_t dom,
tools/libs/foreignmemory/solaris.c +7 -0
@@ -98,6 +98,13 @@ int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,return munmap (addr, num*XC_PAGE_SIZE ); } +int osdep_xenforeignmemory_restrict (xenforeignmemory_handle *fmem, +domid_t domid) +{ + errno = -EOPNOTSUPP ; +return -1 ; +} +/* * Local variables: * mode: C
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 9 lines · Paul Durrant
Commit
8ef5f344d061"tools/libxendevicemodel: add a call to restrict the handle" added a function to the devicemodel interface to restrict operations through the API to a specific domain, where a capable under- lying privcmd driver exists.This patch adds similar functionality to the xenforeignmemory API. This will be necessary (as much as xendevicemodel restriction) for limiting the scope of device models to specific domains.
Quoted 6 lines
NOTE: My patch to the linux kernel [1] added the appropriate checks to
the foreign memory ioctls.[1] https://git.kernel.org/cgit/linux/kernel/git/ostr/linux.git/commit/?id=4610d240
Signed-off-by Paul Durrant <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
tools/libs/foreignmemory/libxenforeignmemory.map VERS_1.0 { · line 9
Quoted 11 lines · Paul Durrant
tools/libs/foreignmemory/libxenforeignmemory.map +1
-0@@ -4,5 +4,6 @@ VERS_1.0 { xenforeignmemory_close; xenforeignmemory_map; xenforeignmemory_unmap; + xenforeignmemory_restrict; local: *; /* Do not expose anything by default */ };
This isn't correct.
New functions like this need to bump at least the SO minor version, like c/s f1446de4ba
Fixing this is a blocker to releasing 4.9
Also, we should really get automatic ABI checking built into the release process, to prevent mistakes like this from happening accidentally.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 25 lines
-----Original Message-----
From: Andrew Cooper
Sent: 24 March 2017 20:10
To: Paul Durrant <[email protected]>; [email protected]
Cc: Wei Liu <[email protected]>; Ian Jackson <[email protected]>; Julien Grall <[email protected]>
Subject: Re: [Xen-devel] [PATCH]tools/libxenforeignmemory: add a call to restrict the handleReview
Quoted 1 line · Paul Durrant
(quoted diff) +0
-0b/tools/libs/foreignmemory/libxenforeignmemory.map
tools/libs/foreignmemory/libxenforeignmemory.map VERS_1.0 { · line 9
Quoted 10 lines
index df206b3..5c9806c 100644
tools/libs/foreignmemory/libxenforeignmemory.map +1
-0@@ -4,5 +4,6 @@ VERS_1.0 { xenforeignmemory_close; xenforeignmemory_map; xenforeignmemory_unmap; + xenforeignmemory_restrict; local: *; /* Do not expose anything by default */ };This isn't correct.
Quoted 3 lines
New functions like this need to bump at least the SO minor version, like c/s
f1446de4ba
Sorry, yes, I forgot these libraries are supposed to be stable now.
Quoted 2 lines
Fixing this is a blocker to releasing 4.9
I'll submit a patch on Monday.
Quoted 3 lines
Also, we should really get automatic ABI checking built into the release process, to prevent mistakes like this from happening accidentally.
Yes, definitely.
Paul
Quoted 1 line
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 41 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 24 March 2017 20:24
To: Andrew Cooper <[email protected]>; xen- [email protected]
Cc: Ian Jackson <[email protected]>; Julien Grall <[email protected]>; Wei Liu <[email protected]>
Subject: Re: [Xen-devel] [PATCH]tools/libxenforeignmemory: add a call to restrict the handleQuoted 4 lines
-----Original Message-----
From: Andrew Cooper
Sent: 24 March 2017 20:10
To: Paul Durrant <[email protected]>; xen-Quoted 21 lines
Cc: Wei Liu <[email protected]>; Ian Jackson <[email protected]>; Julien Grall <[email protected]>
Subject: Re: [Xen-devel] [PATCH]tools/libxenforeignmemory: add a call to restrict the handleReview
Quoted 1 line · Paul Durrant
(quoted diff) +0
-0b/tools/libs/foreignmemory/libxenforeignmemory.map
tools/libs/foreignmemory/libxenforeignmemory.map VERS_1.0 { · line 9
Quoted 10 lines
index df206b3..5c9806c 100644
tools/libs/foreignmemory/libxenforeignmemory.map +1
-0@@ -4,5 +4,6 @@ VERS_1.0 { xenforeignmemory_close; xenforeignmemory_map; xenforeignmemory_unmap; + xenforeignmemory_restrict; local: *; /* Do not expose anything by default */ };This isn't correct.
Quoted 3 lines
New functions like this need to bump at least the SO minor version, like c/s
f1446de4ba
Quoted 6 lines
Sorry, yes, I forgot these libraries are supposed to be stable now.
Quoted 2 lines
Fixing this is a blocker to releasing 4.9
I'll submit a patch on Monday.
Actually, on second thoughts, do we want to bump the version for all changes or just incompatible ones? I added a call here so it shouldn't break any older application compiling against this library.
Paul
Quoted 7 lines
Quoted 4 lines
Also, we should really get automatic ABI checking built into the release process, to prevent mistakes like this from happening accidentally.
Yes, definitely.
Quoted 7 lines
Paul
Quoted 1 line
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 39 lines · Paul Durrant
Quoted 39 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 24 March 2017 20:24
To: Andrew Cooper <[email protected]>; xen- [email protected]
Cc: Ian Jackson <[email protected]>; Julien Grall <[email protected]>; Wei Liu <[email protected]>
Subject: Re: [Xen-devel] [PATCH]tools/libxenforeignmemory: add a call to restrict the handleQuoted 4 lines
-----Original Message-----
From: Andrew Cooper
Sent: 24 March 2017 20:10
To: Paul Durrant <[email protected]>; xen-Quoted 23 lines
Cc: Wei Liu <[email protected]>; Ian Jackson <[email protected]>; Julien Grall <[email protected]>
Subject: Re: [Xen-devel] [PATCH]tools/libxenforeignmemory: add a call to restrict the handleReview
Quoted 1 line · Paul Durrant
(quoted diff) +0
-0b/tools/libs/foreignmemory/libxenforeignmemory.map
tools/libs/foreignmemory/libxenforeignmemory.map VERS_1.0 { · line 9
Quoted 10 lines
index df206b3..5c9806c 100644
tools/libs/foreignmemory/libxenforeignmemory.map +1
-0@@ -4,5 +4,6 @@ VERS_1.0 { xenforeignmemory_close; xenforeignmemory_map; xenforeignmemory_unmap; + xenforeignmemory_restrict; local: *; /* Do not expose anything by default */ };This isn't correct.
New functions like this need to bump at least the SO minor version, like c/s
f1446de4ba
Quoted 6 lines
Quoted 5 lines
Sorry, yes, I forgot these libraries are supposed to be stable now.
Quoted 2 lines
Fixing this is a blocker to releasing 4.9
I'll submit a patch on Monday.
Actually, on second thoughts, do we want to bump the version for all changes or just incompatible ones? I added a call here so it shouldn't break any older application compiling against this library.
You must bump the versions; the version information gets embedded as part of the dynamic linkage of the application built against libxenforeignmemory.
In particular, you need to prevent an application built now from referencing [email protected] because the version 1.0 shipped in all earlier versions of Xen lacked this function.
Not bumping the version now will result in newer applications being built which the dynamic loader thinks will work with older versions of the library, rather than correctly identifying that a newer version of the library is required.
As with other things in staging, it can get away with only being bumped once per Xen release, but it must always be bumped at the first change.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 70 lines
-----Original Message-----
From: Andrew Cooper [mailto:[email protected]] On Behalf Of Andrew Cooper
Sent: 27 March 2017 09:16
To: Paul Durrant <[email protected]>; [email protected]
Cc: Ian Jackson <[email protected]>; Julien Grall <[email protected]>; Wei Liu <[email protected]>
Subject: Re: [Xen-devel] [PATCH]tools/libxenforeignmemory: add a call to restrict the handleQuoted 9 lines · Paul Durrant
Quoted 9 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 24 March 2017 20:24
To: Andrew Cooper <[email protected]>; xen- [email protected]
Cc: Ian Jackson <[email protected]>; Julien Grall <[email protected]>; Wei Liu <[email protected]>
Subject: Re: [Xen-devel] [PATCH]tools/libxenforeignmemory: add a callto
Quoted 8 lines
Quoted 8 lines
restrict the handle
Quoted 4 lines
-----Original Message-----
From: Andrew Cooper
Sent: 24 March 2017 20:10
To: Paul Durrant <[email protected]>; xen-Quoted 1 line
Cc Wei Liu <[email protected]>; Ian JacksonQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Julien Grall <[email protected]>
Subject: Re: [Xen-devel] [PATCH]tools/libxenforeignmemory: add a callto
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
restrict the handle
Review
Quoted 1 line · Paul Durrant
(quoted diff) +0
-0b/tools/libs/foreignmemory/libxenforeignmemory.map
tools/libs/foreignmemory/libxenforeignmemory.map VERS_1.0 { · line 9
Quoted 10 lines
index df206b3..5c9806c 100644
tools/libs/foreignmemory/libxenforeignmemory.map +1
-0@@ -4,5 +4,6 @@ VERS_1.0 { xenforeignmemory_close; xenforeignmemory_map; xenforeignmemory_unmap; + xenforeignmemory_restrict; local: *; /* Do not expose anything by default */ };This isn't correct.
New functions like this need to bump at least the SO minor version, like c/s
f1446de4baQuoted 6 lines
Quoted 5 lines
Sorry, yes, I forgot these libraries are supposed to be stable now.
Quoted 2 lines
Fixing this is a blocker to releasing 4.9
I'll submit a patch on Monday.
Actually, on second thoughts, do we want to bump the version for all
changes or just incompatible ones? I added a call here so it shouldn't break any older application compiling against this library.
You must bump the versions; the version information gets embedded as part of the dynamic linkage of the application built against libxenforeignmemory.
In particular, you need to prevent an application built now from referencing [email protected] because the version 1.0 shipped in all earlier versions of Xen lacked this function.
Quoted 8 lines
Not bumping the version now will result in newer applications being built which the dynamic loader thinks will work with older versions of the library, rather than correctly identifying that a newer version of the library is required.
As with other things in staging, it can get away with only being bumped once per Xen release, but it must always be bumped at the first change.
Ok. I'll send a patch today then.
Paul
Quoted 1 line
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Hi Andre,
Quoted 15 lines · Andrew Cooper
tools/libs/foreignmemory/libxenforeignmemory.map VERS_1.0 { · line 9
Quoted 11 lines · Paul Durrant
tools/libs/foreignmemory/libxenforeignmemory.map +1
-0@@ -4,5 +4,6 @@ VERS_1.0 { xenforeignmemory_close; xenforeignmemory_map; xenforeignmemory_unmap; + xenforeignmemory_restrict; local: *; /* Do not expose anything by default */ };This isn't correct.
Quoted 4 lines
New functions like this need to bump at least the SO minor version, like c/s
f1446de4baFixing this is a blocker to releasing 4.9
I saw a patch (commit 9a7fbdd692) merged today to fix this. Let me know if there are more patches coming to address this.
Quoted 3 lines
Also, we should really get automatic ABI checking built into the release process, to prevent mistakes like this from happening accidentally.
That's a good idea. I will create a task on Jira for that.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 19 lines · Julien Grall
Hi Andre,
Quoted 16 lines · Andrew Cooper
tools/libs/foreignmemory/libxenforeignmemory.map VERS_1.0 { · line 9
Quoted 12 lines · Paul Durrant
tools/libs/foreignmemory/libxenforeignmemory.map +1
-0@@ -4,5 +4,6 @@ VERS_1.0 { xenforeignmemory_close; xenforeignmemory_map; xenforeignmemory_unmap; + xenforeignmemory_restrict; local: *; /* Do not expose anything by default */ };This isn't correct.
Quoted 7 lines
Quoted 4 lines
New functions like this need to bump at least the SO minor version, like c/s
f1446de4baFixing this is a blocker to releasing 4.9
I saw a patch (commit
9a7fbdd692) merged today to fix this. Let me know if there are more patches coming to address this.
That should be all to fix this specific issue.
Quoted 6 lines
Quoted 4 lines
Also, we should really get automatic ABI checking built into the release process, to prevent mistakes like this from happening accidentally.
That's a good idea. I will create a task on Jira for that.
https://xenproject.atlassian.net/projects/XEN/issues/XEN-33 is way ahead of you :)
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel