Skip to content
Permalink
Browse files

core: get_elf_segments(): use memmove on overlapping memory

get_elf_segments() final stage aggregates ELF segments. In the while
loop, the logic to remove the current index is to use memcpy() to shift
down everything beyond that point. This is incorrect; memmove() should
be used instead.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reported-by: Bastien Simondi <bsimondi@netflix.com> [2.8]
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
  • Loading branch information...
jforissier committed Feb 5, 2019
1 parent b17e2e4 commit 3bcb882f200c2dd14ea1937031d5bd97bf6a78ca
Showing with 2 additions and 2 deletions.
  1. +2 −2 core/arch/arm/kernel/user_ta.c
@@ -178,8 +178,8 @@ static TEE_Result get_elf_segments(struct user_ta_elf *elf,
segs[idx - 1].flags |= segs[idx].flags;

/* Remove this index */
memcpy(segs + idx, segs + idx + 1,
(num_segs - idx - 1) * sizeof(*segs));
memmove(segs + idx, segs + idx + 1,
(num_segs - idx - 1) * sizeof(*segs));
num_segs--;
} else {
idx++;

0 comments on commit 3bcb882

Please sign in to comment.
You can’t perform that action at this time.