bpf_jit_supports_fsession() returns bool. Commit 92258b5bf1ec
("powerpc32/bpf: Add fsession support") made it return -EOPNOTSUPP on
ppc32 until fsession is validated there. The negative value converts to
true, so the verifier does not reject fsession programs on ppc32. Such a
program loads, and only attaching it fails because
__arch_prepare_bpf_trampoline() returns -EOPNOTSUPP on ppc32.

Return false instead. The load then fails with "JIT does not support
fsession". Tested with a ppc32 kernel on QEMU g3beige.

Fixes: 92258b5bf1ec ("powerpc32/bpf: Add fsession support")
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Closes: https://lore.kernel.org/r/[email protected]/
Assisted-by: LLM
Signed-off-by: Karl Mehltretter <[email protected]>
---
 arch/powerpc/net/bpf_jit_comp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
index 7a612688e7a2..64e70f3226b2 100644
--- a/arch/powerpc/net/bpf_jit_comp.c
+++ b/arch/powerpc/net/bpf_jit_comp.c
@@ -539,7 +539,7 @@ bool bpf_jit_supports_fsession(void)
         * for fsession and trampoline on ppc32.
         */
        if (IS_ENABLED(CONFIG_PPC32))
-               return -EOPNOTSUPP;
+               return false;
        return true;
 }
 

base-commit: e767a4ea70a3992c37ed604157d32f0dfbf9b1e3
-- 
2.53.0


Reply via email to