Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp960712rwb; Tue, 27 Sep 2022 06:49:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7xMFygMnx4tr7yLHONCCy+KYAchHlgFPDozc4X+Fpq3uXLVS73wAagqll+YYO2DViCRbVP X-Received: by 2002:a05:6a00:2446:b0:52b:e9a8:cb14 with SMTP id d6-20020a056a00244600b0052be9a8cb14mr29595619pfj.32.1664286579329; Tue, 27 Sep 2022 06:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664286579; cv=none; d=google.com; s=arc-20160816; b=i0igTfu2Dy75idXn6/paLJgAAZYrKjB8eY8KLvj6vMfmjy4Gq9AMCr7SRGat8TFdNH tci53WWaHJCnfvmu0yWhWsafosO2cDb+/J4yGUN7kSw+YwJDjtK9S49+QvTUbsVdLcja 8NTHa1Gw2z/WKV52So7wflJOeLNKi4hQ2RPxPptXPXqU5SI5OWIk1hEHlmGkMt/tL0/G jIzX6jqJPc8BWEzcwCL3AMBRkEiehpQ7cRtwlWUSNTAuV6X6DrSB1/fD+7AmsNkf/oh3 2lDnLdruHEJ6Vm+qT5FUaJAVEtJ6EycSd3OF91i/tVTnvXsi60mdfs1IxfHEZAf5tKba dK/Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bVLufyZ0Il1a3urayd/1xWuVo2UofE5J7JQGhusZR9Y=; b=owuR/eyV8y6HZKQzfE9avGyS9sHbAu6bG2CjGFKXpJu+v2il75VOZ01hOnmt3LVm3S AtHXBEm724UuX4lAD3kFN2LnE6U5ngckZBGQ4b/4FeEN5sAgQqFSVccUJRHEjujuFxba A/JY0HR5EhKBn3/2WM5UdfT9kKAIHXF58ZDzapD+s1E90sYqJCZCMlWgCcEOOUPBSDOc 9qbWSEqy0RG/FdfpG7JSBIARamr0Boxl4KALqUtuDAD/UEA8l1Ei2GB80PVSZaSTG8xA 0JJxLBFisAjRiaR3AW21RfH7BalZ84kKs2FXEtlqZHjhMiZtjT9eRmkdCsrAJ7xVHM0K FYLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M71Xih9A; 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 ip6-20020a17090b314600b0020317f7907bsi16561246pjb.4.2022.09.27.06.49.27; Tue, 27 Sep 2022 06:49:39 -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=M71Xih9A; 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 S232748AbiI0NTg (ORCPT + 99 others); Tue, 27 Sep 2022 09:19:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232723AbiI0NSk (ORCPT ); Tue, 27 Sep 2022 09:18:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F5311F2F5; Tue, 27 Sep 2022 06:17:10 -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 7EBF1B81BE2; Tue, 27 Sep 2022 13:16:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27313C433C1; Tue, 27 Sep 2022 13:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664284614; bh=s/UljI70Vv0SGpL736mlm7zLImOyzf9iXSKvkaxCaWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M71Xih9AdmGtPValy28Q23Ca6NgekVQzhMigg1Aj8UAxzaoT8ukkN9ChNkGeL9vGO tp/gA1EISSrr4KfuB1JNf6R1mq6a4s47uj2fcco1/C7DMwu1yAKGV/OlFsSTXlHeM7 R/RosiRymCLwE7eD4Vpu5EYZ3WW0VA73qFDTrFgWtkqzfWyBx2AKLXdl+GKhh49jY8 J/9wPWnmiqvU5Yn/Kccvb6uHXLB+IEtHNpWO97hxo4sizNrOXXRt7MGlb1YX1ry8UP mbRoadQRczwVSL/A/kvt4tU+qfGqfeBbC9OmpvIvCVr+tmkWb3tyGy43jaYNJDDjDv aC3XoGZ8bxFtQ== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Miguel Ojeda , Kees Cook , Alex Gaynor , Wedson Almeida Filho , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Boqun Feng , Gary Guo Subject: [PATCH v10 13/27] rust: export generated symbols Date: Tue, 27 Sep 2022 15:14:44 +0200 Message-Id: <20220927131518.30000-14-ojeda@kernel.org> In-Reply-To: <20220927131518.30000-1-ojeda@kernel.org> References: <20220927131518.30000-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 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 All symbols are reexported reusing the `EXPORT_SYMBOL_GPL` macro from C. The lists of symbols are generated on the fly. There are three main sets of symbols to distinguish: - The ones from the `core` and `alloc` crates (from the Rust standard library). The code is licensed as Apache/MIT. - The ones from our abstractions in the `kernel` crate. - The helpers (already exported since they are not generated). We export everything as GPL. This ensures we do not mistakenly expose GPL kernel symbols/features as non-GPL, even indirectly. Reviewed-by: Kees Cook Co-developed-by: Alex Gaynor Signed-off-by: Alex Gaynor Co-developed-by: Wedson Almeida Filho Signed-off-by: Wedson Almeida Filho Co-developed-by: Björn Roy Baron Signed-off-by: Björn Roy Baron Signed-off-by: Miguel Ojeda --- rust/exports.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 rust/exports.c diff --git a/rust/exports.c b/rust/exports.c new file mode 100644 index 000000000000..bb7cc64cecd0 --- /dev/null +++ b/rust/exports.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * A hack to export Rust symbols for loadable modules without having to redo + * the entire `include/linux/export.h` logic in Rust. + * + * This requires the Rust's new/future `v0` mangling scheme because the default + * one ("legacy") uses invalid characters for C identifiers (thus we cannot use + * the `EXPORT_SYMBOL_*` macros). + * + * All symbols are exported as GPL-only to guarantee no GPL-only feature is + * accidentally exposed. + */ + +#include + +#define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym) + +#include "exports_core_generated.h" +#include "exports_alloc_generated.h" +#include "exports_bindings_generated.h" +#include "exports_kernel_generated.h" -- 2.37.3