From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 04FE0A0471 for ; Mon, 12 Aug 2019 13:37:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D82441BE89; Mon, 12 Aug 2019 13:37:55 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 5CFED49E0; Mon, 12 Aug 2019 13:37:52 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Aug 2019 04:37:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,377,1559545200"; d="scan'208";a="183533693" Received: from irsmsx153.ger.corp.intel.com ([163.33.192.75]) by FMSMGA003.fm.intel.com with ESMTP; 12 Aug 2019 04:37:50 -0700 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.73]) by IRSMSX153.ger.corp.intel.com ([169.254.9.121]) with mapi id 14.03.0439.000; Mon, 12 Aug 2019 12:37:49 +0100 From: "Ananyev, Konstantin" To: Jerin Jacob Kollanukkaran , "dev@dpdk.org" CC: "thomas@monjalon.net" , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] bpf: fix to allow ptr stack program type Thread-Index: AQHVTs+w6eiuBSAK7kqssbVdAgwC16b3NM2AgAAPwwCAAB4uUA== Date: Mon, 12 Aug 2019 11:37:49 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258018115D7C8@irsmsx105.ger.corp.intel.com> References: <20190809162919.5967-1-jerinj@marvell.com> <2601191342CEEE43887BDE71AB977258018115CEAE@irsmsx105.ger.corp.intel.com> In-Reply-To: Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTAwODY3YjctNzFlMS00Y2ZjLWEyZDItNzdhMzkxM2I1YWNmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiY3RURjBmVGhZKzFQWldaUDRkZEJwcWtBbklwbERDQ3FWMkllN3lRXC9qSVA2VU1GRWRZS1VKVXBoM1N5azJvUjMifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] bpf: fix to allow ptr stack program type X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" > > Hi Jerin, >=20 > Hi Konstantin, >=20 > > > > > > > > bpf_validate does not allow to execute RTE_BPF_ARG_PTR_STACK for no > > > reason. > > > > I believe there is a reason, > > ARG_PTR_STACK is reserved for memory within BPF program internal stack > > only. > > User that calls BPF program should never pass parameter with that type. >=20 > OK. > Shouldn't we remove that from public header file > (lib/librte_bpf/rte_bpf.h) then ? Probably... or might be just put extra comments to mark it as internal? The reason I left it here, so we can add new public values for enum here, before RTE_BPF_ARG_PTR_STACK. Of course in theory we can use for RTE_BPF_ARG_PTR_STACK some reserved value instead. >=20 > > If the user allocates parameter for bpf function on the stack, he can s= till use > > RTE_BPF_ARG_PTR for it. >=20 > I see the _stack_ is only allocated under RTE_BPF_ARG_PTR_STACK checks in= bpf_validate.c. > Can you check? I agree that stack should be allocated for RTE_BPF_ARG_PTR= as well. Not sure I understand your query here... Each BPF program can use up to MAX_BPF_STACK_SIZE bytes for stack. Though to avoid JIT to allocate unused space for the stack, in bpf_validate= .c we figure out does given BPF program really allocate things on the stack an= d if yes, how many bytes is needed. This info is stored in rte_bpf.stack_sz and can be used later by the JIT. Let say for x86 jit is used in emit_prolog(). >=20 > I am writing the arm64 JIT support now, I see always stack of size of 0. = I did not spend much > Time on the generic piece of ebpf code(Focusing only on JIT side now). >=20 > Can you share more detail the stack allocation scheme, Is validate code p= arse the eBPF opcode and > Figure out the stack depth it by its own and pass to JIT function where A= rch code can allocate > enough stack. Yep, see above. Konstantin >=20 >=20 > > > > > Fix it by enhancing the prog_arg.type check. > > > > > > Fixes: 6e12ec4c4d6d ("bpf: add more checks") > > > Cc: stable@dpdk.org > > > > > > Signed-off-by: Jerin Jacob > > > --- > > > lib/librte_bpf/bpf_validate.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/lib/librte_bpf/bpf_validate.c > > > b/lib/librte_bpf/bpf_validate.c index 0cf41fa27..c75777b6d 100644 > > > --- a/lib/librte_bpf/bpf_validate.c > > > +++ b/lib/librte_bpf/bpf_validate.c > > > @@ -2216,6 +2216,7 @@ bpf_validate(struct rte_bpf *bpf) > > > > > > /* check input argument type, don't allow mbuf ptr on 32-bit */ > > > if (bpf->prm.prog_arg.type !=3D RTE_BPF_ARG_RAW && > > > + bpf->prm.prog_arg.type !=3D > > RTE_BPF_ARG_PTR_STACK && > > > bpf->prm.prog_arg.type !=3D RTE_BPF_ARG_PTR && > > > (sizeof(uint64_t) !=3D sizeof(uintptr_t) || > > > bpf->prm.prog_arg.type !=3D > > RTE_BPF_ARG_PTR_MBUF)) { > > > -- > > > 2.22.0