From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21CA0C11F68 for ; Fri, 2 Jul 2021 10:26:57 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E6631613FB for ; Fri, 2 Jul 2021 10:26:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E6631613FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GGWTp23pKz3bYc for ; Fri, 2 Jul 2021 20:26:54 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MxM6F1mR; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MxM6F1mR; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=216.205.24.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=jolsa@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MxM6F1mR; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MxM6F1mR; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GGWTD4Z5Xz2yNm for ; Fri, 2 Jul 2021 20:26:21 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625221577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EM4rv+Os2BFUcNbdujbpAl42XdEpcURNArLBdyldSyk=; b=MxM6F1mRqZsHnllDbFUcTx+B+NE8XZ77vuwb6uwr46M2aQs99uRI0EDKMCc7mdtqoKkkgc gRU7/nsGHDIp0ZPSMDMNe8YPAiSpn0/rlbl+gFwZ3B+Oal/HcDA7ltGDlZ1EvDwYU99189 yvGUPCF3nlJHa5wicEn5wHvbIQ+AdR8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625221577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EM4rv+Os2BFUcNbdujbpAl42XdEpcURNArLBdyldSyk=; b=MxM6F1mRqZsHnllDbFUcTx+B+NE8XZ77vuwb6uwr46M2aQs99uRI0EDKMCc7mdtqoKkkgc gRU7/nsGHDIp0ZPSMDMNe8YPAiSpn0/rlbl+gFwZ3B+Oal/HcDA7ltGDlZ1EvDwYU99189 yvGUPCF3nlJHa5wicEn5wHvbIQ+AdR8= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-499-WDSI-gibPNiflNmuitQEyA-1; Fri, 02 Jul 2021 06:26:16 -0400 X-MC-Unique: WDSI-gibPNiflNmuitQEyA-1 Received: by mail-ej1-f72.google.com with SMTP id ho42-20020a1709070eaab02904a77ea3380eso3378612ejc.4 for ; Fri, 02 Jul 2021 03:26:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=EM4rv+Os2BFUcNbdujbpAl42XdEpcURNArLBdyldSyk=; b=UXfqNGUub6tITzpBRsXtldsS6qXF5RMKgaBV0G4E1uP/YVtHeZ6fJdka2ldUcLCNny vY5TRxcULVURj7CKosc5FPKSLIjzTTj3lZkK3bJO+yseqQifgZdvDZxNJXdwTJBEFmIf y9zBB/FJvPQiLdUr5hffjgKkGYfX+dYP0AA8IVr+iazQ7N8lpWF+uZMb44MBaOe+N0Xg GTYOHWRIqYg3rvpvPnvqi9bXz4KVG9GnEbFOZLpa4RSo6Tcy6TIWJHOEREzTvIItj27S zCT3ocYcCpRZGQ3kiaei1rMTV064+oE9G+Y4wCpd7hMSs4vJAHW0PtsdtQ6/x1XlLHsP 5TDw== X-Gm-Message-State: AOAM531e2fXDAgcaU6pR88qyx+6vDvn1hXgAqHgHxQRv2baJL1YTlXTv e8ZsHDK+tmhnKSk/8eUBR4n5gU11HmKKfvQSl9sIcd1fKmN2MtPnu2UFfTL562WPyD65ylhnxkx PuAkOi28eqf1RNBfoGHRURuuaVw== X-Received: by 2002:a05:6402:31b3:: with SMTP id dj19mr1648291edb.24.1625221574989; Fri, 02 Jul 2021 03:26:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn8k1h6e/dZCweAEKoFXiejKrvCFYp7PHqlHpnkSx8je37PU0hXAgg8Sl+uceeRMdngxs2Gg== X-Received: by 2002:a05:6402:31b3:: with SMTP id dj19mr1648281edb.24.1625221574866; Fri, 02 Jul 2021 03:26:14 -0700 (PDT) Received: from krava ([185.153.78.55]) by smtp.gmail.com with ESMTPSA id g23sm1122002edp.74.2021.07.02.03.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 03:26:14 -0700 (PDT) Date: Fri, 2 Jul 2021 12:26:11 +0200 From: Jiri Olsa To: "Naveen N. Rao" Subject: Re: [PATCH 1/2] powerpc/bpf: Fix detecting BPF atomic instructions Message-ID: References: <4117b430ffaa8cd7af042496f87fd7539e4f17fd.1625145429.git.naveen.n.rao@linux.vnet.ibm.com> MIME-Version: 1.0 In-Reply-To: <4117b430ffaa8cd7af042496f87fd7539e4f17fd.1625145429.git.naveen.n.rao@linux.vnet.ibm.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Borkmann , Brendan Jackman , bpf@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Alexei Starovoitov Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Thu, Jul 01, 2021 at 08:38:58PM +0530, Naveen N. Rao wrote: > Commit 91c960b0056672 ("bpf: Rename BPF_XADD and prepare to encode other > atomics in .imm") converted BPF_XADD to BPF_ATOMIC and added a way to > distinguish instructions based on the immediate field. Existing JIT > implementations were updated to check for the immediate field and to > reject programs utilizing anything more than BPF_ADD (such as BPF_FETCH) > in the immediate field. > > However, the check added to powerpc64 JIT did not look at the correct > BPF instruction. Due to this, such programs would be accepted and > incorrectly JIT'ed resulting in soft lockups, as seen with the atomic > bounds test. Fix this by looking at the correct immediate value. > > Fixes: 91c960b0056672 ("bpf: Rename BPF_XADD and prepare to encode other atomics in .imm") > Reported-by: Jiri Olsa > Tested-by: Jiri Olsa > Signed-off-by: Naveen N. Rao > --- > Hi Jiri, > FYI: I made a small change in this patch -- using 'imm' directly, rather > than insn[i].imm. I've still added your Tested-by since this shouldn't > impact the fix in any way. yep, it works nicely thanks jirka > > - Naveen > > > arch/powerpc/net/bpf_jit_comp64.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c > index 5cad5b5a7e9774..de8595880feec6 100644 > --- a/arch/powerpc/net/bpf_jit_comp64.c > +++ b/arch/powerpc/net/bpf_jit_comp64.c > @@ -667,7 +667,7 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, struct codegen_context * > * BPF_STX ATOMIC (atomic ops) > */ > case BPF_STX | BPF_ATOMIC | BPF_W: > - if (insn->imm != BPF_ADD) { > + if (imm != BPF_ADD) { > pr_err_ratelimited( > "eBPF filter atomic op code %02x (@%d) unsupported\n", > code, i); > @@ -689,7 +689,7 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, struct codegen_context * > PPC_BCC_SHORT(COND_NE, tmp_idx); > break; > case BPF_STX | BPF_ATOMIC | BPF_DW: > - if (insn->imm != BPF_ADD) { > + if (imm != BPF_ADD) { > pr_err_ratelimited( > "eBPF filter atomic op code %02x (@%d) unsupported\n", > code, i); > -- > 2.31.1 >