Skip to content

[kernel] Perform sbrk address wrap check#2134

Merged
ghaerr merged 1 commit intomasterfrom
vmalloc4
Dec 14, 2024
Merged

[kernel] Perform sbrk address wrap check#2134
ghaerr merged 1 commit intomasterfrom
vmalloc4

Conversation

@ghaerr
Copy link
Copy Markdown
Owner

@ghaerr ghaerr commented Dec 14, 2024

Yet another fix - signed arithmetic address wrap check is now performed in the kernel. This check was previously in v7malloc but not in standard malloc.

Address wrap could occur in malloc/sbrk when the heap break is at a high address, and a large allocation request occurs that overflows the 16-bit process heap break address when calculating the new break address. This was previously not checked for an would result in the break set to a low address, corrupting data.

A message "SBRK FAIL, OUT OF HEAP (address wrap)" is now displayed, and the allocation denied, which will end up with malloc safely returning NULL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant