linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	Johan Almbladh <johan.almbladh@anyfinetworks.com>,
	Christophe Leroy <christophe.leroy@csgroup.eu>,
	Song Liu <songliubraving@fb.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.19 27/28] powerpc/bpf: Fix BPF_MOD when imm == 1
Date: Mon, 11 Oct 2021 15:47:17 +0200	[thread overview]
Message-ID: <20211011134641.589971358@linuxfoundation.org> (raw)
In-Reply-To: <20211011134640.711218469@linuxfoundation.org>

From: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>

[ Upstream commit 8bbc9d822421d9ac8ff9ed26a3713c9afc69d6c8 ]

Only ignore the operation if dividing by 1.

Fixes: 156d0e290e969c ("powerpc/ebpf/jit: Implement JIT compiler for extended BPF")
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Tested-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Acked-by: Song Liu <songliubraving@fb.com>
Acked-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/c674ca18c3046885602caebb326213731c675d06.1633464148.git.naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/powerpc/net/bpf_jit_comp64.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
index e7d56ddba43a..ff201b1fe768 100644
--- a/arch/powerpc/net/bpf_jit_comp64.c
+++ b/arch/powerpc/net/bpf_jit_comp64.c
@@ -385,8 +385,14 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
 		case BPF_ALU64 | BPF_DIV | BPF_K: /* dst /= imm */
 			if (imm == 0)
 				return -EINVAL;
-			else if (imm == 1)
-				goto bpf_alu32_trunc;
+			if (imm == 1) {
+				if (BPF_OP(code) == BPF_DIV) {
+					goto bpf_alu32_trunc;
+				} else {
+					EMIT(PPC_RAW_LI(dst_reg, 0));
+					break;
+				}
+			}
 
 			PPC_LI32(b2p[TMP_REG_1], imm);
 			switch (BPF_CLASS(code)) {
-- 
2.33.0




  parent reply	other threads:[~2021-10-11 14:16 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-11 13:46 [PATCH 4.19 00/28] 4.19.211-rc1 review Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 4.19 01/28] Partially revert "usb: Kconfig: using select for USB_COMMON dependency" Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 4.19 02/28] USB: cdc-acm: fix racy tty buffer accesses Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 4.19 03/28] USB: cdc-acm: fix break reporting Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 4.19 04/28] xen/privcmd: fix error handling in mmap-resource processing Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 4.19 05/28] ovl: fix missing negative dentry check in ovl_rename() Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 4.19 06/28] nfsd4: Handle the NFSv4 READDIR dircount hint being zero Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 4.19 07/28] xen/balloon: fix cancelled balloon action Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 4.19 08/28] ARM: dts: omap3430-sdp: Fix NAND device node Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 4.19 09/28] ARM: dts: qcom: apq8064: use compatible which contains chipid Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 10/28] bpf, mips: Validate conditional branch offsets Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 11/28] xtensa: call irqchip_init only when CONFIG_USE_OF is selected Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 12/28] bpf, arm: Fix register clobbering in div/mod implementation Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 13/28] bpf: Fix integer overflow in prealloc_elems_and_freelist() Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 14/28] phy: mdio: fix memory leak Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 15/28] net_sched: fix NULL deref in fifo_set_limit() Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 16/28] powerpc/fsl/dts: Fix phy-connection-type for fm1mac3 Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 17/28] ptp_pch: Load module automatically if ID matches Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 18/28] ARM: imx6: disable the GIC CPU interface before calling stby-poweroff sequence Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 19/28] net: bridge: use nla_total_size_64bit() in br_get_linkxstats_size() Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 20/28] net: sfp: Fix typo in state machine debug string Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 21/28] netlink: annotate data races around nlk->bound Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 22/28] drm/nouveau/debugfs: fix file release memory leak Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 23/28] rtnetlink: fix if_nlmsg_stats_size() under estimation Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 24/28] i40e: fix endless loop under rtnl Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 25/28] i40e: Fix freeing of uninitialized misc IRQ vector Greg Kroah-Hartman
2021-10-11 13:47 ` [PATCH 4.19 26/28] i2c: acpi: fix resource leak in reconfiguration device addition Greg Kroah-Hartman
2021-10-11 13:47 ` Greg Kroah-Hartman [this message]
2021-10-11 13:47 ` [PATCH 4.19 28/28] x86/Kconfig: Correct reference to MWINCHIP3D Greg Kroah-Hartman
2021-10-11 16:51 ` [PATCH 4.19 00/28] 4.19.211-rc1 review Pavel Machek
2021-10-11 20:51 ` Guenter Roeck
2021-10-12  1:18 ` Shuah Khan
2021-10-12  1:59 ` Guenter Roeck
2021-10-12  8:13 ` Samuel Zou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211011134641.589971358@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=christophe.leroy@csgroup.eu \
    --cc=johan.almbladh@anyfinetworks.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=sashal@kernel.org \
    --cc=songliubraving@fb.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).