Skip to content

πŸ”’ Fix integer overflow in calloc#33

Closed
undivisible wants to merge 1 commit into
mainfrom
fix-calloc-integer-overflow-663093201888592636
Closed

πŸ”’ Fix integer overflow in calloc#33
undivisible wants to merge 1 commit into
mainfrom
fix-calloc-integer-overflow-663093201888592636

Conversation

@undivisible

Copy link
Copy Markdown
Contributor

🎯 What: The vulnerability fixed is an integer overflow in calloc within kernel/libc.in. The product n * size could overflow when the arguments are large, resulting in a buffer allocation that is smaller than the requested size.

⚠️ Risk: If a smaller buffer is allocated due to the integer overflow, subsequent operations that assume the full size is available could cause a buffer overflow or memory corruption. This could lead to a crash or potential exploitation.

πŸ›‘οΈ Solution: Modified calloc to verify that n != 0 and then assert that (total / n) == size. If an integer overflow occurs during the multiplication, this check catches it and assert prevents further execution, effectively mitigating the vulnerability.


PR created automatically by Jules for task 663093201888592636 started by @undivisible

Adds a check in `kernel/libc.in` for the `calloc` function to ensure that
integer overflow does not happen during the multiplication of `n` and `size`.
If `n != 0` and `total / n != size`, the check will trigger an `assert`,
halting execution and preventing a smaller buffer allocation than expected,
avoiding potential memory corruption.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@undivisible

Copy link
Copy Markdown
Contributor Author

Duplicate of #18 (calloc overflow guard). #18 is the superset and is merged to main.

@undivisible

Copy link
Copy Markdown
Contributor Author

Closing as obsolete. Duplicate of #18 (calloc overflow guard). #18 is the superset and is merged to main.

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