Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1616286pxb; Mon, 11 Oct 2021 09:33:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8kXZ9NYf6Uj+c9s4hbHQAj0t3DYTpD7yO7bVCqpRL3bxT5b7oVGNAeaNM4eMeKgYiUsHs X-Received: by 2002:a17:906:7848:: with SMTP id p8mr26885626ejm.212.1633969991504; Mon, 11 Oct 2021 09:33:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633969991; cv=none; d=google.com; s=arc-20160816; b=mu4MTyeXh3QTpLwozJIVgBzEi8vCmXUyNDXGjVSn9xGBwaLSjxbEO6z/+t9yFCS3nQ lxObhC1wMSjaxeVYGw38rybrJUSFodIzRci2klpDN+cHiRTm//7H18URX9TjrLDMZli3 EdMkDqeW/sCS2Jfthih8fdbkJDohTTxHpxigN1jYX5lVe9hjBeLuwkGET3WZmAEX5w7o tGf9QiYuWyuZcnxsG5/bZe3iAmI1P3xX08JN9hY/ouXbL71/Rn1gu4G9r1KaR+1zrfO/ Ttjq3LAJ0SQLyDLMRC1XB00y1sfccoD4KLqEpSSAeXYkIfrVezNgUOw3Rcuxppk5ftDB 7zQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HbbOfNxnCDhOXF+e8i25bk75gju9U/eG7g/RMuLTlfE=; b=QPlYgItWj7bgmeSgPqk7byCZkX9A3yOmPEiRoLh0zgRDhh41pWYbB7REKs59nDN/t7 XnkxVvBEF0H2GtV/PCWRw9oGBW397Eb7wM07GMJjW2bHedKgYgc3ED8+3IliY3TszcmL ZpEkTVfOze9vBXkMxkR6PFL9LEnd9cnsUFlz8yCM2DuAgBdwo6ProO7ISRObT7bbmPOy mZSVjo2fC3JiIP8CE5DWUDZU6eUJLhE+uOp4wZJvzk8a+xIBPH57mAiuteQSNlKaNwLx ZKIkMh4IzwM4qYHQ7Z+4AfhGyAKRv1HOuLD/M+L1dLCZf1nASrKoxCQisVWWg3e3j9O5 TukQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H8WOYvVb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p22si11131731ejm.526.2021.10.11.09.32.47; Mon, 11 Oct 2021 09:33:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H8WOYvVb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237624AbhJKOBD (ORCPT + 99 others); Mon, 11 Oct 2021 10:01:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:49804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237773AbhJKN7C (ORCPT ); Mon, 11 Oct 2021 09:59:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E1A74610E7; Mon, 11 Oct 2021 13:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633960530; bh=8QyFRXt1ty+bSfUAH28UXsajU+uxYWy1fQ7W42jAeDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H8WOYvVb+Nx87O5y7Kzu7fmll/ipxP1sPGPPYZngsmCHqazSWE3vnb9GGhgFwdU/L wvcYrV/Ox4esz3eVtU2yqlsZmSIDnj3JrZSDxQDDjLYyIJrARphW7LWPL8KHXEn3oL IxKvvjcdLx/xjIzKqw2a1+GxvMdsai/xcKohva38= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Naveen N. Rao" , Johan Almbladh , Christophe Leroy , Song Liu , Michael Ellerman , Sasha Levin Subject: [PATCH 5.10 73/83] powerpc/bpf: Fix BPF_MOD when imm == 1 Date: Mon, 11 Oct 2021 15:46:33 +0200 Message-Id: <20211011134510.897297770@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011134508.362906295@linuxfoundation.org> References: <20211011134508.362906295@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Naveen N. Rao [ 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 Tested-by: Johan Almbladh Reviewed-by: Christophe Leroy Acked-by: Song Liu Acked-by: Johan Almbladh Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/c674ca18c3046885602caebb326213731c675d06.1633464148.git.naveen.n.rao@linux.vnet.ibm.com Signed-off-by: Sasha Levin --- 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 658ca2bab13c..e79f9eae2bc0 100644 --- a/arch/powerpc/net/bpf_jit_comp64.c +++ b/arch/powerpc/net/bpf_jit_comp64.c @@ -408,8 +408,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