All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kbuild: avoid static_assert for genksyms
@ 2020-12-03 23:09 Arnd Bergmann
  2020-12-06  2:48 ` Masahiro Yamada
  2020-12-10 16:12 ` Marco Elver
  0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2020-12-03 23:09 UTC (permalink / raw)
  To: Andrew Morton, linux-kbuild, Masahiro Yamada, Michal Marek
  Cc: Arnd Bergmann, stable, Ard Biesheuvel, Kees Cook,
	Masahiro Yamada, Rikard Falkeborn, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

genksyms does not know or care about the _Static_assert() built-in,
and sometimes falls back to ignoring the later symbols, which causes
undefined behavior such as

WARNING: modpost: EXPORT symbol "ethtool_set_ethtool_phy_ops" [vmlinux] version generation failed, symbol will not be versioned.
ld: net/ethtool/common.o: relocation R_AARCH64_ABS32 against `__crc_ethtool_set_ethtool_phy_ops' can not be used when making a shared object
net/ethtool/common.o:(_ftrace_annotated_branch+0x0): dangerous relocation: unsupported relocation

Redefine static_assert for genksyms to avoid that.

Cc: stable@vger.kernel.org
Suggested-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/build_bug.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/build_bug.h b/include/linux/build_bug.h
index e3a0be2c90ad..7bb66e15b481 100644
--- a/include/linux/build_bug.h
+++ b/include/linux/build_bug.h
@@ -77,4 +77,9 @@
 #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
 #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
 
+#ifdef __GENKSYMS__
+/* genksyms gets confused by _Static_assert */
+#define _Static_assert(expr, ...)
+#endif
+
 #endif	/* _LINUX_BUILD_BUG_H */
-- 
2.27.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: avoid static_assert for genksyms
  2020-12-03 23:09 [PATCH] kbuild: avoid static_assert for genksyms Arnd Bergmann
@ 2020-12-06  2:48 ` Masahiro Yamada
  2020-12-07  8:53   ` Ard Biesheuvel
  2020-12-10 16:12 ` Marco Elver
  1 sibling, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2020-12-06  2:48 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Andrew Morton, Linux Kbuild mailing list, Michal Marek,
	Arnd Bergmann, stable, Ard Biesheuvel, Kees Cook,
	Rikard Falkeborn, Linux Kernel Mailing List

On Fri, Dec 4, 2020 at 8:10 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> genksyms does not know or care about the _Static_assert() built-in,
> and sometimes falls back to ignoring the later symbols, which causes
> undefined behavior such as
>
> WARNING: modpost: EXPORT symbol "ethtool_set_ethtool_phy_ops" [vmlinux] version generation failed, symbol will not be versioned.
> ld: net/ethtool/common.o: relocation R_AARCH64_ABS32 against `__crc_ethtool_set_ethtool_phy_ops' can not be used when making a shared object
> net/ethtool/common.o:(_ftrace_annotated_branch+0x0): dangerous relocation: unsupported relocation
>
> Redefine static_assert for genksyms to avoid that.


Please tell the CONFIG options needed to reproduce this.
I do not see it.


>
> Cc: stable@vger.kernel.org
> Suggested-by: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  include/linux/build_bug.h | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/include/linux/build_bug.h b/include/linux/build_bug.h
> index e3a0be2c90ad..7bb66e15b481 100644
> --- a/include/linux/build_bug.h
> +++ b/include/linux/build_bug.h
> @@ -77,4 +77,9 @@
>  #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
>  #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
>
> +#ifdef __GENKSYMS__
> +/* genksyms gets confused by _Static_assert */
> +#define _Static_assert(expr, ...)
> +#endif
> +
>  #endif /* _LINUX_BUILD_BUG_H */
> --
> 2.27.0
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: avoid static_assert for genksyms
  2020-12-06  2:48 ` Masahiro Yamada
@ 2020-12-07  8:53   ` Ard Biesheuvel
  0 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2020-12-07  8:53 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Arnd Bergmann, Andrew Morton, Linux Kbuild mailing list,
	Michal Marek, Arnd Bergmann, stable, Kees Cook, Rikard Falkeborn,
	Linux Kernel Mailing List

On Sun, 6 Dec 2020 at 03:49, Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Fri, Dec 4, 2020 at 8:10 AM Arnd Bergmann <arnd@kernel.org> wrote:
> >
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > genksyms does not know or care about the _Static_assert() built-in,
> > and sometimes falls back to ignoring the later symbols, which causes
> > undefined behavior such as
> >
> > WARNING: modpost: EXPORT symbol "ethtool_set_ethtool_phy_ops" [vmlinux] version generation failed, symbol will not be versioned.
> > ld: net/ethtool/common.o: relocation R_AARCH64_ABS32 against `__crc_ethtool_set_ethtool_phy_ops' can not be used when making a shared object
> > net/ethtool/common.o:(_ftrace_annotated_branch+0x0): dangerous relocation: unsupported relocation
> >
> > Redefine static_assert for genksyms to avoid that.
>
>
> Please tell the CONFIG options needed to reproduce this.
> I do not see it.
>

https://people.linaro.org/~ard.biesheuvel/randconfig-modversions-error

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: avoid static_assert for genksyms
  2020-12-03 23:09 [PATCH] kbuild: avoid static_assert for genksyms Arnd Bergmann
  2020-12-06  2:48 ` Masahiro Yamada
@ 2020-12-10 16:12 ` Marco Elver
  1 sibling, 0 replies; 4+ messages in thread
From: Marco Elver @ 2020-12-10 16:12 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Andrew Morton, linux-kbuild, Masahiro Yamada, Michal Marek,
	Arnd Bergmann, stable, Ard Biesheuvel, Kees Cook,
	Masahiro Yamada, Rikard Falkeborn, linux-kernel

On Fri, Dec 04, 2020 at 12:09AM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> genksyms does not know or care about the _Static_assert() built-in,
> and sometimes falls back to ignoring the later symbols, which causes
> undefined behavior such as
> 
> WARNING: modpost: EXPORT symbol "ethtool_set_ethtool_phy_ops" [vmlinux] version generation failed, symbol will not be versioned.
> ld: net/ethtool/common.o: relocation R_AARCH64_ABS32 against `__crc_ethtool_set_ethtool_phy_ops' can not be used when making a shared object
> net/ethtool/common.o:(_ftrace_annotated_branch+0x0): dangerous relocation: unsupported relocation
> 
> Redefine static_assert for genksyms to avoid that.
> 
> Cc: stable@vger.kernel.org
> Suggested-by: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  include/linux/build_bug.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/include/linux/build_bug.h b/include/linux/build_bug.h
> index e3a0be2c90ad..7bb66e15b481 100644
> --- a/include/linux/build_bug.h
> +++ b/include/linux/build_bug.h
> @@ -77,4 +77,9 @@
>  #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
>  #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
>  
> +#ifdef __GENKSYMS__
> +/* genksyms gets confused by _Static_assert */
> +#define _Static_assert(expr, ...)
> +#endif
> +

I had sent

	https://lkml.kernel.org/r/20201201152017.3576951-1-elver@google.com

3 days before your patch. :-)

I guess what you propose is simpler, but might still have corner cases
where we still get warnings. In particular, if some file (for whatever
reason) does not include build_bug.h and uses a raw _Static_assert(),
then we still get warnings. E.g. I see 1 user of raw _Static_assert()
(drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h ).

In the end I don't mind either way, as long as those warnings are fixed
in 5.11. :-)

Thanks,
-- Marco

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-10 16:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 23:09 [PATCH] kbuild: avoid static_assert for genksyms Arnd Bergmann
2020-12-06  2:48 ` Masahiro Yamada
2020-12-07  8:53   ` Ard Biesheuvel
2020-12-10 16:12 ` Marco Elver

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.