Skip to content

Commit

Permalink
rcar-gen3: plat: BL2: fix Incorrect Address Range Calculation
Browse files Browse the repository at this point in the history
Check against all address overlap cases

Reviewed-by: Tomer Fichman <Tomer.Fichman@cymotive.com>
Signed-off-by: Yoshifumi Hosoya <yoshifumi.hosoya.wj@renesas.com>
  • Loading branch information
hosoya committed Apr 28, 2023
1 parent b5cd031 commit 954d488
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions drivers/renesas/common/io/io_rcar.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,18 @@ static int32_t check_load_area(uintptr_t dst, uintptr_t len)
* 2. check:
* | IMAGE n |
* | IMAGE n+1 |
* 3. check:
* | IMAGE n |
* | IMAGE n+1 |
*
* */
if (((dst > addr_loaded[n].dest) &&
(dst < addr_loaded[n].dest + addr_loaded[n].length)) ||
(((dst < addr_loaded[n].dest) &&
(dst + len)) > addr_loaded[n].dest)) {
ERROR("BL2: image is inside a previous image area.\n");
if (((dst >= addr_loaded[n].dest) &&
(dst <= addr_loaded[n].dest + addr_loaded[n].length)) ||
((dst + len >= addr_loaded[n].dest) &&
(dst + len <= addr_loaded[n].dest + addr_loaded[n].length)) ||
((dst <= addr_loaded[n].dest) &&
(dst + len >= addr_loaded[n].dest + addr_loaded[n].length))) {
ERROR("BL2: next image overlap a previous image area.\n");
result = IO_FAIL;
}
}
Expand Down

0 comments on commit 954d488

Please sign in to comment.