[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] xen/sched: fix potential NULL dereference in sched_move_domain()
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Juergen Gross <jgross@xxxxxxxx>
- Date: Fri, 27 Nov 2026 16:45:00 +0100
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Autocrypt"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Autocrypt"
- Authentication-results: smtp-out1.suse.de; none
- Autocrypt: addr=jgross@xxxxxxxx; keydata= xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOB ycWxw3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJve dYm8Of8Zd621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJ NwQpd369y9bfIhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvx XP3FAp2pkW0xqG7/377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEB AAHNH0p1ZXJnZW4gR3Jvc3MgPGpncm9zc0BzdXNlLmNvbT7CwHkEEwECACMFAlOMcK8CGwMH CwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgAAKCRCw3p3WKL8TL8eZB/9G0juS/kDY9LhEXseh mE9U+iA1VsLhgDqVbsOtZ/S14LRFHczNd/Lqkn7souCSoyWsBs3/wO+OjPvxf7m+Ef+sMtr0 G5lCWEWa9wa0IXx5HRPW/ScL+e4AVUbL7rurYMfwCzco+7TfjhMEOkC+va5gzi1KrErgNRHH kg3PhlnRY0Udyqx++UYkAsN4TQuEhNN32MvN0Np3WlBJOgKcuXpIElmMM5f1BBzJSKBkW0Jc Wy3h2Wy912vHKpPV/Xv7ZwVJ27v7KcuZcErtptDevAljxJtE7aJG6WiBzm+v9EswyWxwMCIO RoVBYuiocc51872tRGywc03xaQydB+9R7BHPzsBNBFOMcBYBCADLMfoA44MwGOB9YT1V4KCy vAfd7E0BTfaAurbG+Olacciz3yd09QOmejFZC6AnoykydyvTFLAWYcSCdISMr88COmmCbJzn sHAogjexXiif6ANUUlHpjxlHCCcELmZUzomNDnEOTxZFeWMTFF9Rf2k2F0Tl4E5kmsNGgtSa aMO0rNZoOEiD/7UfPP3dfh8JCQ1VtUUsQtT1sxos8Eb/HmriJhnaTZ7Hp3jtgTVkV0ybpgFg w6WMaRkrBh17mV0z2ajjmabB7SJxcouSkR0hcpNl4oM74d2/VqoW4BxxxOD1FcNCObCELfIS auZx+XT6s+CE7Qi/c44ibBMR7hyjdzWbABEBAAHCwF8EGAECAAkFAlOMcBYCGwwACgkQsN6d 1ii/Ey9D+Af/WFr3q+bg/8v5tCknCtn92d5lyYTBNt7xgWzDZX8G6/pngzKyWfedArllp0Pn fgIXtMNV+3t8Li1Tg843EXkP7+2+CQ98MB8XvvPLYAfW8nNDV85TyVgWlldNcgdv7nn1Sq8g HwB2BHdIAkYce3hEoDQXt/mKlgEGsLpzJcnLKimtPXQQy9TxUaLBe9PInPd+Ohix0XOlY+Uk QFEx50Ki3rSDl2Zt2tnkNYKUCvTJq7jvOlaPd6d/W0tZqpyy7KVay+K4aMobDsodB3dvEAs6 ScCnh03dDAFgIq5nsB11j3KPKdVoPlfucX2c7kGNH+LUMbzqV6beIENfNexkOfxHfw==
- Cc: Dario Faggioli <dfaggioli@xxxxxxxx>, George Dunlap <gwd@xxxxxxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Fri, 27 Nov 2026 15:45:08 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 24.11.26 14:57, Jan Beulich wrote:
On 24.11.2026 13:20, Juergen Gross wrote:
If a dying domain has not all of its vcpus filled and it is moved from
a cpupool with gran=socket to one with gran=core,
Why would a dying domain need moving in this way in the first place?
Possibly connected to this, ...
it might happen that
during assignment of the new units to the vcpus a NULL pointer is
being dereferenced:
- system has 2 sockets with 2 cores each, each core has 2 threads
- Pool-0 has gran=core, other cpupool has gran=socket
- domain with max_vcpus=4 has only 3 vcpus and is in cpupool with
gran=socket
- domain is dying and is moved to Pool-0
- in sched_move_domain() this results in vcpu_failed being set to
true for the last unit of the domain, resulting in the unit not
being allocated ("continue" statement is being hit)
- in the for_each_vcpu() loop of sched_move_domain() for vcpu 2
the unit pointer will be set to NULL, as unit->next_in_list is not
populated due to above "continue"
Fixes: 4835c078e5cf ("xen/sched: core: skip missing vcpu slots in
sched_move_domain()")
Reported-by: Roger Pau Monné <roger.pau@xxxxxxx>
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
xen/common/sched/core.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 10b6eecccd..ee7077b870 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -830,10 +830,13 @@ int sched_move_domain(struct domain *d, struct cpupool *c)
if ( unit->unit_id + gran == v->vcpu_id )
unit = unit->next_in_list;
- unit->state_entry_time = old_unit->state_entry_time;
- unit->runstate_cnt[v->runstate.state]++;
- /* Temporarily use old resource assignment */
- unit->res = get_sched_res(new_cpu);
+ if ( unit )
+ {
+ unit->state_entry_time = old_unit->state_entry_time;
+ unit->runstate_cnt[v->runstate.state]++;
+ /* Temporarily use old resource assignment */
+ unit->res = get_sched_res(new_cpu);
+ }
v->sched_unit = unit;
... is this field becoming NULL really okay?
Turns out it isn't.
If vcpu_wake() is called for such a vcpu then NULL is being dereferenced.
I don't see why this couldn't happen for a dying domain.
And I'm sure other cases do exist, too.
Juergen
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature
|