2018-12-10 17:17:32

by WANG Chao

[permalink] [raw]
Subject: [PATCH] treewide: replace RETPOLINE with CONFIG_RETPOLINE

Since commit 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend
on compiler support"), RETPOLINE has been replaced by CONFIG_RETPOLINE.

Fixes: 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
Signed-off-by: WANG Chao <[email protected]>
---
arch/x86/kernel/cpu/bugs.c | 2 +-
include/linux/compiler-gcc.h | 2 +-
include/linux/module.h | 2 +-
scripts/mod/modpost.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 500278f5308e..e8abe3f6c10e 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -213,7 +213,7 @@ static enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init =
static enum spectre_v2_user_mitigation spectre_v2_user __ro_after_init =
SPECTRE_V2_USER_NONE;

-#ifdef RETPOLINE
+#ifdef CONFIG_RETPOLINE
static bool spectre_v2_bad_module;

bool retpoline_module_ok(bool has_retpoline)
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 2010493e1040..977ddf2774f9 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -68,7 +68,7 @@
*/
#define uninitialized_var(x) x = x

-#ifdef RETPOLINE
+#ifdef CONFIG_RETPOLINE
#define __noretpoline __attribute__((__indirect_branch__("keep")))
#endif

diff --git a/include/linux/module.h b/include/linux/module.h
index fce6b4335e36..0c575f51fe57 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -817,7 +817,7 @@ static inline void module_bug_finalize(const Elf_Ehdr *hdr,
static inline void module_bug_cleanup(struct module *mod) {}
#endif /* CONFIG_GENERIC_BUG */

-#ifdef RETPOLINE
+#ifdef CONFIG_RETPOLINE
extern bool retpoline_module_ok(bool has_retpoline);
#else
static inline bool retpoline_module_ok(bool has_retpoline)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0d998c54564d..5a5b3780456f 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2157,7 +2157,7 @@ static void add_intree_flag(struct buffer *b, int is_intree)
/* Cannot check for assembler */
static void add_retpoline(struct buffer *b)
{
- buf_printf(b, "\n#ifdef RETPOLINE\n");
+ buf_printf(b, "\n#ifdef CONFIG_RETPOLINE\n");
buf_printf(b, "MODULE_INFO(retpoline, \"Y\");\n");
buf_printf(b, "#endif\n");
}
--
2.19.2



2018-12-12 08:16:24

by Zhenzhong Duan

[permalink] [raw]
Subject: Re: [PATCH] treewide: replace RETPOLINE with CONFIG_RETPOLINE


On 2018/12/11 0:37, WANG Chao wrote:
> Since commit 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend
> on compiler support"), RETPOLINE has been replaced by CONFIG_RETPOLINE.
>
> Fixes: 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
> Signed-off-by: WANG Chao <[email protected]>
> ---
> arch/x86/kernel/cpu/bugs.c | 2 +-
> include/linux/compiler-gcc.h | 2 +-
> include/linux/module.h | 2 +-
> scripts/mod/modpost.c | 2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> index 500278f5308e..e8abe3f6c10e 100644
> --- a/arch/x86/kernel/cpu/bugs.c
> +++ b/arch/x86/kernel/cpu/bugs.c
> @@ -213,7 +213,7 @@ static enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init =
> static enum spectre_v2_user_mitigation spectre_v2_user __ro_after_init =
> SPECTRE_V2_USER_NONE;
>
> -#ifdef RETPOLINE
> +#ifdef CONFIG_RETPOLINE
> static bool spectre_v2_bad_module;
>
> bool retpoline_module_ok(bool has_retpoline)
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index 2010493e1040..977ddf2774f9 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -68,7 +68,7 @@
> */
> #define uninitialized_var(x) x = x
>
> -#ifdef RETPOLINE
> +#ifdef CONFIG_RETPOLINE
> #define __noretpoline __attribute__((__indirect_branch__("keep")))
> #endif
>
> diff --git a/include/linux/module.h b/include/linux/module.h
> index fce6b4335e36..0c575f51fe57 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -817,7 +817,7 @@ static inline void module_bug_finalize(const Elf_Ehdr *hdr,
> static inline void module_bug_cleanup(struct module *mod) {}
> #endif /* CONFIG_GENERIC_BUG */
>
> -#ifdef RETPOLINE
> +#ifdef CONFIG_RETPOLINE
> extern bool retpoline_module_ok(bool has_retpoline);
> #else
> static inline bool retpoline_module_ok(bool has_retpoline)
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 0d998c54564d..5a5b3780456f 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -2157,7 +2157,7 @@ static void add_intree_flag(struct buffer *b, int is_intree)
> /* Cannot check for assembler */
> static void add_retpoline(struct buffer *b)
> {
> - buf_printf(b, "\n#ifdef RETPOLINE\n");
> + buf_printf(b, "\n#ifdef CONFIG_RETPOLINE\n");
> buf_printf(b, "MODULE_INFO(retpoline, \"Y\");\n");
> buf_printf(b, "#endif\n");
> }

I have no idea why I have missed these chunks. Thank you for fixing.

Reviewed-by: Zhenzhong Duan <[email protected]>


2018-12-12 13:13:52

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] treewide: replace RETPOLINE with CONFIG_RETPOLINE

On Tue, Dec 11, 2018 at 2:17 AM WANG Chao <[email protected]> wrote:
>
> Since commit 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend
> on compiler support"), RETPOLINE has been replaced by CONFIG_RETPOLINE.
>
> Fixes: 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
> Signed-off-by: WANG Chao <[email protected]>
> ---



Reviewed-by: Masahiro Yamada <[email protected]>




--
Best Regards
Masahiro Yamada

2018-12-21 16:02:57

by WANG Chao

[permalink] [raw]
Subject: Re: [PATCH] treewide: replace RETPOLINE with CONFIG_RETPOLINE

On 12/11/18 at 12:37P, WANG Chao wrote:
> Since commit 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend
> on compiler support"), RETPOLINE has been replaced by CONFIG_RETPOLINE.
>
> Fixes: 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
> Signed-off-by: WANG Chao <[email protected]>

ping ...

> ---
> arch/x86/kernel/cpu/bugs.c | 2 +-
> include/linux/compiler-gcc.h | 2 +-
> include/linux/module.h | 2 +-
> scripts/mod/modpost.c | 2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> index 500278f5308e..e8abe3f6c10e 100644
> --- a/arch/x86/kernel/cpu/bugs.c
> +++ b/arch/x86/kernel/cpu/bugs.c
> @@ -213,7 +213,7 @@ static enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init =
> static enum spectre_v2_user_mitigation spectre_v2_user __ro_after_init =
> SPECTRE_V2_USER_NONE;
>
> -#ifdef RETPOLINE
> +#ifdef CONFIG_RETPOLINE
> static bool spectre_v2_bad_module;
>
> bool retpoline_module_ok(bool has_retpoline)
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index 2010493e1040..977ddf2774f9 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -68,7 +68,7 @@
> */
> #define uninitialized_var(x) x = x
>
> -#ifdef RETPOLINE
> +#ifdef CONFIG_RETPOLINE
> #define __noretpoline __attribute__((__indirect_branch__("keep")))
> #endif
>
> diff --git a/include/linux/module.h b/include/linux/module.h
> index fce6b4335e36..0c575f51fe57 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -817,7 +817,7 @@ static inline void module_bug_finalize(const Elf_Ehdr *hdr,
> static inline void module_bug_cleanup(struct module *mod) {}
> #endif /* CONFIG_GENERIC_BUG */
>
> -#ifdef RETPOLINE
> +#ifdef CONFIG_RETPOLINE
> extern bool retpoline_module_ok(bool has_retpoline);
> #else
> static inline bool retpoline_module_ok(bool has_retpoline)
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 0d998c54564d..5a5b3780456f 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -2157,7 +2157,7 @@ static void add_intree_flag(struct buffer *b, int is_intree)
> /* Cannot check for assembler */
> static void add_retpoline(struct buffer *b)
> {
> - buf_printf(b, "\n#ifdef RETPOLINE\n");
> + buf_printf(b, "\n#ifdef CONFIG_RETPOLINE\n");
> buf_printf(b, "MODULE_INFO(retpoline, \"Y\");\n");
> buf_printf(b, "#endif\n");
> }
> --
> 2.19.2
>
>

2018-12-21 16:32:05

by WANG Chao

[permalink] [raw]
Subject: Re: [PATCH] treewide: replace RETPOLINE with CONFIG_RETPOLINE

On 12/21/18 at 11:47P, Borislav Petkov wrote:
> On Fri, Dec 21, 2018 at 05:33:47PM +0800, WANG Chao wrote:
> > On 12/11/18 at 12:37P, WANG Chao wrote:
> > > Since commit 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend
> > > on compiler support"), RETPOLINE has been replaced by CONFIG_RETPOLINE.
> > >
> > > Fixes: 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
> > > Signed-off-by: WANG Chao <[email protected]>
> >
> > ping ...
>
> This one somehow slipped through the cracks... :-\
>
> Ok, let's see: this could be relevant for the case when a module built
> with a compiler which doesn't support retpolines, gets loaded on a
> system which is built with retpolines.

You're right.

>
> Which is pretty seldom as the majority of setups out there should have
> a retpoline-enabled compiler. And should not allow loading external
> modules anyway, but that's a different story.
>
> So, this close to the merge window, I'm inclined to delay this one after
> it and have it take the x86/urgent fixes path. Unless someone screams
> and says that patch breaks his system. I haven't seen any reports about
> it so far so...

OK. Thanks.

WANG Chao

2018-12-21 19:25:22

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH] treewide: replace RETPOLINE with CONFIG_RETPOLINE

On Fri, Dec 21, 2018 at 05:33:47PM +0800, WANG Chao wrote:
> On 12/11/18 at 12:37P, WANG Chao wrote:
> > Since commit 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend
> > on compiler support"), RETPOLINE has been replaced by CONFIG_RETPOLINE.
> >
> > Fixes: 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
> > Signed-off-by: WANG Chao <[email protected]>
>
> ping ...

This one somehow slipped through the cracks... :-\

Ok, let's see: this could be relevant for the case when a module built
with a compiler which doesn't support retpolines, gets loaded on a
system which is built with retpolines.

Which is pretty seldom as the majority of setups out there should have
a retpoline-enabled compiler. And should not allow loading external
modules anyway, but that's a different story.

So, this close to the merge window, I'm inclined to delay this one after
it and have it take the x86/urgent fixes path. Unless someone screams
and says that patch breaks his system. I haven't seen any reports about
it so far so...

Thx.

--
Regards/Gruss,
Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)

2018-12-22 02:12:45

by David Laight

[permalink] [raw]
Subject: RE: [PATCH] treewide: replace RETPOLINE with CONFIG_RETPOLINE

From: Borislav Petkov
> Sent: 21 December 2018 10:47
> On Fri, Dec 21, 2018 at 05:33:47PM +0800, WANG Chao wrote:
> > On 12/11/18 at 12:37P, WANG Chao wrote:
> > > Since commit 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend
> > > on compiler support"), RETPOLINE has been replaced by CONFIG_RETPOLINE.
> > >
> > > Fixes: 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
> > > Signed-off-by: WANG Chao <[email protected]>
> >
> > ping ...
>
> This one somehow slipped through the cracks... :-\
>
> Ok, let's see: this could be relevant for the case when a module built
> with a compiler which doesn't support retpolines, gets loaded on a
> system which is built with retpolines.

Isn't the real problem someone taking a kernel from (say) kernel.org
that is compiled for retpolines and then trying to compile an additional
module on a system that has an old compiler?

> Which is pretty seldom as the majority of setups out there should have
> a retpoline-enabled compiler. And should not allow loading external
> modules anyway, but that's a different story.

Most of an external module is likely to be a big '.o' file that (I expect)
has to be compiled without retpolines in order to be linkable into old
kernels.
(Either that or it doesn't matter at all because it is just a change
to the generated code.)

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

2019-01-09 03:59:21

by WANG Chao

[permalink] [raw]
Subject: Re: [PATCH] treewide: replace RETPOLINE with CONFIG_RETPOLINE

On 12/21/18 at 11:47P, Borislav Petkov wrote:
> On Fri, Dec 21, 2018 at 05:33:47PM +0800, WANG Chao wrote:
> > On 12/11/18 at 12:37P, WANG Chao wrote:
> > > Since commit 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend
> > > on compiler support"), RETPOLINE has been replaced by CONFIG_RETPOLINE.
> > >
> > > Fixes: 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
> > > Signed-off-by: WANG Chao <[email protected]>
> >
> > ping ...
>
> This one somehow slipped through the cracks... :-\
>
> Ok, let's see: this could be relevant for the case when a module built
> with a compiler which doesn't support retpolines, gets loaded on a
> system which is built with retpolines.
>
> Which is pretty seldom as the majority of setups out there should have
> a retpoline-enabled compiler. And should not allow loading external
> modules anyway, but that's a different story.
>
> So, this close to the merge window, I'm inclined to delay this one after
> it and have it take the x86/urgent fixes path. Unless someone screams
> and says that patch breaks his system. I haven't seen any reports about
> it so far so...

Hi, Boris.

Please pick up this one in x86/urgent.

Thanks
Chao

Subject: [tip:x86/urgent] x86, modpost: Replace last remnants of RETPOLINE with CONFIG_RETPOLINE

Commit-ID: e4f358916d528d479c3c12bd2fd03f2d5a576380
Gitweb: https://git.kernel.org/tip/e4f358916d528d479c3c12bd2fd03f2d5a576380
Author: WANG Chao <[email protected]>
AuthorDate: Tue, 11 Dec 2018 00:37:25 +0800
Committer: Borislav Petkov <[email protected]>
CommitDate: Wed, 9 Jan 2019 10:35:56 +0100

x86, modpost: Replace last remnants of RETPOLINE with CONFIG_RETPOLINE

Commit

4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")

replaced the RETPOLINE define with CONFIG_RETPOLINE checks. Remove the
remaining pieces.

[ bp: Massage commit message. ]

Fixes: 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
Signed-off-by: WANG Chao <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Masahiro Yamada <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: David Woodhouse <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Jessica Yu <[email protected]>
Cc: Jiri Kosina <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Luc Van Oostenryck <[email protected]>
Cc: Michal Marek <[email protected]>
Cc: Miguel Ojeda <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Tim Chen <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: stable <[email protected]>
Cc: x86-ml <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
---
arch/x86/kernel/cpu/bugs.c | 2 +-
include/linux/compiler-gcc.h | 2 +-
include/linux/module.h | 2 +-
scripts/mod/modpost.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 8654b8b0c848..1de0f4170178 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -215,7 +215,7 @@ static enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init =
static enum spectre_v2_user_mitigation spectre_v2_user __ro_after_init =
SPECTRE_V2_USER_NONE;

-#ifdef RETPOLINE
+#ifdef CONFIG_RETPOLINE
static bool spectre_v2_bad_module;

bool retpoline_module_ok(bool has_retpoline)
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 5776da43da97..dd8268f5f5f0 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -68,7 +68,7 @@
*/
#define uninitialized_var(x) x = x

-#ifdef RETPOLINE
+#ifdef CONFIG_RETPOLINE
#define __noretpoline __attribute__((__indirect_branch__("keep")))
#endif

diff --git a/include/linux/module.h b/include/linux/module.h
index 9a21fe3509af..8fa38d3e7538 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -828,7 +828,7 @@ static inline void module_bug_finalize(const Elf_Ehdr *hdr,
static inline void module_bug_cleanup(struct module *mod) {}
#endif /* CONFIG_GENERIC_BUG */

-#ifdef RETPOLINE
+#ifdef CONFIG_RETPOLINE
extern bool retpoline_module_ok(bool has_retpoline);
#else
static inline bool retpoline_module_ok(bool has_retpoline)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0de2fb236640..26bf886bd168 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2185,7 +2185,7 @@ static void add_intree_flag(struct buffer *b, int is_intree)
/* Cannot check for assembler */
static void add_retpoline(struct buffer *b)
{
- buf_printf(b, "\n#ifdef RETPOLINE\n");
+ buf_printf(b, "\n#ifdef CONFIG_RETPOLINE\n");
buf_printf(b, "MODULE_INFO(retpoline, \"Y\");\n");
buf_printf(b, "#endif\n");
}