From: Wedson Almeida Filho <wedsonaf@gmail.com>
To: Benno Lossin <benno.lossin@proton.me>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@samsung.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Martin Rodriguez Reboredo" <yakoyoku@gmail.com>,
"Asahi Lina" <lina@asahilina.net>,
"Sumera Priyadarsini" <sylphrenadin@gmail.com>,
"Neal Gompa" <neal@gompa.dev>,
"Thomas Bertschinger" <tahbertschinger@gmail.com>,
"Andrea Righi" <andrea.righi@canonical.com>,
"Matthew Bakhtiari" <dev@mtbk.me>,
"Adam Bratschi-Kaye" <ark.email@gmail.com>,
stable@vger.kernel.org, "Masahiro Yamada" <masahiroy@kernel.org>,
"Wedson Almeida Filho" <wedsonaf@google.com>,
"Finn Behrens" <me@kloenk.dev>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] rust: macros: fix soundness issue in `module!` macro
Date: Mon, 1 Apr 2024 16:42:23 -0300 [thread overview]
Message-ID: <CANeycqracHqSh0AS3sSWerMA=tGUWs7U=iPfnL+UzqBQs1oUZw@mail.gmail.com> (raw)
In-Reply-To: <20240401185222.12015-1-benno.lossin@proton.me>
On Mon, 1 Apr 2024 at 15:52, Benno Lossin <benno.lossin@proton.me> wrote:
>
> The `module!` macro creates glue code that are called by C to initialize
> the Rust modules using the `Module::init` function. Part of this glue
> code are the local functions `__init` and `__exit` that are used to
> initialize/destroy the Rust module.
> These functions are safe and also visible to the Rust mod in which the
> `module!` macro is invoked. This means that they can be called by other
> safe Rust code. But since they contain `unsafe` blocks that rely on only
> being called at the right time, this is a soundness issue.
>
> Wrap these generated functions inside of two private modules, this
> guarantees that the public functions cannot be called from the outside.
> Make the safe functions `unsafe` and add SAFETY comments.
>
> Cc: stable@vger.kernel.org
> Closes: https://github.com/Rust-for-Linux/linux/issues/629
> Fixes: 1fbde52bde73 ("rust: add `macros` crate")
> Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Wedson Almeida Filho <walmeida@microsoft.com>
next prev parent reply other threads:[~2024-04-01 19:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-01 18:52 [PATCH v2] rust: macros: fix soundness issue in `module!` macro Benno Lossin
2024-04-01 19:42 ` Wedson Almeida Filho [this message]
2024-04-01 21:10 ` Boqun Feng
2024-04-01 22:01 ` Benno Lossin
2024-04-01 22:17 ` Boqun Feng
2024-04-02 12:47 ` Benno Lossin
2024-04-07 20:02 ` Miguel Ojeda
2024-04-16 17:07 ` Boqun Feng
2024-04-16 19:36 ` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANeycqracHqSh0AS3sSWerMA=tGUWs7U=iPfnL+UzqBQs1oUZw@mail.gmail.com' \
--to=wedsonaf@gmail.com \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=andrea.righi@canonical.com \
--cc=ark.email@gmail.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dev@mtbk.me \
--cc=gary@garyguo.net \
--cc=lina@asahilina.net \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=me@kloenk.dev \
--cc=neal@gompa.dev \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=sylphrenadin@gmail.com \
--cc=tahbertschinger@gmail.com \
--cc=wedsonaf@google.com \
--cc=yakoyoku@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).