c3bad6
From 7759cc92c07c86272bdc91c18e66646920bde0f6 Mon Sep 17 00:00:00 2001
c3bad6
From: Daan De Meyer <daan.j.demeyer@gmail.com>
c3bad6
Date: Thu, 3 Oct 2024 10:46:27 +0200
c3bad6
Subject: [PATCH] nsresourced: Fix declaration of bpf_rdonly_cast()
c3bad6
c3bad6
Fixes compilation error
c3bad6
c3bad6
"""
c3bad6
[780/3171] /usr/bin/clang -std=gnu11 -Wno-compare-distinct-pointer-types -fno-stack-protector -O2 -target bpf -g -c -D__aarch64__ -I. -isystem /usr/include/ -idirafter /usr/include ../src/nsresourced/bpf/userns_restrict/userns-restrict.bpf.c -o src/nsresourced/bpf/userns_restrict/userns-restrict.bpf.unstripped.o -I/usr/src/kernels/6.11.1-0.hs1.hs+fb.el9.aarch64
c3bad6
FAILED: src/nsresourced/bpf/userns_restrict/userns-restrict.bpf.unstripped.o
c3bad6
/usr/bin/clang -std=gnu11 -Wno-compare-distinct-pointer-types -fno-stack-protector -O2 -target bpf -g -c -D__aarch64__ -I. -isystem /usr/include/ -idirafter /usr/include ../src/nsresourced/bpf/userns_restrict/userns-restrict.bpf.c -o src/nsresourced/bpf/userns_restrict/userns-restrict.bpf.unstripped.o -I/usr/src/kernels/6.11.1-0.hs1.hs+fb.el9.aarch64
c3bad6
../src/nsresourced/bpf/userns_restrict/userns-restrict.bpf.c:27:7: error: conflicting types for 'bpf_rdonly_cast'
c3bad6
   27 | void *bpf_rdonly_cast(void *, __u32) __ksym;
c3bad6
      |       ^
c3bad6
/usr/src/kernels/6.11.1-0.hs1.hs+fb.el9.aarch64/vmlinux.h:143063:14: note: previous declaration is here
c3bad6
 143063 | extern void *bpf_rdonly_cast(const void *obj__ign, u32 btf_id__k) __weak __ksym;
c3bad6
        |              ^
c3bad6
1 error generated.
c3bad6
"""
c3bad6
---
c3bad6
 src/nsresourced/bpf/userns_restrict/userns-restrict.bpf.c | 2 +-
c3bad6
 1 file changed, 1 insertion(+), 1 deletion(-)
c3bad6
c3bad6
diff --git a/src/nsresourced/bpf/userns_restrict/userns-restrict.bpf.c b/src/nsresourced/bpf/userns_restrict/userns-restrict.bpf.c
c3bad6
index 126422bb69cc1..0ff41a138bee9 100644
c3bad6
--- a/src/nsresourced/bpf/userns_restrict/userns-restrict.bpf.c
c3bad6
+++ b/src/nsresourced/bpf/userns_restrict/userns-restrict.bpf.c
c3bad6
@@ -24,7 +24,7 @@
c3bad6
 /* bpf_rdonly_cast() was introduced in libbpf commit 688879f together with
c3bad6
  * the definition of a bpf_core_cast macro. So use that one to avoid
c3bad6
  * defining a prototype for bpf_rdonly_cast */
c3bad6
-void *bpf_rdonly_cast(void *, __u32) __ksym;
c3bad6
+void* bpf_rdonly_cast(const void *, __u32) __ksym;
c3bad6
 #endif
c3bad6
 
c3bad6
 /* BPF module that implements an allowlist of mounts (identified by mount ID) for user namespaces (identified