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
Unknown Object (File)
Dec 1 2023, 4:45 AM
Unknown Object (File)
Nov 24 2023, 7:47 AM
Unknown Object (File)
Aug 16 2023, 1:23 AM
Unknown Object (File)
Aug 3 2023, 7:26 PM
Unknown Object (File)
Aug 3 2023, 7:25 PM
Unknown Object (File)
Aug 3 2023, 7:24 PM
Unknown Object (File)
Aug 3 2023, 7:21 PM
Unknown Object (File)
Aug 2 2023, 6:04 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 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.