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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE15DC352A1 for ; Tue, 6 Dec 2022 10:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231950AbiLFK6E (ORCPT ); Tue, 6 Dec 2022 05:58:04 -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 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