* [PATCH v2] kexec_file: Adjust declaration of kexec_purgatory
@ 2017-05-10 20:02 Kees Cook
2017-05-10 20:08 ` Eric W. Biederman
0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2017-05-10 20:02 UTC (permalink / raw)
To: Eric Biederman; +Cc: kexec, Daniel Micay, linux-kernel
Defining kexec_purgatory as a zero-length char array upsets compile
time size checking. Since this is built on a per-arch basis, define
it as an unsized char array (like is done for other similar things,
e.g. linker sections). This silences the warning generated by the future
CONFIG_FORTIFY_SOURCE, which did not like the memcmp() of a "0 byte"
array. This drops the __weak and uses an extern instead, since both
users define kexec_purgatory.
Cc: Daniel Micay <danielmicay@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
v2: use extern instead of __weak void *; ebiederm
---
kernel/kexec_file.c | 7 -------
kernel/kexec_internal.h | 2 ++
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index b118735fea9d..7a147a7add2e 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -26,13 +26,6 @@
#include <linux/vmalloc.h>
#include "kexec_internal.h"
-/*
- * Declare these symbols weak so that if architecture provides a purgatory,
- * these will be overridden.
- */
-char __weak kexec_purgatory[0];
-size_t __weak kexec_purgatory_size = 0;
-
static int kexec_calculate_store_digests(struct kimage *image);
/* Architectures can provide this probe function */
diff --git a/kernel/kexec_internal.h b/kernel/kexec_internal.h
index 799a8a452187..50dfcb039a41 100644
--- a/kernel/kexec_internal.h
+++ b/kernel/kexec_internal.h
@@ -17,6 +17,8 @@ extern struct mutex kexec_mutex;
#ifdef CONFIG_KEXEC_FILE
#include <linux/purgatory.h>
void kimage_file_post_load_cleanup(struct kimage *image);
+extern char kexec_purgatory[];
+extern size_t kexec_purgatory_size;
#else /* CONFIG_KEXEC_FILE */
static inline void kimage_file_post_load_cleanup(struct kimage *image) { }
#endif /* CONFIG_KEXEC_FILE */
--
2.7.4
--
Kees Cook
Pixel Security
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] kexec_file: Adjust declaration of kexec_purgatory
2017-05-10 20:02 [PATCH v2] kexec_file: Adjust declaration of kexec_purgatory Kees Cook
@ 2017-05-10 20:08 ` Eric W. Biederman
0 siblings, 0 replies; 2+ messages in thread
From: Eric W. Biederman @ 2017-05-10 20:08 UTC (permalink / raw)
To: Kees Cook; +Cc: kexec, Daniel Micay, linux-kernel
Kees Cook <keescook@chromium.org> writes:
> Defining kexec_purgatory as a zero-length char array upsets compile
> time size checking. Since this is built on a per-arch basis, define
> it as an unsized char array (like is done for other similar things,
> e.g. linker sections). This silences the warning generated by the future
> CONFIG_FORTIFY_SOURCE, which did not like the memcmp() of a "0 byte"
> array. This drops the __weak and uses an extern instead, since both
> users define kexec_purgatory.
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
> Cc: Daniel Micay <danielmicay@gmail.com>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> v2: use extern instead of __weak void *; ebiederm
> ---
> kernel/kexec_file.c | 7 -------
> kernel/kexec_internal.h | 2 ++
> 2 files changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
> index b118735fea9d..7a147a7add2e 100644
> --- a/kernel/kexec_file.c
> +++ b/kernel/kexec_file.c
> @@ -26,13 +26,6 @@
> #include <linux/vmalloc.h>
> #include "kexec_internal.h"
>
> -/*
> - * Declare these symbols weak so that if architecture provides a purgatory,
> - * these will be overridden.
> - */
> -char __weak kexec_purgatory[0];
> -size_t __weak kexec_purgatory_size = 0;
> -
> static int kexec_calculate_store_digests(struct kimage *image);
>
> /* Architectures can provide this probe function */
> diff --git a/kernel/kexec_internal.h b/kernel/kexec_internal.h
> index 799a8a452187..50dfcb039a41 100644
> --- a/kernel/kexec_internal.h
> +++ b/kernel/kexec_internal.h
> @@ -17,6 +17,8 @@ extern struct mutex kexec_mutex;
> #ifdef CONFIG_KEXEC_FILE
> #include <linux/purgatory.h>
> void kimage_file_post_load_cleanup(struct kimage *image);
> +extern char kexec_purgatory[];
> +extern size_t kexec_purgatory_size;
> #else /* CONFIG_KEXEC_FILE */
> static inline void kimage_file_post_load_cleanup(struct kimage *image) { }
> #endif /* CONFIG_KEXEC_FILE */
> --
> 2.7.4
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-10 20:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-10 20:02 [PATCH v2] kexec_file: Adjust declaration of kexec_purgatory Kees Cook
2017-05-10 20:08 ` Eric W. Biederman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox