In riscv_send_ipi(), check if hyp is NULL before accessing hyp->vm
to prevent a potential NULL pointer dereference.
Micro-optimization: Use __predict_false for the hypctx == NULL check.
Signed-off-by: Doongar Singh <doonbsd@gmail.com>
Differential D60789
riscv: bhyve: add NULL check for hyp in riscv_send_ipi Authored by doonbsd_gmail.com on Fri, Oct 16, 10:43 PM. Tags None Referenced Files
Details
In riscv_send_ipi(), check if hyp is NULL before accessing hyp->vm Micro-optimization: Use __predict_false for the hypctx == NULL check. Signed-off-by: Doongar Singh <doonbsd@gmail.com>
Diff Detail
Event TimelineComment Actions Commit message does not say the "why", only the "what"; i.e. it doesn't say under what circumstances this can happen. Can it happen? It would seem like a rather broken state to be in. Comment Actions riscv_send_ipi() is an independent non-static helper function. Since the check is for all possible CPUs and not just active CPUs, any part of the kernel (malicious) can call it with wrong arguments and cause a kernel panic. I think its a good defensive check. Comment Actions I am sorry. Being defensive when function is open for abuse is not good enough? Also, the guest SBI calls can't be trusted. |