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
F168253765: D14767.id40501.diff
Thu, Aug 27, 5:03 AM
F168171632: D14767.diff
Wed, Aug 26, 5:12 PM
F168091852: D14767.id40490.diff
Wed, Aug 26, 8:33 AM
Unknown Object (File)
Mon, Aug 24, 1:55 AM
Unknown Object (File)
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
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 15656

Event Timeline

kib added a subscriber: pho.
sys/vm/vm_phys.c
1192

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.