* [PATCH] vNUMA: validate XEN_DOMCTL_setvnumainfo input
@ 2015-03-03 14:38 Jan Beulich
2015-03-03 14:46 ` Wei Liu
2015-03-03 20:17 ` Andrew Cooper
0 siblings, 2 replies; 4+ messages in thread
From: Jan Beulich @ 2015-03-03 14:38 UTC (permalink / raw)
To: xen-devel
Cc: Keir Fraser, Tim Deegan, Dario Faggioli, Ian Jackson,
Ian Campbell, Wei Liu
[-- Attachment #1: Type: text/plain, Size: 3063 bytes --]
As we get ready to use the information set for a domain here we should
make sure it is actually valid: Both vNode and pNode numbers should be
in range. Do a little bit of other cleanup so the code ends up looking
reasonably consistent in style.
Along with this goes that we don't need an array of unsigned int to
store the pNode number - a nodeid_t one (a quarter the size) suffices.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -344,7 +344,7 @@ static struct vnuma_info *vnuma_alloc(un
vnuma->vdistance = xmalloc_array(unsigned int, nr_vnodes * nr_vnodes);
vnuma->vcpu_to_vnode = xmalloc_array(unsigned int, nr_vcpus);
- vnuma->vnode_to_pnode = xmalloc_array(unsigned int, nr_vnodes);
+ vnuma->vnode_to_pnode = xmalloc_array(nodeid_t, nr_vnodes);
vnuma->vmemrange = xmalloc_array(xen_vmemrange_t, nr_ranges);
if ( vnuma->vdistance == NULL || vnuma->vmemrange == NULL ||
@@ -382,30 +382,40 @@ static struct vnuma_info *vnuma_init(con
nr_vnodes * nr_vnodes) )
goto vnuma_fail;
+ if ( copy_from_guest(info->vmemrange, uinfo->vmemrange,
+ uinfo->nr_vmemranges) )
+ goto vnuma_fail;
+
if ( copy_from_guest(info->vcpu_to_vnode, uinfo->vcpu_to_vnode,
d->max_vcpus) )
goto vnuma_fail;
- if ( copy_from_guest(info->vnode_to_pnode, uinfo->vnode_to_pnode,
- nr_vnodes) )
- goto vnuma_fail;
+ ret = -E2BIG;
+ for ( i = 0; i < d->max_vcpus; ++i )
+ if ( info->vcpu_to_vnode[i] >= nr_vnodes )
+ goto vnuma_fail;
- if (copy_from_guest(info->vmemrange, uinfo->vmemrange,
- uinfo->nr_vmemranges))
- goto vnuma_fail;
+ for ( i = 0; i < nr_vnodes; ++i )
+ {
+ unsigned int pnode;
+
+ ret = -EFAULT;
+ if ( copy_from_guest_offset(&pnode, uinfo->vnode_to_pnode, i, 1) )
+ goto vnuma_fail;
+ ret = -E2BIG;
+ if ( pnode >= MAX_NUMNODES )
+ goto vnuma_fail;
+ info->vnode_to_pnode[i] = pnode;
+ }
info->nr_vnodes = nr_vnodes;
info->nr_vmemranges = uinfo->nr_vmemranges;
/* Check that vmemranges flags are zero. */
+ ret = -EINVAL;
for ( i = 0; i < info->nr_vmemranges; i++ )
- {
if ( info->vmemrange[i].flags != 0 )
- {
- ret = -EINVAL;
goto vnuma_fail;
- }
- }
return info;
--- a/xen/include/xen/domain.h
+++ b/xen/include/xen/domain.h
@@ -4,6 +4,7 @@
#include <public/xen.h>
#include <asm/domain.h>
+#include <asm/numa.h>
typedef union {
struct vcpu_guest_context *nat;
@@ -99,7 +100,7 @@ struct vnuma_info {
unsigned int nr_vmemranges;
unsigned int *vdistance;
unsigned int *vcpu_to_vnode;
- unsigned int *vnode_to_pnode;
+ nodeid_t *vnode_to_pnode;
struct xen_vmemrange *vmemrange;
};
[-- Attachment #2: vNUMA-validate.patch --]
[-- Type: text/plain, Size: 3106 bytes --]
vNUMA: validate XEN_DOMCTL_setvnumainfo input
As we get ready to use the information set for a domain here we should
make sure it is actually valid: Both vNode and pNode numbers should be
in range. Do a little bit of other cleanup so the code ends up looking
reasonably consistent in style.
Along with this goes that we don't need an array of unsigned int to
store the pNode number - a nodeid_t one (a quarter the size) suffices.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -344,7 +344,7 @@ static struct vnuma_info *vnuma_alloc(un
vnuma->vdistance = xmalloc_array(unsigned int, nr_vnodes * nr_vnodes);
vnuma->vcpu_to_vnode = xmalloc_array(unsigned int, nr_vcpus);
- vnuma->vnode_to_pnode = xmalloc_array(unsigned int, nr_vnodes);
+ vnuma->vnode_to_pnode = xmalloc_array(nodeid_t, nr_vnodes);
vnuma->vmemrange = xmalloc_array(xen_vmemrange_t, nr_ranges);
if ( vnuma->vdistance == NULL || vnuma->vmemrange == NULL ||
@@ -382,30 +382,40 @@ static struct vnuma_info *vnuma_init(con
nr_vnodes * nr_vnodes) )
goto vnuma_fail;
+ if ( copy_from_guest(info->vmemrange, uinfo->vmemrange,
+ uinfo->nr_vmemranges) )
+ goto vnuma_fail;
+
if ( copy_from_guest(info->vcpu_to_vnode, uinfo->vcpu_to_vnode,
d->max_vcpus) )
goto vnuma_fail;
- if ( copy_from_guest(info->vnode_to_pnode, uinfo->vnode_to_pnode,
- nr_vnodes) )
- goto vnuma_fail;
+ ret = -E2BIG;
+ for ( i = 0; i < d->max_vcpus; ++i )
+ if ( info->vcpu_to_vnode[i] >= nr_vnodes )
+ goto vnuma_fail;
- if (copy_from_guest(info->vmemrange, uinfo->vmemrange,
- uinfo->nr_vmemranges))
- goto vnuma_fail;
+ for ( i = 0; i < nr_vnodes; ++i )
+ {
+ unsigned int pnode;
+
+ ret = -EFAULT;
+ if ( copy_from_guest_offset(&pnode, uinfo->vnode_to_pnode, i, 1) )
+ goto vnuma_fail;
+ ret = -E2BIG;
+ if ( pnode >= MAX_NUMNODES )
+ goto vnuma_fail;
+ info->vnode_to_pnode[i] = pnode;
+ }
info->nr_vnodes = nr_vnodes;
info->nr_vmemranges = uinfo->nr_vmemranges;
/* Check that vmemranges flags are zero. */
+ ret = -EINVAL;
for ( i = 0; i < info->nr_vmemranges; i++ )
- {
if ( info->vmemrange[i].flags != 0 )
- {
- ret = -EINVAL;
goto vnuma_fail;
- }
- }
return info;
--- a/xen/include/xen/domain.h
+++ b/xen/include/xen/domain.h
@@ -4,6 +4,7 @@
#include <public/xen.h>
#include <asm/domain.h>
+#include <asm/numa.h>
typedef union {
struct vcpu_guest_context *nat;
@@ -99,7 +100,7 @@ struct vnuma_info {
unsigned int nr_vmemranges;
unsigned int *vdistance;
unsigned int *vcpu_to_vnode;
- unsigned int *vnode_to_pnode;
+ nodeid_t *vnode_to_pnode;
struct xen_vmemrange *vmemrange;
};
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vNUMA: validate XEN_DOMCTL_setvnumainfo input
2015-03-03 14:38 [PATCH] vNUMA: validate XEN_DOMCTL_setvnumainfo input Jan Beulich
@ 2015-03-03 14:46 ` Wei Liu
2015-03-03 14:53 ` Ian Campbell
2015-03-03 20:17 ` Andrew Cooper
1 sibling, 1 reply; 4+ messages in thread
From: Wei Liu @ 2015-03-03 14:46 UTC (permalink / raw)
To: Jan Beulich
Cc: Wei Liu, Keir Fraser, Tim Deegan, Dario Faggioli, Ian Jackson,
Ian Campbell, xen-devel
On Tue, Mar 03, 2015 at 02:38:19PM +0000, Jan Beulich wrote:
> As we get ready to use the information set for a domain here we should
> make sure it is actually valid: Both vNode and pNode numbers should be
> in range. Do a little bit of other cleanup so the code ends up looking
> reasonably consistent in style.
>
> Along with this goes that we don't need an array of unsigned int to
> store the pNode number - a nodeid_t one (a quarter the size) suffices.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
FWIW
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vNUMA: validate XEN_DOMCTL_setvnumainfo input
2015-03-03 14:46 ` Wei Liu
@ 2015-03-03 14:53 ` Ian Campbell
0 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2015-03-03 14:53 UTC (permalink / raw)
To: Wei Liu
Cc: Keir Fraser, Tim Deegan, Dario Faggioli, Ian Jackson, Jan Beulich,
xen-devel
On Tue, 2015-03-03 at 14:46 +0000, Wei Liu wrote:
> On Tue, Mar 03, 2015 at 02:38:19PM +0000, Jan Beulich wrote:
> > As we get ready to use the information set for a domain here we should
> > make sure it is actually valid: Both vNode and pNode numbers should be
> > in range. Do a little bit of other cleanup so the code ends up looking
> > reasonably consistent in style.
> >
> > Along with this goes that we don't need an array of unsigned int to
> > store the pNode number - a nodeid_t one (a quarter the size) suffices.
> >
> > Signed-off-by: Jan Beulich <jbeulich@suse.com>
> >
>
> FWIW
>
> Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@cigtrix.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vNUMA: validate XEN_DOMCTL_setvnumainfo input
2015-03-03 14:38 [PATCH] vNUMA: validate XEN_DOMCTL_setvnumainfo input Jan Beulich
2015-03-03 14:46 ` Wei Liu
@ 2015-03-03 20:17 ` Andrew Cooper
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2015-03-03 20:17 UTC (permalink / raw)
To: Jan Beulich, xen-devel
Cc: Keir Fraser, Ian Jackson, Dario Faggioli, Tim Deegan,
Ian Campbell, Wei Liu
[-- Attachment #1.1: Type: text/plain, Size: 3386 bytes --]
On 03/03/15 14:38, Jan Beulich wrote:
> As we get ready to use the information set for a domain here we should
> make sure it is actually valid: Both vNode and pNode numbers should be
> in range. Do a little bit of other cleanup so the code ends up looking
> reasonably consistent in style.
>
> Along with this goes that we don't need an array of unsigned int to
> store the pNode number - a nodeid_t one (a quarter the size) suffices.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
>
> --- a/xen/common/domctl.c
> +++ b/xen/common/domctl.c
> @@ -344,7 +344,7 @@ static struct vnuma_info *vnuma_alloc(un
>
> vnuma->vdistance = xmalloc_array(unsigned int, nr_vnodes * nr_vnodes);
> vnuma->vcpu_to_vnode = xmalloc_array(unsigned int, nr_vcpus);
> - vnuma->vnode_to_pnode = xmalloc_array(unsigned int, nr_vnodes);
> + vnuma->vnode_to_pnode = xmalloc_array(nodeid_t, nr_vnodes);
> vnuma->vmemrange = xmalloc_array(xen_vmemrange_t, nr_ranges);
>
> if ( vnuma->vdistance == NULL || vnuma->vmemrange == NULL ||
> @@ -382,30 +382,40 @@ static struct vnuma_info *vnuma_init(con
> nr_vnodes * nr_vnodes) )
> goto vnuma_fail;
>
> + if ( copy_from_guest(info->vmemrange, uinfo->vmemrange,
> + uinfo->nr_vmemranges) )
> + goto vnuma_fail;
> +
> if ( copy_from_guest(info->vcpu_to_vnode, uinfo->vcpu_to_vnode,
> d->max_vcpus) )
> goto vnuma_fail;
>
> - if ( copy_from_guest(info->vnode_to_pnode, uinfo->vnode_to_pnode,
> - nr_vnodes) )
> - goto vnuma_fail;
> + ret = -E2BIG;
> + for ( i = 0; i < d->max_vcpus; ++i )
> + if ( info->vcpu_to_vnode[i] >= nr_vnodes )
> + goto vnuma_fail;
>
> - if (copy_from_guest(info->vmemrange, uinfo->vmemrange,
> - uinfo->nr_vmemranges))
> - goto vnuma_fail;
> + for ( i = 0; i < nr_vnodes; ++i )
> + {
> + unsigned int pnode;
> +
> + ret = -EFAULT;
> + if ( copy_from_guest_offset(&pnode, uinfo->vnode_to_pnode, i, 1) )
> + goto vnuma_fail;
> + ret = -E2BIG;
> + if ( pnode >= MAX_NUMNODES )
> + goto vnuma_fail;
> + info->vnode_to_pnode[i] = pnode;
> + }
>
> info->nr_vnodes = nr_vnodes;
> info->nr_vmemranges = uinfo->nr_vmemranges;
>
> /* Check that vmemranges flags are zero. */
> + ret = -EINVAL;
> for ( i = 0; i < info->nr_vmemranges; i++ )
> - {
> if ( info->vmemrange[i].flags != 0 )
> - {
> - ret = -EINVAL;
> goto vnuma_fail;
> - }
> - }
>
> return info;
>
> --- a/xen/include/xen/domain.h
> +++ b/xen/include/xen/domain.h
> @@ -4,6 +4,7 @@
>
> #include <public/xen.h>
> #include <asm/domain.h>
> +#include <asm/numa.h>
>
> typedef union {
> struct vcpu_guest_context *nat;
> @@ -99,7 +100,7 @@ struct vnuma_info {
> unsigned int nr_vmemranges;
> unsigned int *vdistance;
> unsigned int *vcpu_to_vnode;
> - unsigned int *vnode_to_pnode;
> + nodeid_t *vnode_to_pnode;
> struct xen_vmemrange *vmemrange;
> };
>
>
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
[-- Attachment #1.2: Type: text/html, Size: 4247 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-03-03 20:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-03 14:38 [PATCH] vNUMA: validate XEN_DOMCTL_setvnumainfo input Jan Beulich
2015-03-03 14:46 ` Wei Liu
2015-03-03 14:53 ` Ian Campbell
2015-03-03 20:17 ` Andrew Cooper
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.