Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp657176pxv; Thu, 15 Jul 2021 12:39:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx/pxZTUrzMmBl55BfH4vn4LYxfPDrzeyHwokNXUf/kfKSYLPV1lV6/7Ti1jVoaz1acZ+F X-Received: by 2002:a05:6402:151:: with SMTP id s17mr9263420edu.233.1626377998026; Thu, 15 Jul 2021 12:39:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377998; cv=none; d=google.com; s=arc-20160816; b=phfCod9B11guBW8ZpcufiX8wzOQrXtaKdM08tEZ4yosiyKUDdLkrqbPcHasNSkhMpu jXb/ryOzTLVbwZlnZCDt38GKvaY2Az1c4A2BMtn+mABQ4DASXSeqpFMquiM1hWms2KRR nNwkIqAXCWSmrzI5ZqxHkuohcoolB/vpdDK4ez9P6NhHbtfDp01V+NwUnmQVy7ivX78e hMqxGV50c8iZFLg/DamzHWz3uWlY7QUpIV+TNZs1RPj4YvpodBpiiAc9fSz72UStZhw7 MaPBGXR4oDA69bYXUJ9LkDxX85dPSVEi0ZXHpDibYUl3gI4p9+urLQs6OhkxhzExGQ6/ PrYg== 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=I5L4J6y7v4vvgzFkmg1nF8KX8Yl3I6EvoUY57dKoENw=; b=NbrsQkKhb2fOgc1sJ0ieU2BADaYQsLzJuFLO0cxeeQt/SsqgCiR59F0H3CoMyulyC1 BOD51yVjwBeoPWSwqPg7EHehuFGRwLz2HZ3mB8sox/R0HNVEUxOGAfJmkFYcFi146ABO 9vxSAaBp43+tS9h0SCk38/G+Q18Xqt7PcWomqe0IDrV3Au8N13q6TX69ImXkdSyn7Nm9 fnmGMshhULWWx4tCPKedWD2MYLiyq02yx9rRVw/5YbMJ7BWMV/sY0JwauCtJl9gzcEyC cLjaoDJ183Bcb/j0Np1uOmTyBh6lexr6sNe6w3gpo5DX27AS9u0KGcRblp8q0j3AD4Xq pqzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gxaY2Yqu; 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 g25si8252547ejx.336.2021.07.15.12.39.34; Thu, 15 Jul 2021 12:39:58 -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=gxaY2Yqu; 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 S1343928AbhGOTjl (ORCPT + 99 others); Thu, 15 Jul 2021 15:39:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:50542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244428AbhGOTOs (ORCPT ); Thu, 15 Jul 2021 15:14:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BF6E3613F2; Thu, 15 Jul 2021 19:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376227; bh=7MPuI7HQIsQRr261hVvk0fPJba0H/8bR2LnvPM9k0u8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gxaY2Yquj7z3WkY8UMbTLdeEJmck3s44QCfRyTXl/a7jrqDwvUhmQexoch0Ugahyi 9bBxGoGhT9L+noKq5hnnqqtGQOSBmvqPE3jm+9PSxfpVlzoHZvAwZWBEcra6M3qSKE PmDMq92KWIJ0pG6fMxlsh6OXo7zh69Km5D+fyfuE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Naveen N. Rao" , Michael Ellerman Subject: [PATCH 5.13 181/266] powerpc/bpf: Reject atomic ops in ppc32 JIT Date: Thu, 15 Jul 2021 20:38:56 +0200 Message-Id: <20210715182643.552266960@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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 commit 307e5042c7bdae15308ef2e9b848833b84122eb0 upstream. Commit 91c960b0056672 ("bpf: Rename BPF_XADD and prepare to encode other atomics in .imm") converted BPF_XADD to BPF_ATOMIC and updated all JIT implementations to reject JIT'ing instructions with an immediate value different from BPF_ADD. However, ppc32 BPF JIT was implemented around the same time and didn't include the same change. Update the ppc32 JIT accordingly. Fixes: 51c66ad849a7 ("powerpc/bpf: Implement extended BPF on PPC32") Cc: stable@vger.kernel.org # v5.13+ Signed-off-by: Naveen N. Rao Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/426699046d89fe50f66ecf74bd31c01eda976ba5.1625145429.git.naveen.n.rao@linux.vnet.ibm.com Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/net/bpf_jit_comp32.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) --- a/arch/powerpc/net/bpf_jit_comp32.c +++ b/arch/powerpc/net/bpf_jit_comp32.c @@ -773,9 +773,17 @@ int bpf_jit_build_body(struct bpf_prog * break; /* - * BPF_STX XADD (atomic_add) + * BPF_STX ATOMIC (atomic ops) */ - case BPF_STX | BPF_XADD | BPF_W: /* *(u32 *)(dst + off) += src */ + case BPF_STX | BPF_ATOMIC | BPF_W: + if (imm != BPF_ADD) { + pr_err_ratelimited("eBPF filter atomic op code %02x (@%d) unsupported\n", + code, i); + return -ENOTSUPP; + } + + /* *(u32 *)(dst + off) += src */ + bpf_set_seen_register(ctx, tmp_reg); /* Get offset into TMP_REG */ EMIT(PPC_RAW_LI(tmp_reg, off)); @@ -789,7 +797,7 @@ int bpf_jit_build_body(struct bpf_prog * PPC_BCC_SHORT(COND_NE, (ctx->idx - 3) * 4); break; - case BPF_STX | BPF_XADD | BPF_DW: /* *(u64 *)(dst + off) += src */ + case BPF_STX | BPF_ATOMIC | BPF_DW: /* *(u64 *)(dst + off) += src */ return -EOPNOTSUPP; /*