* [PATCH] arm64: change to use memmove in efi-stub @ 2015-10-16 10:46 yalin wang 2015-10-16 10:57 ` Mark Rutland 0 siblings, 1 reply; 3+ messages in thread From: yalin wang @ 2015-10-16 10:46 UTC (permalink / raw) To: linux-arm-kernel Change to use memmove(), in case the dest address overlap with the source address. Signed-off-by: yalin wang <yalin.wang2010@gmail.com> --- arch/arm64/kernel/efi-stub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c index 816120e..b6dc44b 100644 --- a/arch/arm64/kernel/efi-stub.c +++ b/arch/arm64/kernel/efi-stub.c @@ -59,7 +59,7 @@ efi_status_t __init handle_kernel_image(efi_system_table_t *sys_table_arg, } *image_addr = *reserve_addr + TEXT_OFFSET; } - memcpy((void *)*image_addr, old_image_addr, kernel_size); + memmove((void *)*image_addr, old_image_addr, kernel_size); *reserve_size = kernel_memsize; } -- 1.9.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] arm64: change to use memmove in efi-stub 2015-10-16 10:46 [PATCH] arm64: change to use memmove in efi-stub yalin wang @ 2015-10-16 10:57 ` Mark Rutland 2015-10-19 2:11 ` yalin wang 0 siblings, 1 reply; 3+ messages in thread From: Mark Rutland @ 2015-10-16 10:57 UTC (permalink / raw) To: linux-arm-kernel Hi, On Fri, Oct 16, 2015 at 06:46:07PM +0800, yalin wang wrote: > Change to use memmove(), in case the dest address overlap with the > source address. This cannot happen, and memove would not be sufficient if it did. The destination is a region returned by EFI_BOOT_SERVICES.AllocatePages, which can only allocate pages which were free to begin with. Therefore the new region cannot overlap with the stub (whose pages are not free). Were the new region to overlap with the stub, the memmove could corrupt the code/data in use by the stub, and things would explode shortly thereafter. Thanks, Mark. > > Signed-off-by: yalin wang <yalin.wang2010@gmail.com> > --- > arch/arm64/kernel/efi-stub.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c > index 816120e..b6dc44b 100644 > --- a/arch/arm64/kernel/efi-stub.c > +++ b/arch/arm64/kernel/efi-stub.c > @@ -59,7 +59,7 @@ efi_status_t __init handle_kernel_image(efi_system_table_t *sys_table_arg, > } > *image_addr = *reserve_addr + TEXT_OFFSET; > } > - memcpy((void *)*image_addr, old_image_addr, kernel_size); > + memmove((void *)*image_addr, old_image_addr, kernel_size); > *reserve_size = kernel_memsize; > } > > -- > 1.9.1 > ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] arm64: change to use memmove in efi-stub 2015-10-16 10:57 ` Mark Rutland @ 2015-10-19 2:11 ` yalin wang 0 siblings, 0 replies; 3+ messages in thread From: yalin wang @ 2015-10-19 2:11 UTC (permalink / raw) To: linux-arm-kernel Got it , Thanks for your explanation . > On Oct 16, 2015, at 18:57, Mark Rutland <mark.rutland@arm.com> wrote: > > Hi, > > On Fri, Oct 16, 2015 at 06:46:07PM +0800, yalin wang wrote: >> Change to use memmove(), in case the dest address overlap with the >> source address. > > This cannot happen, and memove would not be sufficient if it did. > > The destination is a region returned by EFI_BOOT_SERVICES.AllocatePages, > which can only allocate pages which were free to begin with. Therefore > the new region cannot overlap with the stub (whose pages are not free). > > Were the new region to overlap with the stub, the memmove could corrupt > the code/data in use by the stub, and things would explode shortly > thereafter. > > Thanks, > Mark. > >> >> Signed-off-by: yalin wang <yalin.wang2010@gmail.com> >> --- >> arch/arm64/kernel/efi-stub.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c >> index 816120e..b6dc44b 100644 >> --- a/arch/arm64/kernel/efi-stub.c >> +++ b/arch/arm64/kernel/efi-stub.c >> @@ -59,7 +59,7 @@ efi_status_t __init handle_kernel_image(efi_system_table_t *sys_table_arg, >> } >> *image_addr = *reserve_addr + TEXT_OFFSET; >> } >> - memcpy((void *)*image_addr, old_image_addr, kernel_size); >> + memmove((void *)*image_addr, old_image_addr, kernel_size); >> *reserve_size = kernel_memsize; >> } >> >> -- >> 1.9.1 >> ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-19 2:11 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-10-16 10:46 [PATCH] arm64: change to use memmove in efi-stub yalin wang 2015-10-16 10:57 ` Mark Rutland 2015-10-19 2:11 ` yalin wang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox