All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Peder Bergan" <peder.bergan@gmail.com>
Cc: linux-modules@vger.kernel.org, "Petr Pavlu" <petr.pavlu@suse.com>,
	ojeda@kernel.org, gary@garyguo.net
Subject: Re: [PATCH] rust: put C helper exports in a dedicated namespace
Date: Fri, 20 Nov 2026 16:46:02 +0000	[thread overview]
Message-ID: <sashiko-outbox-225583@kernel.org> (raw)
In-Reply-To: <20261120-rust-helper-namespace-v1-1-3b9a05553ff6@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] rust: missing RUST_HELPERS namespace import in kasan_test
  module
--

commit 42a51ff367154ba548e8d27e3154503fd972371b
Author: Peder Bergan <peder.bergan@gmail.com>

rust: put C helper exports in a dedicated namespace

This commit moves exported Rust C helpers into the RUST_HELPERS symbol
namespace and makes the Rust module! macro import that namespace when
helper inlining is disabled.

Link: https://github.com/Rust-for-Linux/linux/issues/216

> diff --git a/rust/macros/module.rs b/rust/macros/module.rs
> index 0a7b9e24c9600..ac3376fa8fb85 100644
> --- a/rust/macros/module.rs
> +++ b/rust/macros/module.rs
> @@ -467,6 +467,11 @@ pub(crate) fn module(info: ModuleInfo) -> Result<TokenStream> {
>          }
>      }
>  
> +    // Inlined kernel code can introduce calls to C helpers in any Rust module.
> +    if !cfg!(CONFIG_RUST_INLINE_HELPERS) {
> +        modinfo.emit_only_loadable("import_ns", "RUST_HELPERS", false);
> +    }
> +
>      // Built-in modules also export the `file` modinfo string.
>      let file =
>          std::env::var("RUST_MODFILE").expect("Unable to fetch RUST_MODFILE environmental variable");

[Severity: Medium]
Does this break the build of kasan_test.ko when CONFIG_KASAN_KUNIT_TEST=m,
CONFIG_RUST=y, and CONFIG_RUST_INLINE_HELPERS=n?

kasan_test is a composite C and Rust module (kasan_test_c.o and
kasan_test_rust.o in mm/kasan/Makefile) that defines its module metadata
in mm/kasan/kasan_test_c.c rather than with module!.
kasan_test_rust_uaf() in mm/kasan/kasan_test_rust.rs uses KVec::push() and
drops the vector, which inline into calls to
rust_helper_krealloc_node_align.  Because neither mm/kasan/kasan_test_c.c
nor mm/kasan/kasan_test_rust.rs imports RUST_HELPERS, modpost rejects
kasan_test.ko for using a symbol from RUST_HELPERS without importing the
namespace.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-rust-helper-namespace-v1-1-3b9a05553ff6@gmail.com?part=1

      reply	other threads:[~2026-11-20 16:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 16:32 [PATCH] rust: put C helper exports in a dedicated namespace Peder Bergan
2026-11-20 16:32 ` Peder Bergan via B4 Relay
2026-11-20 16:46 ` sashiko-bot [this message]

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=sashiko-outbox-225583@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-modules@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=peder.bergan@gmail.com \
    --cc=petr.pavlu@suse.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.