Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rust: export generated symbols

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 <keescook@chromium.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Co-developed-by: Alex Gaynor <alex.gaynor@gmail.com>
Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
Co-developed-by: Wedson Almeida Filho <wedsonaf@google.com>
Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
Co-developed-by: Björn Roy Baron <bjorn3_gh@protonmail.com>
Signed-off-by: Björn Roy Baron <bjorn3_gh@protonmail.com>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

+21
+21
rust/exports.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * A hack to export Rust symbols for loadable modules without having to redo 4 + * the entire `include/linux/export.h` logic in Rust. 5 + * 6 + * This requires the Rust's new/future `v0` mangling scheme because the default 7 + * one ("legacy") uses invalid characters for C identifiers (thus we cannot use 8 + * the `EXPORT_SYMBOL_*` macros). 9 + * 10 + * All symbols are exported as GPL-only to guarantee no GPL-only feature is 11 + * accidentally exposed. 12 + */ 13 + 14 + #include <linux/module.h> 15 + 16 + #define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym) 17 + 18 + #include "exports_core_generated.h" 19 + #include "exports_alloc_generated.h" 20 + #include "exports_bindings_generated.h" 21 + #include "exports_kernel_generated.h"