]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
powerpc/bpf ppc32: Fix BPF_SUB when imm == 0x80000000
authorNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Tue, 5 Oct 2021 20:25:29 +0000 (01:55 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Oct 2021 07:42:03 +0000 (09:42 +0200)
[ Upstream commit 548b762763b885b81850db676258df47c55dd5f9 ]

Special case handling of the smallest 32-bit negative number for BPF_SUB.

Fixes: 51c66ad849a703 ("powerpc/bpf: Implement extended BPF on PPC32")
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/7135360a0cdf70adedbccf9863128b8daef18764.1633464148.git.naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/net/bpf_jit_comp32.c

index c48de048c8ced0ab24a616f9deb106880cb46676..a7759aa8043d22f42f00b70ddc80c1aec2aa4621 100644 (file)
@@ -355,7 +355,7 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, struct codegen_context *
                                PPC_LI32(_R0, imm);
                                EMIT(PPC_RAW_ADDC(dst_reg, dst_reg, _R0));
                        }
-                       if (imm >= 0)
+                       if (imm >= 0 || (BPF_OP(code) == BPF_SUB && imm == 0x80000000))
                                EMIT(PPC_RAW_ADDZE(dst_reg_h, dst_reg_h));
                        else
                                EMIT(PPC_RAW_ADDME(dst_reg_h, dst_reg_h));