* [PATCH v2] xen/sched: fix sched_move_domain() for domain without vcpus
@ 2021-09-08 13:04 Juergen Gross
2021-09-14 21:59 ` Dario Faggioli
2021-09-15 14:31 ` Luca Fancellu
0 siblings, 2 replies; 3+ messages in thread
From: Juergen Gross @ 2021-09-08 13:04 UTC (permalink / raw)
To: xen-devel; +Cc: Juergen Gross, George Dunlap, Dario Faggioli, Bertrand Marquis
In case a domain is created with a cpupool other than Pool-0 specified
it will be moved to that cpupool before any vcpus are allocated.
This will lead to a NULL pointer dereference in sched_move_domain().
Fix that by tolerating vcpus not being allocated yet.
Fixes: 70fadc41635b9b6 ("xen/cpupool: support moving domain between cpupools with different granularity")
Reported-by: Bertrand Marquis <bertrand.marquis@arm.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
V2:
- Only test for vcpu[0] not being present (Jan Beulich)
---
xen/common/sched/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 8d178baf3d..8f4b1ca10d 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -651,7 +651,7 @@ int sched_move_domain(struct domain *d, struct cpupool *c)
struct scheduler *old_ops = dom_scheduler(d);
void *old_domdata;
unsigned int gran = cpupool_get_granularity(c);
- unsigned int n_units = DIV_ROUND_UP(d->max_vcpus, gran);
+ unsigned int n_units = d->vcpu[0] ? DIV_ROUND_UP(d->max_vcpus, gran) : 0;
int ret = 0;
for_each_vcpu ( d, v )
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] xen/sched: fix sched_move_domain() for domain without vcpus
2021-09-08 13:04 [PATCH v2] xen/sched: fix sched_move_domain() for domain without vcpus Juergen Gross
@ 2021-09-14 21:59 ` Dario Faggioli
2021-09-15 14:31 ` Luca Fancellu
1 sibling, 0 replies; 3+ messages in thread
From: Dario Faggioli @ 2021-09-14 21:59 UTC (permalink / raw)
To: Juergen Gross, xen-devel; +Cc: George Dunlap, Bertrand Marquis
[-- Attachment #1: Type: text/plain, Size: 899 bytes --]
On Wed, 2021-09-08 at 15:04 +0200, Juergen Gross wrote:
> In case a domain is created with a cpupool other than Pool-0
> specified
> it will be moved to that cpupool before any vcpus are allocated.
>
> This will lead to a NULL pointer dereference in sched_move_domain().
>
> Fix that by tolerating vcpus not being allocated yet.
>
> Fixes: 70fadc41635b9b6 ("xen/cpupool: support moving domain between
> cpupools with different granularity")
> Reported-by: Bertrand Marquis <bertrand.marquis@arm.com>
> Signed-off-by: Juergen Gross <jgross@suse.com>
>
Reviewed-by: Dario Faggioli <dfaggioli@suse.com>
Regards
--
Dario Faggioli, Ph.D
http://about.me/dario.faggioli
Virtualization Software Engineer
SUSE Labs, SUSE https://www.suse.com/
-------------------------------------------------------------------
<<This happens because _I_ choose it to happen!>> (Raistlin Majere)
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] xen/sched: fix sched_move_domain() for domain without vcpus
2021-09-08 13:04 [PATCH v2] xen/sched: fix sched_move_domain() for domain without vcpus Juergen Gross
2021-09-14 21:59 ` Dario Faggioli
@ 2021-09-15 14:31 ` Luca Fancellu
1 sibling, 0 replies; 3+ messages in thread
From: Luca Fancellu @ 2021-09-15 14:31 UTC (permalink / raw)
To: Juergen Gross; +Cc: xen-devel, George Dunlap, Dario Faggioli, Bertrand Marquis
> On 8 Sep 2021, at 14:04, Juergen Gross <jgross@suse.com> wrote:
>
> In case a domain is created with a cpupool other than Pool-0 specified
> it will be moved to that cpupool before any vcpus are allocated.
>
> This will lead to a NULL pointer dereference in sched_move_domain().
>
> Fix that by tolerating vcpus not being allocated yet.
>
> Fixes: 70fadc41635b9b6 ("xen/cpupool: support moving domain between cpupools with different granularity")
> Reported-by: Bertrand Marquis <bertrand.marquis@arm.com>
> Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Luca Fancellu <Luca.fancellu@arm.com>
> ---
> V2:
> - Only test for vcpu[0] not being present (Jan Beulich)
> ---
> xen/common/sched/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
> index 8d178baf3d..8f4b1ca10d 100644
> --- a/xen/common/sched/core.c
> +++ b/xen/common/sched/core.c
> @@ -651,7 +651,7 @@ int sched_move_domain(struct domain *d, struct cpupool *c)
> struct scheduler *old_ops = dom_scheduler(d);
> void *old_domdata;
> unsigned int gran = cpupool_get_granularity(c);
> - unsigned int n_units = DIV_ROUND_UP(d->max_vcpus, gran);
> + unsigned int n_units = d->vcpu[0] ? DIV_ROUND_UP(d->max_vcpus, gran) : 0;
> int ret = 0;
>
> for_each_vcpu ( d, v )
> --
> 2.26.2
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-15 14:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-08 13:04 [PATCH v2] xen/sched: fix sched_move_domain() for domain without vcpus Juergen Gross
2021-09-14 21:59 ` Dario Faggioli
2021-09-15 14:31 ` Luca Fancellu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).