* [PATCH] kexec_file: Adjust type of kexec_purgatory
@ 2017-05-09 23:06 ` Kees Cook
0 siblings, 0 replies; 10+ messages in thread
From: Kees Cook @ 2017-05-09 23:06 UTC (permalink / raw)
To: linux-kernel; +Cc: Eric Biederman, kexec, Daniel Micay
Defining kexec_purgatory as a zero-length char array upsets compile
time size checking. Since this is entirely runtime sized, switch
this to void *. This silences the warning generated by the future
CONFIG_FORTIFY_SOURCE, which did not like the memcmp() of a "0 byte"
array.
Cc: Daniel Micay <danielmicay@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
kernel/kexec_file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index b118735fea9d..bc86f85f1329 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -30,7 +30,7 @@
* Declare these symbols weak so that if architecture provides a purgatory,
* these will be overridden.
*/
-char __weak kexec_purgatory[0];
+void * __weak kexec_purgatory;
size_t __weak kexec_purgatory_size = 0;
static int kexec_calculate_store_digests(struct kimage *image);
--
2.7.4
--
Kees Cook
Pixel Security
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] kexec_file: Adjust type of kexec_purgatory
@ 2017-05-09 23:06 ` Kees Cook
0 siblings, 0 replies; 10+ messages in thread
From: Kees Cook @ 2017-05-09 23:06 UTC (permalink / raw)
To: linux-kernel; +Cc: Daniel Micay, kexec, Eric Biederman
Defining kexec_purgatory as a zero-length char array upsets compile
time size checking. Since this is entirely runtime sized, switch
this to void *. This silences the warning generated by the future
CONFIG_FORTIFY_SOURCE, which did not like the memcmp() of a "0 byte"
array.
Cc: Daniel Micay <danielmicay@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
kernel/kexec_file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index b118735fea9d..bc86f85f1329 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -30,7 +30,7 @@
* Declare these symbols weak so that if architecture provides a purgatory,
* these will be overridden.
*/
-char __weak kexec_purgatory[0];
+void * __weak kexec_purgatory;
size_t __weak kexec_purgatory_size = 0;
static int kexec_calculate_store_digests(struct kimage *image);
--
2.7.4
--
Kees Cook
Pixel Security
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] kexec_file: Adjust type of kexec_purgatory
2017-05-09 23:06 ` Kees Cook
@ 2017-05-09 23:13 ` Daniel Micay
-1 siblings, 0 replies; 10+ messages in thread
From: Daniel Micay @ 2017-05-09 23:13 UTC (permalink / raw)
To: Kees Cook, linux-kernel; +Cc: Eric Biederman, kexec
On Tue, 2017-05-09 at 16:06 -0700, Kees Cook wrote:
> Defining kexec_purgatory as a zero-length char array upsets compile
> time size checking. Since this is entirely runtime sized, switch
> this to void *. This silences the warning generated by the future
> CONFIG_FORTIFY_SOURCE, which did not like the memcmp() of a "0 byte"
> array.
>
> Cc: Daniel Micay <danielmicay@gmail.com>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> kernel/kexec_file.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
> index b118735fea9d..bc86f85f1329 100644
> --- a/kernel/kexec_file.c
> +++ b/kernel/kexec_file.c
> @@ -30,7 +30,7 @@
> * Declare these symbols weak so that if architecture provides a
> purgatory,
> * these will be overridden.
> */
> -char __weak kexec_purgatory[0];
> +void * __weak kexec_purgatory;
> size_t __weak kexec_purgatory_size = 0;
>
> static int kexec_calculate_store_digests(struct kimage *image);
> --
> 2.7.4
It seems more correct to use char `char __weak kexec_purgatory[]`,
otherwise isn't __builtin_object_size ending up as 8, which is still
wrong?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] kexec_file: Adjust type of kexec_purgatory
@ 2017-05-09 23:13 ` Daniel Micay
0 siblings, 0 replies; 10+ messages in thread
From: Daniel Micay @ 2017-05-09 23:13 UTC (permalink / raw)
To: Kees Cook, linux-kernel; +Cc: kexec, Eric Biederman
On Tue, 2017-05-09 at 16:06 -0700, Kees Cook wrote:
> Defining kexec_purgatory as a zero-length char array upsets compile
> time size checking. Since this is entirely runtime sized, switch
> this to void *. This silences the warning generated by the future
> CONFIG_FORTIFY_SOURCE, which did not like the memcmp() of a "0 byte"
> array.
>
> Cc: Daniel Micay <danielmicay@gmail.com>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> kernel/kexec_file.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
> index b118735fea9d..bc86f85f1329 100644
> --- a/kernel/kexec_file.c
> +++ b/kernel/kexec_file.c
> @@ -30,7 +30,7 @@
> * Declare these symbols weak so that if architecture provides a
> purgatory,
> * these will be overridden.
> */
> -char __weak kexec_purgatory[0];
> +void * __weak kexec_purgatory;
> size_t __weak kexec_purgatory_size = 0;
>
> static int kexec_calculate_store_digests(struct kimage *image);
> --
> 2.7.4
It seems more correct to use char `char __weak kexec_purgatory[]`,
otherwise isn't __builtin_object_size ending up as 8, which is still
wrong?
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] kexec_file: Adjust type of kexec_purgatory
2017-05-09 23:13 ` Daniel Micay
@ 2017-05-09 23:22 ` Kees Cook
-1 siblings, 0 replies; 10+ messages in thread
From: Kees Cook @ 2017-05-09 23:22 UTC (permalink / raw)
To: Daniel Micay; +Cc: LKML, Eric Biederman, Kexec Mailing List
On Tue, May 9, 2017 at 4:13 PM, Daniel Micay <danielmicay@gmail.com> wrote:
> On Tue, 2017-05-09 at 16:06 -0700, Kees Cook wrote:
>> Defining kexec_purgatory as a zero-length char array upsets compile
>> time size checking. Since this is entirely runtime sized, switch
>> this to void *. This silences the warning generated by the future
>> CONFIG_FORTIFY_SOURCE, which did not like the memcmp() of a "0 byte"
>> array.
>>
>> Cc: Daniel Micay <danielmicay@gmail.com>
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> ---
>> kernel/kexec_file.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
>> index b118735fea9d..bc86f85f1329 100644
>> --- a/kernel/kexec_file.c
>> +++ b/kernel/kexec_file.c
>> @@ -30,7 +30,7 @@
>> * Declare these symbols weak so that if architecture provides a
>> purgatory,
>> * these will be overridden.
>> */
>> -char __weak kexec_purgatory[0];
>> +void * __weak kexec_purgatory;
>> size_t __weak kexec_purgatory_size = 0;
>>
>> static int kexec_calculate_store_digests(struct kimage *image);
>> --
>> 2.7.4
>
> It seems more correct to use char `char __weak kexec_purgatory[]`,
> otherwise isn't __builtin_object_size ending up as 8, which is still
> wrong?
I tried [], that was my instinct, too, but since this is a __weak and
not an extern, that doesn't work:
kernel/kexec_file.c:33:13: warning: array ‘kexec_purgatory’ assumed to
have one element
char __weak kexec_purgatory[];
^~~~~~~~~~~~~~~
-Kees
--
Kees Cook
Pixel Security
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] kexec_file: Adjust type of kexec_purgatory
@ 2017-05-09 23:22 ` Kees Cook
0 siblings, 0 replies; 10+ messages in thread
From: Kees Cook @ 2017-05-09 23:22 UTC (permalink / raw)
To: Daniel Micay; +Cc: Kexec Mailing List, LKML, Eric Biederman
On Tue, May 9, 2017 at 4:13 PM, Daniel Micay <danielmicay@gmail.com> wrote:
> On Tue, 2017-05-09 at 16:06 -0700, Kees Cook wrote:
>> Defining kexec_purgatory as a zero-length char array upsets compile
>> time size checking. Since this is entirely runtime sized, switch
>> this to void *. This silences the warning generated by the future
>> CONFIG_FORTIFY_SOURCE, which did not like the memcmp() of a "0 byte"
>> array.
>>
>> Cc: Daniel Micay <danielmicay@gmail.com>
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> ---
>> kernel/kexec_file.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
>> index b118735fea9d..bc86f85f1329 100644
>> --- a/kernel/kexec_file.c
>> +++ b/kernel/kexec_file.c
>> @@ -30,7 +30,7 @@
>> * Declare these symbols weak so that if architecture provides a
>> purgatory,
>> * these will be overridden.
>> */
>> -char __weak kexec_purgatory[0];
>> +void * __weak kexec_purgatory;
>> size_t __weak kexec_purgatory_size = 0;
>>
>> static int kexec_calculate_store_digests(struct kimage *image);
>> --
>> 2.7.4
>
> It seems more correct to use char `char __weak kexec_purgatory[]`,
> otherwise isn't __builtin_object_size ending up as 8, which is still
> wrong?
I tried [], that was my instinct, too, but since this is a __weak and
not an extern, that doesn't work:
kernel/kexec_file.c:33:13: warning: array ‘kexec_purgatory’ assumed to
have one element
char __weak kexec_purgatory[];
^~~~~~~~~~~~~~~
-Kees
--
Kees Cook
Pixel Security
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] kexec_file: Adjust type of kexec_purgatory
2017-05-09 23:22 ` Kees Cook
@ 2017-05-10 0:15 ` Eric W. Biederman
-1 siblings, 0 replies; 10+ messages in thread
From: Eric W. Biederman @ 2017-05-10 0:15 UTC (permalink / raw)
To: Kees Cook; +Cc: Daniel Micay, LKML, Kexec Mailing List
Kees Cook <keescook@chromium.org> writes:
> On Tue, May 9, 2017 at 4:13 PM, Daniel Micay <danielmicay@gmail.com> wrote:
>> On Tue, 2017-05-09 at 16:06 -0700, Kees Cook wrote:
>>> Defining kexec_purgatory as a zero-length char array upsets compile
>>> time size checking. Since this is entirely runtime sized, switch
>>> this to void *. This silences the warning generated by the future
>>> CONFIG_FORTIFY_SOURCE, which did not like the memcmp() of a "0 byte"
>>> array.
>>>
>>> Cc: Daniel Micay <danielmicay@gmail.com>
>>> Signed-off-by: Kees Cook <keescook@chromium.org>
>>> ---
>>> kernel/kexec_file.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
>>> index b118735fea9d..bc86f85f1329 100644
>>> --- a/kernel/kexec_file.c
>>> +++ b/kernel/kexec_file.c
>>> @@ -30,7 +30,7 @@
>>> * Declare these symbols weak so that if architecture provides a
>>> purgatory,
>>> * these will be overridden.
>>> */
>>> -char __weak kexec_purgatory[0];
>>> +void * __weak kexec_purgatory;
>>> size_t __weak kexec_purgatory_size = 0;
>>>
>>> static int kexec_calculate_store_digests(struct kimage *image);
>>> --
>>> 2.7.4
>>
>> It seems more correct to use char `char __weak kexec_purgatory[]`,
>> otherwise isn't __builtin_object_size ending up as 8, which is still
>> wrong?
>
> I tried [], that was my instinct, too, but since this is a __weak and
> not an extern, that doesn't work:
>
> kernel/kexec_file.c:33:13: warning: array ‘kexec_purgatory’ assumed to
> have one element
> char __weak kexec_purgatory[];
> ^~~~~~~~~~~~~~~
Nor does "void *kexec_purgatory" as that says at the address known as
kexec_purgatory is a void pointer not a blob a bytes that can be used
for something interesting.
Better to get rid of the __weak and deal with that fallout.
Eric
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] kexec_file: Adjust type of kexec_purgatory
@ 2017-05-10 0:15 ` Eric W. Biederman
0 siblings, 0 replies; 10+ messages in thread
From: Eric W. Biederman @ 2017-05-10 0:15 UTC (permalink / raw)
To: Kees Cook; +Cc: Daniel Micay, Kexec Mailing List, LKML
Kees Cook <keescook@chromium.org> writes:
> On Tue, May 9, 2017 at 4:13 PM, Daniel Micay <danielmicay@gmail.com> wrote:
>> On Tue, 2017-05-09 at 16:06 -0700, Kees Cook wrote:
>>> Defining kexec_purgatory as a zero-length char array upsets compile
>>> time size checking. Since this is entirely runtime sized, switch
>>> this to void *. This silences the warning generated by the future
>>> CONFIG_FORTIFY_SOURCE, which did not like the memcmp() of a "0 byte"
>>> array.
>>>
>>> Cc: Daniel Micay <danielmicay@gmail.com>
>>> Signed-off-by: Kees Cook <keescook@chromium.org>
>>> ---
>>> kernel/kexec_file.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
>>> index b118735fea9d..bc86f85f1329 100644
>>> --- a/kernel/kexec_file.c
>>> +++ b/kernel/kexec_file.c
>>> @@ -30,7 +30,7 @@
>>> * Declare these symbols weak so that if architecture provides a
>>> purgatory,
>>> * these will be overridden.
>>> */
>>> -char __weak kexec_purgatory[0];
>>> +void * __weak kexec_purgatory;
>>> size_t __weak kexec_purgatory_size = 0;
>>>
>>> static int kexec_calculate_store_digests(struct kimage *image);
>>> --
>>> 2.7.4
>>
>> It seems more correct to use char `char __weak kexec_purgatory[]`,
>> otherwise isn't __builtin_object_size ending up as 8, which is still
>> wrong?
>
> I tried [], that was my instinct, too, but since this is a __weak and
> not an extern, that doesn't work:
>
> kernel/kexec_file.c:33:13: warning: array ‘kexec_purgatory’ assumed to
> have one element
> char __weak kexec_purgatory[];
> ^~~~~~~~~~~~~~~
Nor does "void *kexec_purgatory" as that says at the address known as
kexec_purgatory is a void pointer not a blob a bytes that can be used
for something interesting.
Better to get rid of the __weak and deal with that fallout.
Eric
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] kexec_file: Adjust type of kexec_purgatory
2017-05-10 0:15 ` Eric W. Biederman
@ 2017-05-10 19:54 ` Kees Cook
-1 siblings, 0 replies; 10+ messages in thread
From: Kees Cook @ 2017-05-10 19:54 UTC (permalink / raw)
To: Eric W. Biederman; +Cc: Daniel Micay, LKML, Kexec Mailing List
On Tue, May 9, 2017 at 5:15 PM, Eric W. Biederman <ebiederm@xmission.com> wrote:
> Kees Cook <keescook@chromium.org> writes:
>> kernel/kexec_file.c:33:13: warning: array ‘kexec_purgatory’ assumed to
>> have one element
>> char __weak kexec_purgatory[];
>> ^~~~~~~~~~~~~~~
>
> Nor does "void *kexec_purgatory" as that says at the address known as
> kexec_purgatory is a void pointer not a blob a bytes that can be used
> for something interesting.
>
> Better to get rid of the __weak and deal with that fallout.
Agreed. This is actually pretty easy, since only x86 and PPC use
kexec_file, and both define purgatories. I'll send an updated patch.
Thanks!
-Kees
--
Kees Cook
Pixel Security
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] kexec_file: Adjust type of kexec_purgatory
@ 2017-05-10 19:54 ` Kees Cook
0 siblings, 0 replies; 10+ messages in thread
From: Kees Cook @ 2017-05-10 19:54 UTC (permalink / raw)
To: Eric W. Biederman; +Cc: Daniel Micay, Kexec Mailing List, LKML
On Tue, May 9, 2017 at 5:15 PM, Eric W. Biederman <ebiederm@xmission.com> wrote:
> Kees Cook <keescook@chromium.org> writes:
>> kernel/kexec_file.c:33:13: warning: array ‘kexec_purgatory’ assumed to
>> have one element
>> char __weak kexec_purgatory[];
>> ^~~~~~~~~~~~~~~
>
> Nor does "void *kexec_purgatory" as that says at the address known as
> kexec_purgatory is a void pointer not a blob a bytes that can be used
> for something interesting.
>
> Better to get rid of the __weak and deal with that fallout.
Agreed. This is actually pretty easy, since only x86 and PPC use
kexec_file, and both define purgatories. I'll send an updated patch.
Thanks!
-Kees
--
Kees Cook
Pixel Security
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-05-10 19:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-09 23:06 [PATCH] kexec_file: Adjust type of kexec_purgatory Kees Cook
2017-05-09 23:06 ` Kees Cook
2017-05-09 23:13 ` Daniel Micay
2017-05-09 23:13 ` Daniel Micay
2017-05-09 23:22 ` Kees Cook
2017-05-09 23:22 ` Kees Cook
2017-05-10 0:15 ` Eric W. Biederman
2017-05-10 0:15 ` Eric W. Biederman
2017-05-10 19:54 ` Kees Cook
2017-05-10 19:54 ` Kees Cook
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.