Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5371997rwb; Wed, 21 Sep 2022 07:02:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4PFCt95Obe5CHUL7xOsNIAZsK5MUP/nVNjtyPCEA1ZaGrudcqC45+qbf3H5Bj4+c3OidZm X-Received: by 2002:a17:903:228c:b0:178:3bc7:8a3f with SMTP id b12-20020a170903228c00b001783bc78a3fmr4942126plh.88.1663768924936; Wed, 21 Sep 2022 07:02:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663768924; cv=none; d=google.com; s=arc-20160816; b=OlFCITl32WJkcmLyVB6Xly8RLLICCCUwfQlWNBeqTh2Tq4PadTSa6AlMCPMGwFcR5d 5LmLTB/AFOMUvQ86WF/yk+rJNKyRgBA4Ue+aXldhvl8IXao4APv4wNh4UeX63XqO6Dy4 zndjn2M+uA+7AHQF66wC6Mtoc47HCTBO9tBWPOdfDADOuibH91ub/NSiIUS41UAwMNV+ huWJhSu6Ilb9OfgP3d6HOFJkiX5g8s/e4raoauanWOGTX0VZ1da9Iq37L00iL/Gwrl8j p36s7eX0vf+UtI1cZqJ8JcCKmaYW5NSG9j/dekob7ssZHCM/VDVovjNC7rIdUjKzqAia QL2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Gmuw7RYv066IxRae4zmwgZqYaBan3eu2R7Ak+x42SkI=; b=D+j7QVep31tKgYWpJLd1oI/glEEv5vo0Ma3/T/3HEMgT7li6ia1j2zZ3AOmLRQHh8c QZK5I7v9aeepVaLLhQBANWrFkQADM9RdBnDHbx+IhTi0MyVbxCo8ifR1oZnnyHMsjQDq l55TtOA5H6TVPYna/l41Oa+jFmuOGM9wz4RRekEVNM+xA0SqR9LIPsbyWFx6druCBPxa gD9OjfHeHGDZTTwF5ow10VWR+FGcSQjsz8Xtu8tPPNA6FQQJH8YQz//DEOaTfEnOBe+H w3lYsBo/DtN3WPYwyLvhZPOzuWLCUBclfbfNcGnk0UsB56s2bsWGPzfKMxq9Z6Vox56O gj5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=epzRSJ0j; 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 l7-20020a170902f68700b00172889e9ea9si3092375plg.583.2022.09.21.07.01.36; Wed, 21 Sep 2022 07:02:04 -0700 (PDT) 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=epzRSJ0j; 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 S229560AbiIUNnv (ORCPT + 99 others); Wed, 21 Sep 2022 09:43:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbiIUNnm (ORCPT ); Wed, 21 Sep 2022 09:43:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E5556E2EF for ; Wed, 21 Sep 2022 06:43:41 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id CDD3CB82FC5 for ; Wed, 21 Sep 2022 13:43:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 930CBC43142 for ; Wed, 21 Sep 2022 13:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663767818; bh=Gmuw7RYv066IxRae4zmwgZqYaBan3eu2R7Ak+x42SkI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=epzRSJ0jyAlPZ16JH3+XPj16W+fgflBh69EoIUoCn+iYNALhGhq0EGN7hyvK6/xnz tCrpO2MgL9f/JKcaFVIpdYkwWnKD81N8BqNwoKaIfVpULQLmOvz2ZVdroMjawrta0o ltKZ/KorHpLGLupVh7L0N+yDipDQXa6ThxHz29DxoZb9DXxNv+/aKxvEEYH4WGYHYT oaAootsA0LfuR1MUG3VujCM5P1GmGhokDptfnnqRKL295GKdkC9Z7vl9faJN982WEV SSAWusvTxydhhjpXEPqqtH0teulP5+KXcoBUaMngLqObOmac7yPzK5i/UYTPtLUnEo byWIA2B/BIBDA== Received: by mail-lf1-f53.google.com with SMTP id k10so9291726lfm.4 for ; Wed, 21 Sep 2022 06:43:38 -0700 (PDT) X-Gm-Message-State: ACrzQf356T7NmSu2tpaiTnPTkpr0X+riNeXky2vVZUKDt/mm3NI2WK1/ njw1uuy3tzDFTxBNBdFvvwuf9x343nLhmOlA8UHIkA== X-Received: by 2002:a2e:920a:0:b0:26c:f7b:95db with SMTP id k10-20020a2e920a000000b0026c0f7b95dbmr9324650ljg.156.1663767805783; Wed, 21 Sep 2022 06:43:25 -0700 (PDT) MIME-Version: 1.0 References: <20220920075951.929132-1-roberto.sassu@huaweicloud.com> <20220920075951.929132-3-roberto.sassu@huaweicloud.com> In-Reply-To: <20220920075951.929132-3-roberto.sassu@huaweicloud.com> From: KP Singh Date: Wed, 21 Sep 2022 15:43:14 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v18 02/13] btf: Export bpf_dynptr definition To: Roberto Sassu Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, sdf@google.com, haoluo@google.com, jolsa@kernel.org, mykolal@fb.com, dhowells@redhat.com, jarkko@kernel.org, rostedt@goodmis.org, mingo@redhat.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, shuah@kernel.org, bpf@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, deso@posteo.net, memxor@gmail.com, Roberto Sassu , stable@vger.kernel.org, Joanne Koong Content-Type: text/plain; charset="UTF-8" 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=unavailable 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 On Tue, Sep 20, 2022 at 10:01 AM Roberto Sassu wrote: > > From: Roberto Sassu > > eBPF dynamic pointers is a new feature recently added to upstream. It binds > together a pointer to a memory area and its size. The internal kernel > structure bpf_dynptr_kern is not accessible by eBPF programs in user space. > They instead see bpf_dynptr, which is then translated to the internal > kernel structure by the eBPF verifier. > > The problem is that it is not possible to include at the same time the uapi > include linux/bpf.h and the vmlinux BTF vmlinux.h, as they both contain the > definition of some structures/enums. The compiler complains saying that the > structures/enums are redefined. > > As bpf_dynptr is defined in the uapi include linux/bpf.h, this makes it > impossible to include vmlinux.h. However, in some cases, e.g. when using > kfuncs, vmlinux.h has to be included. The only option until now was to > include vmlinux.h and add the definition of bpf_dynptr directly in the eBPF > program source code from linux/bpf.h. > > Solve the problem by using the same approach as for bpf_timer (which also > follows the same scheme with the _kern suffix for the internal kernel > structure). > > Add the following line in one of the dynamic pointer helpers, > bpf_dynptr_from_mem(): > > BTF_TYPE_EMIT(struct bpf_dynptr); > > Cc: stable@vger.kernel.org > Cc: Joanne Koong > Fixes: 97e03f521050c ("bpf: Add verifier support for dynptrs") > Signed-off-by: Roberto Sassu > Acked-by: Yonghong Song I tested this out and it works, however for the BPF signing use case where "bpf_dynptr_kern" is added to struct bpf_prog_aux one still ends up defining the __ksym extern with bpf_dynptr_kern. But let's discuss that when the series is posted. Tested-by: KP Singh