Skip to content

Commit d479244

Browse files
committed
x86/intel_rdt/cqm: Prevent use after free
intel_rdt_iffline_cpu() -> domain_remove_cpu() frees memory first and then proceeds accessing it. BUG: KASAN: use-after-free in find_first_bit+0x1f/0x80 Read of size 8 at addr ffff883ff7c1e780 by task cpuhp/31/195 find_first_bit+0x1f/0x80 has_busy_rmid+0x47/0x70 intel_rdt_offline_cpu+0x4b4/0x510 Freed by task 195: kfree+0x94/0x1a0 intel_rdt_offline_cpu+0x17d/0x510 Do the teardown first and then free memory. Fixes: 24247ae ("x86/intel_rdt/cqm: Improve limbo list processing") Reported-by: Joseph Salisbury <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Ravi Shankar <[email protected]> Cc: Peter Zilstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Vikas Shivappa <[email protected]> Cc: Andi Kleen <[email protected]> Cc: "Roderick W. Smith" <[email protected]> Cc: [email protected] Cc: Fenghua Yu <[email protected]> Cc: Tony Luck <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1801161957510.2366@nanos
1 parent 107cd25 commit d479244

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/x86/kernel/cpu/intel_rdt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,6 @@ static void domain_remove_cpu(int cpu, struct rdt_resource *r)
525525
*/
526526
if (static_branch_unlikely(&rdt_mon_enable_key))
527527
rmdir_mondata_subdir_allrdtgrp(r, d->id);
528-
kfree(d->ctrl_val);
529-
kfree(d->rmid_busy_llc);
530-
kfree(d->mbm_total);
531-
kfree(d->mbm_local);
532528
list_del(&d->list);
533529
if (is_mbm_enabled())
534530
cancel_delayed_work(&d->mbm_over);
@@ -545,6 +541,10 @@ static void domain_remove_cpu(int cpu, struct rdt_resource *r)
545541
cancel_delayed_work(&d->cqm_limbo);
546542
}
547543

544+
kfree(d->ctrl_val);
545+
kfree(d->rmid_busy_llc);
546+
kfree(d->mbm_total);
547+
kfree(d->mbm_local);
548548
kfree(d);
549549
return;
550550
}

0 commit comments

Comments
 (0)