Page MenuHomeFreeBSD

Check for wrap-around in vm_phys_alloc_seg_contig().
ClosedPublic

Authored by kib on Mar 20 2018, 10:27 AM.
Tags
None
Referenced Files
F167727477: D14767.diff
Mon, Aug 24, 1:55 AM
F167712030: D14767.id40501.diff
Sun, Aug 23, 10:21 PM
Unknown Object (File)
Tue, Aug 11, 3:04 PM
Unknown Object (File)
Mon, Aug 10, 11:43 PM
Unknown Object (File)
Mon, Aug 10, 11:42 PM
Unknown Object (File)
Mon, Aug 10, 11:41 PM
Unknown Object (File)
Mon, Aug 10, 11:41 PM
Unknown Object (File)
Sun, Aug 9, 5:44 AM
Subscribers

Details

Summary

It is possible to provide insane values for size in contigmalloc(9) request, which usually not reaches the phys allocator due to failing KVA allocation. But with the 4/4 i386, where 32bit architecture has almost 4G KVA, contigmalloc(1G) is not unreasonable outright and KVA might be available sometimes.

Then, the calculation of pa_end could wrap around, depending on the physical address, and the checks in vm_phys_alloc_seg_contig() would pass while the iteration in the loop after the 'done' label goes out of the vm_page_array bounds.

Fix it by detecting the wrap.

Reported and tested by: pho

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib added a subscriber: pho.
sys/vm/vm_phys.c
1192 ↗(On Diff #40490)

Doesn't the first condition suffice?

Remove redundant check.

This revision is now accepted and ready to land.Mar 20 2018, 3:39 PM
This revision was automatically updated to reflect the committed changes.