Fix crashes with arinc653 cpupools
cover Fix crashes with arinc653 cpupools
From: Nathan Studer <[email protected]>
The ARINC653 scheduler's vdata_alloc and vdata_free functions contain a number of errors which cause the hypervisor to crash when using the ARINC653 scheduler with cpupools.
Nathan Studer (2):
Fix sched_priv corruption in ARINC653 alloc_vdata. Fix NULL pointer dereference in ARINC653 free_vdata.
xen/common/sched_arinc653.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/2 Fix sched_priv corruption in ARINC653 alloc_vdata.
From: Nathan Studer <[email protected]>
The ARINC653 scheduler was directly assigning and manipulating the sched_priv field of a vcpu in its alloc_vdata function.
When creating a cpu pool, this resulted in the corruption of the sched_priv field of the vcpu, which was then passed to the initial scheduler's free_vdata function with disastrous results.
--- xen/common/sched_arinc653.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
xen/common/sched_arinc653.c +9 -6
@@ -380,11 +380,14 @@ a653sched_deinit(const struct scheduler *ops)static void *a653sched_alloc_vdata (const struct scheduler *ops,struct vcpu *vc,void *dd) { +arinc653_vcpu_t *svc; +/* * Allocate memory for the ARINC 653-specific scheduler data information * associated with the given VCPU (vc). -*/ -if ( (vc->sched_priv =xmalloc (arinc653_vcpu_t)) ==NULL ) +*/ + svc =xmalloc (arinc653_vcpu_t); +if ( svc ==NULL )return NULL ;/*
@@ -393,13 +396,13 @@ a653sched_alloc_vdata(const struct scheduler *ops, struct vcpu *vc, void *dd)* will call the vcpu_wake scheduler callback function and our scheduler * will mark the VCPU awake. */ -AVCPU (vc)->vc = vc; -AVCPU (vc)->awake =0 ; + svc->vc = vc; + svc->awake =0 ;if ( !is_idle_vcpu (vc) ) -list_add (&AVCPU (vc)->list, &SCHED_PRIV (ops)->vcpu_list); +list_add (&svc->list, &SCHED_PRIV (ops)->vcpu_list);update_schedule_vcpus (ops); -return AVCPU (vc); +return svc; }/**
Signature · 1 line
1.7.9.5
Re: [PATCH 1/2] Fix sched_priv corruption in ARINC653 alloc_vdata.
Quoted 11 lines · Nathan Studer
From: Nathan Studer <[email protected]>
The ARINC653 scheduler was directly assigning and manipulating the
sched_privfield of a vcpu in itsalloc_vdatafunction.When creating a cpu pool, this resulted in the corruption of the
sched_privfield of the vcpu, which was then passed to the initial scheduler'sfree_vdatafunction with disastrous results.Signed-off-by Nathan Studer <[email protected]>
This looks sane.
You have one line of misc whitespace change. Given the extent of trailing whitespace in the file, it might be worth having a separate patch in the series which fixes all the whitespace at once. Along with that, it would be kind to put a "Local variables" block in as well (see the bottom of sched.h as an example).
Quoted 43 lines
--- xen/common/sched_arinc653.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)xen/common/sched_arinc653.c +9
-6@@ -380,11 +380,14 @@ a653sched_deinit(const struct scheduler *ops)static void *a653sched_alloc_vdata (const struct scheduler *ops,struct vcpu *vc,void *dd) { +arinc653_vcpu_t *svc; +/* * Allocate memory for the ARINC 653-specific scheduler data information * associated with the given VCPU (vc). -*/ -if ( (vc->sched_priv =xmalloc (arinc653_vcpu_t)) ==NULL ) +*/ + svc =xmalloc (arinc653_vcpu_t); +if ( svc ==NULL )return NULL ;/* @@ -393,13 +396,13 @@ a653sched_alloc_vdata(const struct scheduler *ops, struct vcpu *vc, void *dd)* will call the vcpu_wake scheduler callback function and our scheduler * will mark the VCPU awake. */ -AVCPU (vc)->vc = vc; -AVCPU (vc)->awake =0 ; + svc->vc = vc; + svc->awake =0 ;if ( !is_idle_vcpu (vc) ) -list_add (&AVCPU (vc)->list, &SCHED_PRIV (ops)->vcpu_list); +list_add (&svc->list, &SCHED_PRIV (ops)->vcpu_list);update_schedule_vcpus (ops); -return AVCPU (vc); +return svc; }/**
Re: [PATCH 1/2] Fix sched_priv corruption in ARINC653 alloc_vdata.
Quoted 15 lines · Andrew Cooper
Quoted 11 lines · Nathan Studer
From: Nathan Studer <[email protected]>
The ARINC653 scheduler was directly assigning and manipulating the
sched_privfield of a vcpu in itsalloc_vdatafunction.When creating a cpu pool, this resulted in the corruption of the
sched_privfield of the vcpu, which was then passed to the initial scheduler'sfree_vdatafunction with disastrous results.Signed-off-by Nathan Studer <[email protected]>This looks sane.
Quoted 7 lines
Reviewed-by Andrew Cooper <[email protected]>You have one line of misc whitespace change. Given the extent of trailing whitespace in the file, it might be worth having a separate patch in the series which fixes all the whitespace at once. Along with that, it would be kind to put a "Local variables" block in as well (see the bottom of
sched.has an example).
These patches just fix the immediate problem of the hypervisor crashing when using the arinc653 scheduler in cpu pools. I expect some more patches in the near future to get pools fully working with the arinc653 scheduler, and since I agree with your assessment, I can address this then.
Thanks for suggesting it.
Re: [PATCH 1/2] Fix sched_priv corruption in ARINC653 alloc_vdata.
In reply to Nathan StuderQuoted 11 lines · Nathan Studer
From: Nathan Studer <[email protected]>
The ARINC653 scheduler was directly assigning and manipulating the
sched_privfield of a vcpu in itsalloc_vdatafunction.When creating a cpu pool, this resulted in the corruption of the
sched_privfield of the vcpu, which was then passed to the initial scheduler'sfree_vdatafunction with disastrous results.Signed-off-by Nathan Studer <[email protected]>
Quoted 43 lines
--- xen/common/sched_arinc653.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)xen/common/sched_arinc653.c +9
-6@@ -380,11 +380,14 @@ a653sched_deinit(const struct scheduler *ops)static void *a653sched_alloc_vdata (const struct scheduler *ops,struct vcpu *vc,void *dd) { +arinc653_vcpu_t *svc; +/* * Allocate memory for the ARINC 653-specific scheduler data information * associated with the given VCPU (vc). -*/ -if ( (vc->sched_priv =xmalloc (arinc653_vcpu_t)) ==NULL ) +*/ + svc =xmalloc (arinc653_vcpu_t); +if ( svc ==NULL )return NULL ;/* @@ -393,13 +396,13 @@ a653sched_alloc_vdata(const struct scheduler *ops, struct vcpu *vc, void *dd)* will call the vcpu_wake scheduler callback function and our scheduler * will mark the VCPU awake. */ -AVCPU (vc)->vc = vc; -AVCPU (vc)->awake =0 ; + svc->vc = vc; + svc->awake =0 ;if ( !is_idle_vcpu (vc) ) -list_add (&AVCPU (vc)->list, &SCHED_PRIV (ops)->vcpu_list); +list_add (&svc->list, &SCHED_PRIV (ops)->vcpu_list);update_schedule_vcpus (ops); -return AVCPU (vc); +return svc; }/**
PATCH 2/2 Fix NULL pointer dereference in ARINC653 free_vdata.
In reply to Nathan StuderFrom: Nathan Studer <[email protected]>
The ARINC653 scheduler alloc_vdata function does not add the idle cpu to its internal vcpu_list, but when the free_vdata function is called, the scheduler attempted to remove the vcpu from its internal vcpu_list, regardless of whether or not the vcpu was the idle vcpu. Since the idle vcpu's list field was never initialized, a NULL pointer was passed to list_del.
When using cpupools, this resulted in a crash when moving a cpu from an arinc653 scheduler pool.
--- xen/common/sched_arinc653.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
xen/common/sched_arinc653.c +3 -1
@@ -418,7 +418,9 @@ a653sched_free_vdata(const struct scheduler *ops, void *priv)if (av ==NULL )return ; -list_del (&av->list); +if ( !is_idle_vcpu (av->vc) ) +list_del (&av->list); +xfree (av);update_schedule_vcpus (ops); }
Signature · 1 line
1.7.9.5
Re: [PATCH 2/2] Fix NULL pointer dereference in ARINC653 free_vdata.
Quoted 9 lines · Nathan Studer
From: Nathan Studer <[email protected]>
The ARINC653 scheduler
alloc_vdatafunction does not add the idle cpu to its internalvcpu_list, but when thefree_vdatafunction is called, the scheduler attempted to remove the vcpu from its internalvcpu_list, regardless of whether or not the vcpu was the idle vcpu. Since the idle vcpu's list field was never initialized, a NULL pointer was passed tolist_del.
Quoted 4 lines
When using cpupools, this resulted in a crash when moving a cpu from an arinc653 scheduler pool.
Signed-off-by Nathan Studer <[email protected]>
This again looks sane, but can't it logically be merged with the previous patch? Both of the patches are "dont break on {alloc,free}_vdata when using cpupools"
I guess this is a matter of taste.
~Andrew
Quoted 19 lines
--- xen/common/sched_arinc653.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)xen/common/sched_arinc653.c +3
-1@@ -418,7 +418,9 @@ a653sched_free_vdata(const struct scheduler *ops, void *priv)if (av ==NULL )return ; -list_del (&av->list); +if ( !is_idle_vcpu (av->vc) ) +list_del (&av->list); +xfree (av);update_schedule_vcpus (ops); }
Re: [PATCH 2/2] Fix NULL pointer dereference in ARINC653 free_vdata.
Quoted 13 lines · Andrew Cooper
Quoted 12 lines · Nathan Studer
From: Nathan Studer <[email protected]>
The ARINC653 scheduler
alloc_vdatafunction does not add the idle cpu to its internalvcpu_list, but when thefree_vdatafunction is called, the scheduler attempted to remove the vcpu from its internalvcpu_list, regardless of whether or not the vcpu was the idle vcpu. Since the idle vcpu's list field was never initialized, a NULL pointer was passed tolist_del.When using cpupools, this resulted in a crash when moving a cpu from an arinc653 scheduler pool.
Quoted 6 lines
Quoted 1 line
Signed-off-by Nathan Studer <[email protected]>This again looks sane, but can't it logically be merged with the previous patch? Both of the patches are "dont break on {alloc,free}_vdata when using cpupools"
I guess this is a matter of taste.
I don't think it's worth asking for a whole re-spin just to merge two relatively short commits that *could* be merged but also work separately.
Both these patches can have my Ack, BTW (although I don't think they need it): I just wanted to be a good citizen and do a bit of review. :-)
-George
Re: [PATCH 2/2] Fix NULL pointer dereference in ARINC653 free_vdata.
Quoted 21 lines · George Dunlap
Quoted 13 lines · Andrew Cooper
Quoted 12 lines · Nathan Studer
From: Nathan Studer <[email protected]>
The ARINC653 scheduler
alloc_vdatafunction does not add the idle cpu to its internalvcpu_list, but when thefree_vdatafunction is called, the scheduler attempted to remove the vcpu from its internalvcpu_list, regardless of whether or not the vcpu was the idle vcpu. Since the idle vcpu's list field was never initialized, a NULL pointer was passed tolist_del.When using cpupools, this resulted in a crash when moving a cpu from an arinc653 scheduler pool.
Quoted 6 lines
Quoted 1 line
Signed-off-by Nathan Studer <[email protected]>This again looks sane, but can't it logically be merged with the previous patch? Both of the patches are "dont break on {alloc,free}_vdata when using cpupools"
I guess this is a matter of taste.
Quoted 8 lines
I don't think it's worth asking for a whole re-spin just to merge two relatively short commits that *could* be merged but also work separately.
Both these patches can have my Ack, BTW (although I don't think they need it): I just wanted to be a good citizen and do a bit of review. :-)
-George
Fair point - the fixes are far more critical than the problems I nitpicked at.
FWIW, Reviewed-by: Andrew Cooper <[email protected]>
Re: [PATCH 2/2] Fix NULL pointer dereference in ARINC653 free_vdata.
In reply to George DunlapQuoted 2 lines · George Dunlap
Both these patches can have my Ack, BTW (although I don't think they need it): I just wanted to be a good citizen and do a bit of review. :-)
Thanks Andrew and George.
Just to make sure, and to avoid needlessly filling George's inbox, Robbie (The other ARINC653 scheduler maintainer) should usually be the one acking patches like this, correct?
Quoted 3 lines
-George
Re: [PATCH 2/2] Fix NULL pointer dereference in ARINC653 free_vdata.
Quoted 8 lines · Nate Studer
Quoted 2 lines · George Dunlap
Both these patches can have my Ack, BTW (although I don't think they need it): I just wanted to be a good citizen and do a bit of review. :-)
Thanks Andrew and George.
Just to make sure, and to avoid needlessly filling George's inbox, Robbie (The other ARINC653 scheduler maintainer) should usually be the one acking patches like this, correct?
Oh, don't worry about filling up my inbox. I do want to know what's going on in the scheduling area, and I probably *should* review this kind of patch anyway. I was just saying, I don't think the committers necessarily need to wait for an Ack from me to commit it. :-)
I'm not sure exactly what the policy would be here -- I think the "need an ack from someone else" rule is primarily for committers to commit their own patches. If you're just submitting it, as a maintainer, it seems like having the committer look over it (and being satisfied that the community has had a chance to comment) should be enough, and needing an extra Ack from the other committer is a bit over-kill, particularly in this case.
But I could be wrong about that. :-)
-George
Re: [PATCH 2/2] Fix NULL pointer dereference in ARINC653 free_vdata.
Quoted 15 lines · George Dunlap
Quoted 8 lines · Nate Studer
Quoted 2 lines · George Dunlap
Both these patches can have my Ack, BTW (although I don't think they need it): I just wanted to be a good citizen and do a bit of review. :-)
Thanks Andrew and George.
Just to make sure, and to avoid needlessly filling George's inbox, Robbie (The other ARINC653 scheduler maintainer) should usually be the one acking patches like this, correct?
Oh, don't worry about filling up my inbox. I do want to know what's going on in the scheduling area, and I probably *should* review this kind of patch anyway. I was just saying, I don't think the committers necessarily need to wait for an Ack from me to commit it. :-)
Quoted 7 lines
I'm not sure exactly what the policy would be here -- I think the "need an ack from someone else" rule is primarily for committers to commit their own patches. If you're just submitting it, as a maintainer, it seems like having the committer look over it (and being satisfied that the community has had a chance to comment) should be enough, and needing an extra Ack from the other committer is a bit over-kill, particularly in this case.
If I were a committer in this area (which I'm not) this is the sort of approach I would take...
Quoted 9 lines
But I could be wrong about that. :-)
-George
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/2] Fix NULL pointer dereference in ARINC653 free_vdata.
In reply to George DunlapQuoted 14 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 3 lines · Nate Studer
Just to make sure, and to avoid needlessly filling George's inbox, Robbie (The other ARINC653 scheduler maintainer) should usually be the one acking patches like this, correct?
I'm not sure exactly what the policy would be here -- I think the "need an ack from someone else" rule is primarily for committers to commit their own patches. If you're just submitting it, as a maintainer, it seems like having the committer look over it (and being satisfied that the community has had a chance to comment) should be enough, and needing an extra Ack from the other committer is a bit over-kill, particularly in this case.
Quoted 1 line
But I could be wrong about that. :-)
My understanding is the same.
Jan