Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7232648rwb; Tue, 6 Dec 2022 03:06:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf42UC9FbmHmm/v/rmVewBEMeKFBpiBrL1Gqjj2bzMQ8Eiyd0Kolvc0oMwt7LZa6NeevExxe X-Received: by 2002:a17:90a:1a15:b0:219:672d:ed9e with SMTP id 21-20020a17090a1a1500b00219672ded9emr31366059pjk.36.1670324793406; Tue, 06 Dec 2022 03:06:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670324793; cv=none; d=google.com; s=arc-20160816; b=B0roVmFSdjVyr4YpWVY7tP/kcCh7s2HWL9pUd7bWteU5rL65BIa5Mvj/3k+B+lp3vY 6nA2bRpa9rl9NbMVyeaSoIvFGZUDakXHNlEnjNdzcJBytQ72kRk/Cvi8Je+0+PzTgo0w zvyQta3HynAMJwWmPGtYZz//sQpdqMv+ygVhjuuN8td8ISEN005J8D6A12bVgqT5RNtm oFmmNx6Rlpi8nMs/6cuUWvnorfgWdRrSix+HQAobmzAtLOj+2Kp5joLWglfYGHA93Tqh gA82wy9fqEebsEnW1/TELA1YH80B/gidh9hUA2G89YRl6GbdBJ4W0fg16MkI6S8VQaDv L/vg== 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 :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=oioQ2q8bR8USiRel0ZxqKjrQ/0jFx43JLXf+oz1BzU4=; b=edh0bDz214u58t+/znOzqKuzvzmQKmrCtwaabyE/Js4JKi+Lq/a0IpOPxMBiPdbuV4 xHLx5kMnkBiijWI7tOvff9YcH3JRue4bvtRoMuJj6PeewBaOj+aNrOyck3/bT66z5thm w9wHdNPYROsgGTPK2LIUSnuhn9FJGEre7mgWZyQHGJ8Oxp4ARV/lZDC9P5Hwwe/D600T PiEdydEOlC64STPaHD+CsLppkYnCjP533MjC5PockE+7q81g0GMHhDd0uMTV9RklKe1y EhcgDy56k2zK2Tjyd3StHjpdaKouo2tPw31z+Bhir2aK3TxComop2l4US6r6yHIEbG1m pphg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fsXiDUxk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a170902eb4500b00189cbf69532si7502782pli.153.2022.12.06.03.06.22; Tue, 06 Dec 2022 03:06:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fsXiDUxk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234451AbiLFK6B (ORCPT + 79 others); Tue, 6 Dec 2022 05:58:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232054AbiLFK57 (ORCPT ); Tue, 6 Dec 2022 05:57:59 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1C781181A; Tue, 6 Dec 2022 02:57:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7D40361639; Tue, 6 Dec 2022 10:57:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91942C433D7; Tue, 6 Dec 2022 10:57:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670324277; bh=oioQ2q8bR8USiRel0ZxqKjrQ/0jFx43JLXf+oz1BzU4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=fsXiDUxkzmX+RIzVJrKr6FEUqv0lA5yEYEqLlcrvSw/ZHQwn0/7rj6J1JVBgdcmEG ZCqys/kjttsYYC4GTxw4gknCD3+UtvIOO2m6XhUVHmF+L7VahEjFyRetO4BbnQrRDo VsTNc6pEwd8Jah2lpQa/RT3h0SG0F7HrE+fCd+Nq1XrgIJZTVGxPfyEzq7ysp7RHwD jypzudpdjgf9q1+Yw+0mVSP4beWnejHxNYSgi4bw/zg4dFwYVX0/fZN+5OnClfKu0g 0Y9FzxFqWmYNp624YVhmdZhrGDKcpo4+TvvH9wJ8GrLnIHUx1HMy17nClrVvqd7NEB Muu2urD/363oA== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: Pu Lehui , bpf@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Paul Walmsley , Palmer Dabbelt , Albert Ou , Pu Lehui , Pu Lehui Subject: Re: [PATCH bpf v3] riscv, bpf: Emit fixed-length instructions for BPF_PSEUDO_FUNC In-Reply-To: <20221206091410.1584784-1-pulehui@huaweicloud.com> References: <20221206091410.1584784-1-pulehui@huaweicloud.com> Date: Tue, 06 Dec 2022 11:57:55 +0100 Message-ID: <87fsds240c.fsf@all.your.base.are.belong.to.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pu Lehui writes: > From: Pu Lehui > > For BPF_PSEUDO_FUNC instruction, verifier will refill imm with > correct addresses of bpf_calls and then run last pass of JIT. > Since the emit_imm of RV64 is variable-length, which will emit > appropriate length instructions accorroding to the imm, it may > broke ctx->offset, and lead to unpredictable problem, such as > inaccurate jump. So let's fix it with fixed-length instructions. > > Fixes: 69c087ba6225 ("bpf: Add bpf_for_each_map_elem() helper") > Signed-off-by: Pu Lehui > Suggested-by: Bj=C3=B6rn T=C3=B6pel Thank you! Acked-by: Bj=C3=B6rn T=C3=B6pel Reviewed-by: Bj=C3=B6rn T=C3=B6pel