x86: fix assertion in ipi_send_cpu to range check the passed id

Prior to the change for sufficiently bad id (and in particular NOCPU which is -1)
it would access memory outside of the cpu_apic_ids array.
This commit is contained in:
Mateusz Guzik 2020-01-19 21:35:51 +00:00
parent 95a8fce118
commit 44c78346f6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=356897

View File

@ -1233,7 +1233,8 @@ ipi_send_cpu(int cpu, u_int ipi)
u_int bitmap, old, new;
u_int *cpu_bitmap;
KASSERT(cpu_apic_ids[cpu] != -1, ("IPI to non-existent CPU %d", cpu));
KASSERT((u_int)cpu < MAXCPU && cpu_apic_ids[cpu] != -1,
("IPI to non-existent CPU %d", cpu));
if (IPI_IS_BITMAPED(ipi)) {
bitmap = 1 << ipi;