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

From: Daniel Borkmann
Date: Wed Feb 22 2023 - 14:32:35 EST


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 <viresh.kumar@xxxxxxxxxx>
---
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 */