Page MenuHomeFreeBSD

Avoid overflow in checking the size of free gaps in vm_map_findspace
ClosedPublic

Authored by dougm on Jun 10 2019, 9:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 8 2024, 1:45 PM
Unknown Object (File)
Dec 20 2023, 2:16 AM
Unknown Object (File)
Dec 18 2023, 8:12 AM
Unknown Object (File)
Nov 13 2023, 11:38 AM
Unknown Object (File)
Jul 12 2023, 8:40 PM
Unknown Object (File)
Jun 15 2023, 7:15 PM
Unknown Object (File)
Jun 3 2023, 7:58 AM
Unknown Object (File)
May 18 2023, 10:14 PM
Subscribers

Details

Summary

To test to see if a free space is big enough compare the required length to the difference of the two offsets that define the gap, to avoid overflow, rather that adding the length to an offset and comparing that to another offset.

This addresses an overflow issue reported by Peter Holm on i386.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Is this a fix for the i386 wrap issue, or just a related change ?

vm_map.c
1802

(void *) space before star.

Since you are changing format, note that the length is truncated. Perhaps use %ju (I would prefer %jx) and cast to uintmax_t for length.

dougm edited the summary of this revision. (Show Details)

Change formatting in error log, as suggested.

kib added inline comments.
vm_map.c
1801

I suggest %#jx

This revision is now accepted and ready to land.Jun 11 2019, 2:52 PM

I tested this patch on i386 with all of the mmap() tests I have. I also ran the same tests on amd64 plus a buildworld.
I can run a full test if you prefer that.

This revision was automatically updated to reflect the committed changes.