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 3D9F8C433F5 for ; Thu, 10 Mar 2022 03:48:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239296AbiCJDtu (ORCPT ); Wed, 9 Mar 2022 22:49:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231249AbiCJDtu (ORCPT ); Wed, 9 Mar 2022 22:49:50 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42D3D12A761; Wed, 9 Mar 2022 19:48:49 -0800 (PST) Received: from dggpeml500025.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KDZkL4Q8wzBrg3; Thu, 10 Mar 2022 11:46:50 +0800 (CST) Received: from [10.174.176.117] (10.174.176.117) by dggpeml500025.china.huawei.com (7.185.36.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 10 Mar 2022 11:48:46 +0800 Subject: Re: [PATCH bpf-next 3/4] bpf: Fix net.core.bpf_jit_harden race To: Alexei Starovoitov CC: Alexei Starovoitov , Martin KaFai Lau , Song Liu , John Fastabend , Yonghong Song , Daniel Borkmann , Andrii Nakryiko , "David S . Miller" , Jakub Kicinski , KP Singh , Network Development , bpf References: <20220309123321.2400262-1-houtao1@huawei.com> <20220309123321.2400262-4-houtao1@huawei.com> <20220309232253.v6oqev7jock7vm7i@ast-mbp.dhcp.thefacebook.com> <06abdc4e-8806-10dd-c753-229d3e957add@huawei.com> From: Hou Tao Message-ID: <60bfb6b5-5d2e-cfc2-cc68-2e016ed06918@huawei.com> Date: Thu, 10 Mar 2022 11:48:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.174.176.117] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500025.china.huawei.com (7.185.36.35) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Hi, On 3/10/2022 11:29 AM, Alexei Starovoitov wrote: > On Wed, Mar 9, 2022 at 5:01 PM Hou Tao wrote: >> Hi, >> >> On 3/10/2022 7:22 AM, Alexei Starovoitov wrote: >>> On Wed, Mar 09, 2022 at 08:33:20PM +0800, Hou Tao wrote: >>>> It is the bpf_jit_harden counterpart to commit 60b58afc96c9 ("bpf: fix >>>> net.core.bpf_jit_enable race"). bpf_jit_harden will be tested twice >>>> for each subprog if there are subprogs in bpf program and constant >>>> blinding may increase the length of program, so when running >>>> "./test_progs -t subprogs" and toggling bpf_jit_harden between 0 and 2, >>>> jit_subprogs may fail because constant blinding increases the length >>>> of subprog instructions during extra passs. >>>> >>>> So cache the value of bpf_jit_blinding_enabled() during program >>>> allocation, and use the cached value during constant blinding, subprog >>>> JITing and args tracking of tail call. >>> Looks like this patch alone is enough. >>> With race fixed. Patches 1 and 2 are no longer necessary, right? >> Yes and no. With patch 3 applied, the problems described in patch 1 and patch 2 >> are gone, but it may recur due to other issue in JIT. So I post these two patch >> together and hope these fixes can also be merged. > What kind of 'issues in JIT'? > I'd rather fix them than do defensive programming. Understand. For "issues in JIT" I just mean all kinds of error path handling in jit, not a real problem. > patch 2 is a hack that should not happen in a correct JIT. > . And "the hack" is partially due to the introduction of an extra pass in JIT. So I am fine to drop it. Regards, Tao