| Summary: | Bad KASSERT in vmm.c vm_gpa_hold() | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | Dave Cameron (puddingpimp) <daverabbitz> | ||||
| Component: | kern | Assignee: | John Baldwin <jhb> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | CC: | grehan, jhb | ||||
| Priority: | --- | Keywords: | patch | ||||
| Version: | CURRENT | Flags: | jhb:
mfc-stable11?
jhb: mfc-stable10? |
||||
| Hardware: | amd64 | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
Created attachment 168441 [details]
Patch as attachment
Adding Peter so he can review the patch. Looks fine. A commit references this bug: Author: jhb Date: Wed Aug 3 15:20:10 UTC 2016 New revision: 303713 URL: https://svnweb.freebsd.org/changeset/base/303713 Log: Correct assertion on vcpuid argument to vm_gpa_hold(). PR: 208168 Submitted by: Dave Cameron <daverabbitz@ihug.co.nz> Reviewed by: grehan MFC after: 1 month Changes: head/sys/amd64/vmm/vmm.c Committed to HEAD, thanks! A commit references this bug: Author: jhb Date: Fri Sep 9 20:30:36 UTC 2016 New revision: 305673 URL: https://svnweb.freebsd.org/changeset/base/305673 Log: MFC 303713: Correct assertion on vcpuid argument to vm_gpa_hold(). PR: 208168 Changes: _U stable/10/ stable/10/sys/amd64/vmm/vmm.c _U stable/11/ stable/11/sys/amd64/vmm/vmm.c |
The KASSERT in this function is always true for positive values of vcpuid, it looks like it is intended to check vcpuid is in the range -1 to VM_MAXCPU. Here is a patch to make it right: diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index cb04f3c..ebd6360 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -914,7 +914,7 @@ vm_gpa_hold(struct vm *vm, int vcpuid, vm_paddr_t gpa, size_t len, int reqprot, * guaranteed if at least one vcpu is in the VCPU_FROZEN state. */ int state; - KASSERT(vcpuid >= -1 || vcpuid < VM_MAXCPU, ("%s: invalid vcpuid %d", + KASSERT(vcpuid >= -1 && vcpuid < VM_MAXCPU, ("%s: invalid vcpuid %d", __func__, vcpuid)); for (i = 0; i < VM_MAXCPU; i++) { if (vcpuid != -1 && vcpuid != i)