New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib/ukalloc: Fix underallocation bug in malloc #931
Conversation
This change fixes a logic error that allocates less memory than necessary in specific cases, risking the memory corruption of internal data structures, leading to unpredictable behavior and crashes. Signed-off-by: Andrei Tatar <andrei@unikraft.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this PR, the native port of redis
now functions correctly. Previously, I would get crashes if I sent a large number of requests.
Reviewed-by: Ioan-Teodor Teugea ioan_teodor.teugea@stud.acs.upb.ro
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Tested it throughly!
Reviewed-by: Eduard-Florin Mihailescu mihailescu.eduard@gmail.com
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved-by: Razvan Deaconescu razvand@unikraft.io
This change fixes a logic error that allocates less memory than necessary in specific cases, risking the memory corruption of internal data structures, leading to unpredictable behavior and crashes. Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Eduard-Florin Mihailescu <mihailescu.eduard@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io> GitHub-Closes: unikraft#931 lib: Added ofw as library lib: Add ofw as library
This change fixes a logic error that allocates less memory than necessary in specific cases, risking the memory corruption of internal data structures, leading to unpredictable behavior and crashes. Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Eduard-Florin Mihailescu <mihailescu.eduard@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io> GitHub-Closes: unikraft#931
This change fixes a logic error that allocates less memory than necessary in specific cases, risking the memory corruption of internal data structures, leading to unpredictable behavior and crashes. Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Eduard-Florin Mihailescu <mihailescu.eduard@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io> GitHub-Closes: unikraft#931
Description of changes
This change fixes a logic error that allocates less memory than necessary in specific cases, risking the memory corruption of internal data structures, leading to unpredictable behavior and crashes.
The bug manifests when requesting exactly 24 bytes less than an integer number of pages (4072, 8168, etc.) because our malloc code reserves 24 bytes of extra space for bookkeeping metadata. However, the same malloc implementation returns buffers 32 bytes above an allocated page boundary, leading to 8 bytes being inadvertently underallocated. Any code that rightfully uses the entire buffer returned by malloc risks corrupting the following page, with dire consequences.
This fix reserves the correct amount of space when computing how many pages to allocate.
Prerequisite checklist
checkpatch.uk
on your commit series before opening this PR;Base target
Additional configuration
Minimal snippet to reproduce the issue: