2023-02-22 08:24:39

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH] bpf: Fix undeclared function 'barrier_nospec' warning

Add the missing header for architectures that don't define
the barrier_nospec() macro. The nospec.h header is added after the
inclusion of barrier.h to avoid redefining the macro for architectures
that already define barrier_nospec() in their respective barrier.h
headers.

Fixes: 74e19ef0ff80 ("uaccess: Add speculation barrier to copy_from_user()")
Signed-off-by: Viresh Kumar <[email protected]>
---
Linus's master branch fails currently to build for arm64 without this commit.

kernel/bpf/core.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 933869983e2a..92aeb388e422 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -38,6 +38,8 @@
#include <linux/memcontrol.h>

#include <asm/barrier.h>
+#include <linux/nospec.h>
+
#include <asm/unaligned.h>

/* Registers */
--
2.31.1.272.g89b43f80a514



2023-02-22 15:04:13

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] bpf: Fix undeclared function 'barrier_nospec' warning

On Wed, Feb 22, 2023 at 9:26 AM Viresh Kumar <[email protected]> wrote:
> Add the missing header for architectures that don't define
> the barrier_nospec() macro. The nospec.h header is added after the
> inclusion of barrier.h to avoid redefining the macro for architectures
> that already define barrier_nospec() in their respective barrier.h
> headers.
>
> Fixes: 74e19ef0ff80 ("uaccess: Add speculation barrier to copy_from_user()")
> Signed-off-by: Viresh Kumar <[email protected]>
> ---
> Linus's master branch fails currently to build for arm64 without this commit.

Not just arm64 :-(
http://kisskb.ellerman.id.au/kisskb/head/5b7c4cabbb65f5c469464da6c5f614cbd7f730f2

Tested-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2023-02-22 15:34:35

by Dave Hansen

[permalink] [raw]
Subject: Re: [PATCH] bpf: Fix undeclared function 'barrier_nospec' warning

On 2/22/23 07:03, Geert Uytterhoeven wrote:
> On Wed, Feb 22, 2023 at 9:26 AM Viresh Kumar <[email protected]> wrote:
>> Add the missing header for architectures that don't define
>> the barrier_nospec() macro. The nospec.h header is added after the
>> inclusion of barrier.h to avoid redefining the macro for architectures
>> that already define barrier_nospec() in their respective barrier.h
>> headers.
>>
>> Fixes: 74e19ef0ff80 ("uaccess: Add speculation barrier to copy_from_user()")
>> Signed-off-by: Viresh Kumar <[email protected]>
>> ---
>> Linus's master branch fails currently to build for arm64 without this commit.
> Not just arm64 ????
> http://kisskb.ellerman.id.au/kisskb/head/5b7c4cabbb65f5c469464da6c5f614cbd7f730f2

Thanks for the fix, and sorry for the breakage, folks! Obviously:

Tested-by: Dave Hansen <[email protected]>

Now time to go make sure I have bpf turned on in all my cross builds.



2023-02-22 16:29:17

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH] bpf: Fix undeclared function 'barrier_nospec' warning

On Wed, Feb 22, 2023 at 7:33 AM Dave Hansen <[email protected]> wrote:
>
> On 2/22/23 07:03, Geert Uytterhoeven wrote:
> > On Wed, Feb 22, 2023 at 9:26 AM Viresh Kumar <[email protected]> wrote:
> >> Add the missing header for architectures that don't define
> >> the barrier_nospec() macro. The nospec.h header is added after the
> >> inclusion of barrier.h to avoid redefining the macro for architectures
> >> that already define barrier_nospec() in their respective barrier.h
> >> headers.
> >>
> >> Fixes: 74e19ef0ff80 ("uaccess: Add speculation barrier to copy_from_user()")
> >> Signed-off-by: Viresh Kumar <[email protected]>
> >> ---
> >> Linus's master branch fails currently to build for arm64 without this commit.
> > Not just arm64 ????
> > http://kisskb.ellerman.id.au/kisskb/head/5b7c4cabbb65f5c469464da6c5f614cbd7f730f2
>
> Thanks for the fix, and sorry for the breakage, folks! Obviously:
>
> Tested-by: Dave Hansen <[email protected]>
>
> Now time to go make sure I have bpf turned on in all my cross builds.

Not clear why the broken commit got applied bypassing bpf@vger and not
going through BPF CI. :(

Yesterday I applied pretty much the same fix from Huacai Chen.

https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/commit/?id=345d24a91c79f408e355c8b7e873ccde0f097eea

and BPF CI is now back to green.

Linus,
Since the blast radius is big, may be apply the fix directly ?

2023-02-22 18:06:06

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH] bpf: Fix undeclared function 'barrier_nospec' warning

On Wed, Feb 22, 2023 at 8:29 AM Alexei Starovoitov
<[email protected]> wrote:
>
> Linus,
> Since the blast radius is big, may be apply the fix directly ?

Yup, done. Of the different patches I picked the same location you had
taken so that there shouldn't be any conflicts if that ends making it
to me later.

Linus

2023-02-22 19:32:35

by Daniel Borkmann

[permalink] [raw]
Subject: Re: [PATCH] bpf: Fix undeclared function 'barrier_nospec' warning

On 2/22/23 9:24 AM, Viresh Kumar wrote:
> Add the missing header for architectures that don't define
> the barrier_nospec() macro. The nospec.h header is added after the
> inclusion of barrier.h to avoid redefining the macro for architectures
> that already define barrier_nospec() in their respective barrier.h
> headers.
>
> Fixes: 74e19ef0ff80 ("uaccess: Add speculation barrier to copy_from_user()")
> Signed-off-by: Viresh Kumar <[email protected]>
> ---
> Linus's master branch fails currently to build for arm64 without this commit.
>
> kernel/bpf/core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
> index 933869983e2a..92aeb388e422 100644
> --- a/kernel/bpf/core.c
> +++ b/kernel/bpf/core.c
> @@ -38,6 +38,8 @@
> #include <linux/memcontrol.h>
>
> #include <asm/barrier.h>
> +#include <linux/nospec.h>
> +

nit: The asm/barrier.h include could have just been removed. linux/nospec.h
internally includes asm/barrier.h already.

> #include <asm/unaligned.h>
>
> /* Registers */
>