Skip to content

networkd: fix integer overflow in prefix assignment - #9592

Closed
Gigadoc2 wants to merge 1 commit into
systemd:masterfrom
Gigadoc2:fix/networkd-pd-integer-overflow
Closed

Gigadoc2 wants to merge 1 commit into
systemd:masterfrom
Gigadoc2:fix/networkd-pd-integer-overflow

Conversation

@Gigadoc2

@Gigadoc2 Gigadoc2 commented Jul 16, 2018 •

Copy link
Copy Markdown
Contributor

When receiving a prefix with size /56, networkd can assign 256 /64 prefixes from that. That value causes the uint8 "n_prefixes" to overflow. Though an extreme example, there could be someone using Prefix Delegation with a /18 from ULA space, which would even overflow an uint32, so uint64 would be the safe choice.

This was also reported in #9591, but I've changed uint32 to uint64 because of the above reasoning.

There are possibly more bugs in the PD code, such as improperly calculating the next prefix and errors when blackholing the unused prefixes, but they require more research and should probably be separate issues/MRs.

When receiving a prefix with size /56, networkd can assing 256 /64
prefixes from that. That value causes the uint8 "n_prefixes" to
overflow. Though an extreme example, there could be someone using Prefix
Delegation with a /18 from ULA space, which would even overflow an
uint32, so uint64 would be the safe choice.
@Gigadoc2

Copy link
Copy Markdown
Contributor Author

Seems like I only tested with uint32, not uint64, which broke the printfs. Sorry about that.

@Gigadoc2

Copy link
Copy Markdown
Contributor Author

OK, seems like this fix is not nearly as trivial as i thought. As I have absolutely no experience with real programming I don't feel capable of increasing the integer size while maintaining portability, so I'm closing this, instead adding my thoughts to #9591. Sorry for the noise.

@Gigadoc2 Gigadoc2 closed this Jul 16, 2018
@Gigadoc2
Gigadoc2 deleted the fix/networkd-pd-integer-overflow branch July 17, 2018 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant