2022-06-29 03:45:32

by GONG, Ruiqi

[permalink] [raw]
Subject: [PATCH] stack: Declare {randomize_,}kstack_offset to fix Sparse warnings

Fix the following Sparse warnings that got noticed when the PPC-dev
patchwork was checking another patch (see the link below):

init/main.c:862:1: warning: symbol 'randomize_kstack_offset' was not declared. Should it be static?
init/main.c:864:1: warning: symbol 'kstack_offset' was not declared. Should it be static?

Which in fact are triggered on all architectures that have
HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET support (for instances x86, arm64
etc).

Link: https://lore.kernel.org/lkml/[email protected]/T/#m49b2d4490121445ce4bf7653500aba59eefcb67f
Cc: Christophe Leroy <[email protected]>
Cc: Xiu Jianfeng <[email protected]>
Signed-off-by: GONG, Ruiqi <[email protected]>
---
init/main.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/init/main.c b/init/main.c
index e2490387db2b..6aa0fb2340cc 100644
--- a/init/main.c
+++ b/init/main.c
@@ -101,6 +101,10 @@
#include <linux/stackdepot.h>
#include <net/net_namespace.h>

+#ifdef CONFIG_RANDOMIZE_KSTACK_OFFSET
+#include <linux/randomize_kstack.h>
+#endif
+
#include <asm/io.h>
#include <asm/bugs.h>
#include <asm/setup.h>
--
2.25.1


2022-06-29 05:24:16

by Christophe Leroy

[permalink] [raw]
Subject: Re: [PATCH] stack: Declare {randomize_,}kstack_offset to fix Sparse warnings



Le 29/06/2022 à 05:29, GONG, Ruiqi a écrit :
> Fix the following Sparse warnings that got noticed when the PPC-dev
> patchwork was checking another patch (see the link below):
>
> init/main.c:862:1: warning: symbol 'randomize_kstack_offset' was not declared. Should it be static?
> init/main.c:864:1: warning: symbol 'kstack_offset' was not declared. Should it be static?
>
> Which in fact are triggered on all architectures that have
> HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET support (for instances x86, arm64
> etc).
>
> Link: https://lore.kernel.org/lkml/[email protected]/T/#m49b2d4490121445ce4bf7653500aba59eefcb67f
> Cc: Christophe Leroy <[email protected]>
> Cc: Xiu Jianfeng <[email protected]>
> Signed-off-by: GONG, Ruiqi <[email protected]>
> ---
> init/main.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/init/main.c b/init/main.c
> index e2490387db2b..6aa0fb2340cc 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -101,6 +101,10 @@
> #include <linux/stackdepot.h>
> #include <net/net_namespace.h>
>
> +#ifdef CONFIG_RANDOMIZE_KSTACK_OFFSET

You don't need this #ifdef, there is already one inside
linux/randomize_kstack.h

> +#include <linux/randomize_kstack.h>
> +#endif
> +
> #include <asm/io.h>
> #include <asm/bugs.h>
> #include <asm/setup.h>
> --
> 2.25.1
>

2022-06-29 05:53:55

by GONG, Ruiqi

[permalink] [raw]
Subject: Re: [PATCH] stack: Declare {randomize_,}kstack_offset to fix Sparse warnings



On 2022/06/29 13:10, Christophe Leroy wrote:
>
>
> Le 29/06/2022 à 05:29, GONG, Ruiqi a écrit :
>> Fix the following Sparse warnings that got noticed when the PPC-dev
>> patchwork was checking another patch (see the link below):
>>
>> init/main.c:862:1: warning: symbol 'randomize_kstack_offset' was not declared. Should it be static?
>> init/main.c:864:1: warning: symbol 'kstack_offset' was not declared. Should it be static?
>>
>> Which in fact are triggered on all architectures that have
>> HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET support (for instances x86, arm64
>> etc).
>>
>> Link: https://lore.kernel.org/lkml/[email protected]/T/#m49b2d4490121445ce4bf7653500aba59eefcb67f
>> Cc: Christophe Leroy <[email protected]>
>> Cc: Xiu Jianfeng <[email protected]>
>> Signed-off-by: GONG, Ruiqi <[email protected]>
>> ---
>> init/main.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/init/main.c b/init/main.c
>> index e2490387db2b..6aa0fb2340cc 100644
>> --- a/init/main.c
>> +++ b/init/main.c
>> @@ -101,6 +101,10 @@
>> #include <linux/stackdepot.h>
>> #include <net/net_namespace.h>
>>
>> +#ifdef CONFIG_RANDOMIZE_KSTACK_OFFSET
>
> You don't need this #ifdef, there is already one inside
> linux/randomize_kstack.h
>

Ah yes, I didn't notice the config was there already. I will send a new
version. Thanks for your reminder!

>> +#include <linux/randomize_kstack.h>
>> +#endif
>> +
>> #include <asm/io.h>
>> #include <asm/bugs.h>
>> #include <asm/setup.h>
>> --
>> 2.25.1