Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3912054rwi; Sat, 22 Oct 2022 02:04:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7AsaEAQszTJNTb1H62IAz8S3rppUWC41qDZt6gRxLMw0/LfX8lP5Z6abAW4VkTVgZfDIw5 X-Received: by 2002:a63:6b49:0:b0:46a:fcba:308f with SMTP id g70-20020a636b49000000b0046afcba308fmr19913278pgc.8.1666429480992; Sat, 22 Oct 2022 02:04:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666429480; cv=none; d=google.com; s=arc-20160816; b=LJMzvQXfLL6dFHIvgAdbcWyO0+yl22Q8VD0dneEyju5/k7yXXIKuDDyo7/DjEZwIBH f3mvxd/MMmb2TfjHl5zGgtm/YeOdaCuCv+myez9ge8BiHHYrUq1Fhg8u2LkO5rHFTxpt q/wm02f/YRlpIamXZLqN9KN5fnuZqK53Xa5hOWzqYha7vU5wvuZruMXTG52RPWLKXv8/ gjPaDPE4cCvRr+EZ7XKpU7TZfbBm2jhzWoaWcNuF0InqiR/ZFIQU7xphxFzTAQB41LFc 5HZpbOGkHB5TONI8ARWnFiuoQzQ30us/v0W3uO0lC61AuhU8oparxy+4HLYML5QcyIPw OWNA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=642PGjFqDZ0CGtOhYVSVDmanyvQBYmUfzM1qcwgz9LE=; b=H5jyNQtzFE1bsvNMsV4Z6taUwpuiOdKIvFpAxnUVG0DW0sIkp5C0pc3TNYlK/XSy6h 4NYmBKgZTBqcXGacfVdOqMBDXyk9LPs/yP6OVVB+503kBfZ5dYhaEJd1Jzk/nBi3+lm0 o79DIfrd0pGxokdWBKJFcI7OdcDQ8beKLd62CQD3Bs4MkER2ruBA/GAzOWhAzK81v11S 9ZiZ8y09ZN349NnSsQtjZK4L7eddnXeU1/E4dAvgU0/fLDZwcT744aMqiY9mcyIY7MXs 2c59L9W1T3H/PdSagpB2Ng30Rx/4+XJDkB1HO29rmKL3rj39lzniRHGqPK3bglNk/Ked 769Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="vsFjGY/O"; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020a170903110f00b00178b88d40ebsi32876934plh.51.2022.10.22.02.04.29; Sat, 22 Oct 2022 02:04:40 -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=@linuxfoundation.org header.s=korg header.b="vsFjGY/O"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233483AbiJVIJ5 (ORCPT + 99 others); Sat, 22 Oct 2022 04:09:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232685AbiJVIFj (ORCPT ); Sat, 22 Oct 2022 04:05:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE2862C6E26; Sat, 22 Oct 2022 00:52:54 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 423F560ADE; Sat, 22 Oct 2022 07:37:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54CE8C433D6; Sat, 22 Oct 2022 07:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424228; bh=CJh7BEGtcX3x0wey5F8aR0SgwStg4GuMXPmHzzulGjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vsFjGY/O5L3RP3TCR/3fHwBe/YmAhXpJFoUokAYYPKhmz05fqbSSUvAtEfrIKoRT4 XG3x265OKh1z/ZfMXZ+Li3p1516Q4mhfruSuZOUJKWHpAvf22fe5rkX/D3eyaM4J/i KIsc6VPkTQPxRRnfhTUN64jKkjarT+Y0C7gjpssY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joanne Koong , Roberto Sassu , Yonghong Song , KP Singh , Alexei Starovoitov Subject: [PATCH 5.19 039/717] btf: Export bpf_dynptr definition Date: Sat, 22 Oct 2022 09:18:38 +0200 Message-Id: <20221022072422.045996090@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 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 From: Roberto Sassu commit 00f146413ccb6c84308e559281449755c83f54c5 upstream. 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 Tested-by: KP Singh Link: https://lore.kernel.org/r/20220920075951.929132-3-roberto.sassu@huaweicloud.com Signed-off-by: Alexei Starovoitov Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/helpers.c | 2 ++ 1 file changed, 2 insertions(+) --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -1468,6 +1468,8 @@ BPF_CALL_4(bpf_dynptr_from_mem, void *, { int err; + BTF_TYPE_EMIT(struct bpf_dynptr); + err = bpf_dynptr_check_size(size); if (err) goto error;