Skip to content

Conversation

@saifuddin-xilinx
Copy link
Contributor

No description provided.

Signed-off-by: Saifuddin Kaijar <[email protected]>
Copilot AI review requested due to automatic review settings January 15, 2026 20:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an integer overflow vulnerability in the AMD XDNA driver's buffer object (BO) creation function by adding input validation for the size parameter before it undergoes page alignment.

Changes:

  • Added validation to reject zero-size BO creation requests
  • Added overflow check to prevent integer overflow when PAGE_ALIGN is applied to the size parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1020 to +1027
if (args->size == 0) {
XDNA_ERR(xdna, "Invalid zero size for BO creation");
return -EINVAL;
}
if (args->size > SIZE_MAX - (PAGE_SIZE - 1)) {
XDNA_ERR(xdna, "Size 0x%llx would overflow PAGE_ALIGN", args->size);
return -EINVAL;
}
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two validation checks could be combined into a single conditional statement to reduce code duplication and improve readability. Consider using a single if statement that checks both conditions with an OR operator, or extract the validation logic into a helper function if this pattern is reused elsewhere in the codebase.

Suggested change
if (args->size == 0) {
XDNA_ERR(xdna, "Invalid zero size for BO creation");
return -EINVAL;
}
if (args->size > SIZE_MAX - (PAGE_SIZE - 1)) {
XDNA_ERR(xdna, "Size 0x%llx would overflow PAGE_ALIGN", args->size);
return -EINVAL;
}
if (args->size == 0 || args->size > SIZE_MAX - (PAGE_SIZE - 1)) {
if (args->size == 0)
XDNA_ERR(xdna, "Invalid zero size for BO creation");
else
XDNA_ERR(xdna, "Size 0x%llx would overflow PAGE_ALIGN", args->size);
return -EINVAL;
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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