* [PATCH] x86/power/64: Use char arrays for asm function names
@ 2017-05-09 21:00 Kees Cook
2017-05-09 21:18 ` Rafael J. Wysocki
2017-05-11 20:13 ` Pavel Machek
0 siblings, 2 replies; 4+ messages in thread
From: Kees Cook @ 2017-05-09 21:00 UTC (permalink / raw)
To: linux-kernel
Cc: Rafael J. Wysocki, Pavel Machek, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, x86, linux-pm, Daniel Micay
This switches the hibernate_64.S function names into character arrays
to match other areas of the kernel where this is done (e.g., linker
scripts). Specifically this fixes a compile-time error noticed by the
future CONFIG_FORTIFY_SOURCE routines that complained about PAGE_SIZE
being copied out of the "single byte" core_restore_code variable.
Additionally drops the "acpi_save_state_mem" exern which does not
appear to be used anywhere else in the kernel.
Cc: Daniel Micay <danielmicay@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
arch/x86/include/asm/suspend_64.h | 5 ++---
arch/x86/power/hibernate_64.c | 6 +++---
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/arch/x86/include/asm/suspend_64.h b/arch/x86/include/asm/suspend_64.h
index 6136a18152af..2bd96b4df140 100644
--- a/arch/x86/include/asm/suspend_64.h
+++ b/arch/x86/include/asm/suspend_64.h
@@ -42,8 +42,7 @@ struct saved_context {
set_debugreg((thread)->debugreg##register, register)
/* routines for saving/restoring kernel state */
-extern int acpi_save_state_mem(void);
-extern char core_restore_code;
-extern char restore_registers;
+extern char core_restore_code[];
+extern char restore_registers[];
#endif /* _ASM_X86_SUSPEND_64_H */
diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c
index 6a61194ffd58..2cc419990ab7 100644
--- a/arch/x86/power/hibernate_64.c
+++ b/arch/x86/power/hibernate_64.c
@@ -147,7 +147,7 @@ static int relocate_restore_code(void)
if (!relocated_restore_code)
return -ENOMEM;
- memcpy((void *)relocated_restore_code, &core_restore_code, PAGE_SIZE);
+ memcpy((void *)relocated_restore_code, core_restore_code, PAGE_SIZE);
/* Make the page containing the relocated code executable */
pgd = (pgd_t *)__va(read_cr3()) + pgd_index(relocated_restore_code);
@@ -292,8 +292,8 @@ int arch_hibernation_header_save(void *addr, unsigned int max_size)
if (max_size < sizeof(struct restore_data_record))
return -EOVERFLOW;
- rdr->jump_address = (unsigned long)&restore_registers;
- rdr->jump_address_phys = __pa_symbol(&restore_registers);
+ rdr->jump_address = (unsigned long)restore_registers;
+ rdr->jump_address_phys = __pa_symbol(restore_registers);
rdr->cr3 = restore_cr3;
rdr->magic = RESTORE_MAGIC;
--
2.7.4
--
Kees Cook
Pixel Security
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/power/64: Use char arrays for asm function names
2017-05-09 21:00 [PATCH] x86/power/64: Use char arrays for asm function names Kees Cook
@ 2017-05-09 21:18 ` Rafael J. Wysocki
2017-05-10 5:49 ` Ingo Molnar
2017-05-11 20:13 ` Pavel Machek
1 sibling, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2017-05-09 21:18 UTC (permalink / raw)
To: Kees Cook
Cc: linux-kernel, Pavel Machek, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, x86, linux-pm, Daniel Micay
On Tuesday, May 09, 2017 02:00:51 PM Kees Cook wrote:
> This switches the hibernate_64.S function names into character arrays
> to match other areas of the kernel where this is done (e.g., linker
> scripts). Specifically this fixes a compile-time error noticed by the
> future CONFIG_FORTIFY_SOURCE routines that complained about PAGE_SIZE
> being copied out of the "single byte" core_restore_code variable.
>
> Additionally drops the "acpi_save_state_mem" exern which does not
> appear to be used anywhere else in the kernel.
>
> Cc: Daniel Micay <danielmicay@gmail.com>
> Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Or I can queue this up if that's preferred.
> ---
> arch/x86/include/asm/suspend_64.h | 5 ++---
> arch/x86/power/hibernate_64.c | 6 +++---
> 2 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/include/asm/suspend_64.h b/arch/x86/include/asm/suspend_64.h
> index 6136a18152af..2bd96b4df140 100644
> --- a/arch/x86/include/asm/suspend_64.h
> +++ b/arch/x86/include/asm/suspend_64.h
> @@ -42,8 +42,7 @@ struct saved_context {
> set_debugreg((thread)->debugreg##register, register)
>
> /* routines for saving/restoring kernel state */
> -extern int acpi_save_state_mem(void);
> -extern char core_restore_code;
> -extern char restore_registers;
> +extern char core_restore_code[];
> +extern char restore_registers[];
>
> #endif /* _ASM_X86_SUSPEND_64_H */
> diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c
> index 6a61194ffd58..2cc419990ab7 100644
> --- a/arch/x86/power/hibernate_64.c
> +++ b/arch/x86/power/hibernate_64.c
> @@ -147,7 +147,7 @@ static int relocate_restore_code(void)
> if (!relocated_restore_code)
> return -ENOMEM;
>
> - memcpy((void *)relocated_restore_code, &core_restore_code, PAGE_SIZE);
> + memcpy((void *)relocated_restore_code, core_restore_code, PAGE_SIZE);
>
> /* Make the page containing the relocated code executable */
> pgd = (pgd_t *)__va(read_cr3()) + pgd_index(relocated_restore_code);
> @@ -292,8 +292,8 @@ int arch_hibernation_header_save(void *addr, unsigned int max_size)
>
> if (max_size < sizeof(struct restore_data_record))
> return -EOVERFLOW;
> - rdr->jump_address = (unsigned long)&restore_registers;
> - rdr->jump_address_phys = __pa_symbol(&restore_registers);
> + rdr->jump_address = (unsigned long)restore_registers;
> + rdr->jump_address_phys = __pa_symbol(restore_registers);
> rdr->cr3 = restore_cr3;
> rdr->magic = RESTORE_MAGIC;
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/power/64: Use char arrays for asm function names
2017-05-09 21:18 ` Rafael J. Wysocki
@ 2017-05-10 5:49 ` Ingo Molnar
0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2017-05-10 5:49 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Kees Cook, linux-kernel, Pavel Machek, Thomas Gleixner,
Ingo Molnar, H. Peter Anvin, x86, linux-pm, Daniel Micay
* Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> On Tuesday, May 09, 2017 02:00:51 PM Kees Cook wrote:
> > This switches the hibernate_64.S function names into character arrays
> > to match other areas of the kernel where this is done (e.g., linker
> > scripts). Specifically this fixes a compile-time error noticed by the
> > future CONFIG_FORTIFY_SOURCE routines that complained about PAGE_SIZE
> > being copied out of the "single byte" core_restore_code variable.
> >
> > Additionally drops the "acpi_save_state_mem" exern which does not
> > appear to be used anywhere else in the kernel.
> >
> > Cc: Daniel Micay <danielmicay@gmail.com>
> > Signed-off-by: Kees Cook <keescook@chromium.org>
>
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Or I can queue this up if that's preferred.
LGTM too!
Acked-by: Ingo Molnar <mingo@kernel.org>
Thanks,
Ingo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/power/64: Use char arrays for asm function names
2017-05-09 21:00 [PATCH] x86/power/64: Use char arrays for asm function names Kees Cook
2017-05-09 21:18 ` Rafael J. Wysocki
@ 2017-05-11 20:13 ` Pavel Machek
1 sibling, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2017-05-11 20:13 UTC (permalink / raw)
To: Kees Cook
Cc: linux-kernel, Rafael J. Wysocki, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, x86, linux-pm, Daniel Micay
[-- Attachment #1: Type: text/plain, Size: 611 bytes --]
On Tue 2017-05-09 14:00:51, Kees Cook wrote:
> This switches the hibernate_64.S function names into character arrays
> to match other areas of the kernel where this is done (e.g., linker
> scripts). Specifically this fixes a compile-time error noticed by the
> future CONFIG_FORTIFY_SOURCE routines that complained about PAGE_SIZE
> being copied out of the "single byte" core_restore_code variable.
Can we get equivalent fix for suspend_32.h?
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-11 20:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-09 21:00 [PATCH] x86/power/64: Use char arrays for asm function names Kees Cook
2017-05-09 21:18 ` Rafael J. Wysocki
2017-05-10 5:49 ` Ingo Molnar
2017-05-11 20:13 ` Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).