Skip to content

Conversation

@gsserge
Copy link

@gsserge gsserge commented Oct 18, 2021

Add a check to make sure than node depth does not
exceed FDT_MAX_NODE_DEPTH.

Signed-off-by: Sergii Glushchenko gsserge@amazon.com

Add a check to make sure than node depth does not
exceed usize::MAX.

Signed-off-by: Sergii Glushchenko <gsserge@amazon.com>
@gsserge
Copy link
Author

gsserge commented Oct 18, 2021

I'm using 'if' block instead of usize::checked_add to keep the style compatible with FdtWriter::end_node; please let me know if checked_add is preferred.

@gsserge gsserge marked this pull request as draft October 18, 2021 14:20
danielverkamp
danielverkamp previously approved these changes Oct 18, 2021
Copy link
Collaborator

@danielverkamp danielverkamp left a comment

Choose a reason for hiding this comment

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

This style of check looks fine to me; thanks for adding the comment explaining it at the addition as well.

Signed-off-by: Sergii Glushchenko <gsserge@amazon.com>
@gsserge gsserge marked this pull request as ready for review October 19, 2021 11:37
Signed-off-by: Sergii Glushchenko <gsserge@amazon.com>
const FDT_HEADER_SIZE: usize = 40;
const FDT_VERSION: u32 = 17;
const FDT_LAST_COMP_VERSION: u32 = 16;
/// The same max depth as in the Linux kernel.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this should be part of the previous commit.

@andreeaflorescu andreeaflorescu merged commit bb53be4 into rust-vmm:main Oct 19, 2021
@gsserge gsserge deleted the depth_overflow branch October 19, 2021 12:54
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.

4 participants