OpenAMP / libmetal

An abstraction layer across RTOS, baremetal, and user-space Linux environments
https://www.openampproject.org/
Other
262 stars 170 forks source link

API to validate address within io block #222

Closed tammyleino closed 1 year ago

tammyleino commented 2 years ago

Ensures the specified address falls within the valid range of the io block Signed-off-by: Tammy Leino tammy_leino@mentor.com

tammyleino commented 2 years ago

PR https://github.com/OpenAMP/open-amp/pull/406 is dependent on this PR.

tammyleino commented 2 years ago

This looks good to me. There may be a case where a false positive can happen (addr + len overflows), but that shouldn't stop this improvement from going in.

@edmooring Thank you very much for your eyes on this. Can you please provide an example of the overflow so I am clear?

edmooring commented 2 years ago

@tammyleino For the overflow, consider the following on a 32-bit architecture: io->virt = 0xffffff00 io->size = 0x80 addr = 0xffffff08 len = 0x100 Unless I have missed something, addr + len will overflow to 0x8 which will pass the test of (addr + len < io->virt + io->size) but still access memory that it shouldn't.