From patchwork Sat Oct 22 07:18:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7451 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1098519wrr; Sat, 22 Oct 2022 01:11:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4qX6YZo0C34QNMWeSUA67Fx8bTPXruVwtIFGNaXbtCh2Lymh5HjoIwDAnPjYElEU5+ZHVO X-Received: by 2002:a17:903:4d7:b0:178:8564:f754 with SMTP id jm23-20020a17090304d700b001788564f754mr23212563plb.60.1666426265767; Sat, 22 Oct 2022 01:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666426265; cv=none; d=google.com; s=arc-20160816; b=YpQaZ9mX/qPJ+ZEy5AP/jgxiKxjOMIg1xMcxS9yobfbCN/yy9xwM0M6gYp4lUKTsGi HHK+EzaRdMhK1Y32OZOUu4GQ+LZZIJcoSrZFEWxXaOC3LLhJ/ZhNYPLDC46dgTjd+0xJ AzBpOkaerr6c1jELa3AI/6GyAqlWajkRc4UWwD7teEPHWSntLcq7/90Da1eZlmj/6n1o zZexABCZUQFZ4pSBUrb0IHJgfT/djRh965DOy1O9gz0hI8HRtfXiiPABjefzRzbmC2ez 0okEX2DuF0XHcLGtmHnihOiBEEAHsAsXHi4B/LLeb1FyWziTBLh8aNri2PXIysbBkx67 y8mg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19-20020a170902c21300b001867a6a1791si4174903pll.426.2022.10.22.01.10.52; Sat, 22 Oct 2022 01:11:05 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747374588349112761?= X-GMAIL-MSGID: =?utf-8?q?1747374588349112761?= 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;