Page MenuHomeFreeBSD

riscv: bhyve: add NULL check for hyp in riscv_send_ipi
Needs RevisionPublic

Authored by doonbsd_gmail.com on Fri, Oct 16, 10:43 PM.
Tags
None
Referenced Files
F176383494: D60789.id.diff
Sun, Oct 18, 10:29 AM
F176383491: D60789.id190079.diff
Sun, Oct 18, 10:29 AM
F176383457: D60789.diff
Sun, Oct 18, 10:29 AM
Unknown Object (File)
Sat, Oct 17, 2:42 PM
Unknown Object (File)
Sat, Oct 17, 2:20 PM
Unknown Object (File)
Sat, Oct 17, 9:19 AM
Unknown Object (File)
Sat, Oct 17, 4:44 AM
Unknown Object (File)
Sat, Oct 17, 2:23 AM
Subscribers

Details

Reviewers
jrtc27
Summary

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>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 78278
Build 75161: arc lint + arc unit

Event Timeline

jrtc27 requested changes to this revision.Sat, Oct 17, 1:28 AM
jrtc27 added a subscriber: jrtc27.

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.

This revision now requires changes to proceed.Sat, Oct 17, 1:28 AM

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.

That is not in general sufficient reasoning

I am sorry. Being defensive when function is open for abuse is not good enough? Also, the guest SBI calls can't be trusted.