Verify identity after checking for WAITFAIL in vm_page_busy_acquire().

A caller that does not guarantee that a page's identity won't change
while sleeping for a busy lock must specify either NOWAIT or WAITFAIL.

Reported by:	syzkaller
Reviewed by:	alc, kib
Discussed with:	jeff
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D22124
This commit is contained in:
markj 2019-10-23 17:58:19 +00:00
parent 3878ab63de
commit a789d36dbe

View File

@ -900,9 +900,11 @@ vm_page_busy_acquire(vm_page_t m, int allocflags)
(allocflags & VM_ALLOC_SBUSY) != 0, locked);
if (locked)
VM_OBJECT_WLOCK(obj);
MPASS(m->object == obj || m->object == NULL);
if ((allocflags & VM_ALLOC_WAITFAIL) != 0)
return (FALSE);
KASSERT(m->object == obj || m->object == NULL,
("vm_page_busy_acquire: page %p does not belong to %p",
m, obj));
}
}