From: Andrew Ballance <andrewjballance@gmail.com>
To: Joel Fernandes <joelagnelf@nvidia.com>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
John Hubbard <jhubbard@nvidia.com>,
Alexandre Courbot <acourbot@nvidia.com>,
Timur Tabi <ttabi@nvidia.com>,
Alistair Popple <apopple@nvidia.com>,
Miguel Ojeda <ojeda@kernel.org>
Subject: Re: Printing with overflow checks can cause modpost errors
Date: Thu, 11 Sep 2025 19:27:26 -0500 [thread overview]
Message-ID: <aMNo7qRCp_yprUAW@my-computer> (raw)
In-Reply-To: <20250911213157.GA1039411@joelbox2>
On Thu, Sep 11, 2025 at 05:31:57PM -0400, Joel Fernandes wrote:
> Hello,
> Recently some of have been running into modpost errors more frequently. Ahead
> of Kangrejos, I am trying to study them, the one I looked at today is truly
> weird, below are more details.
>
> I narrowed it down to the print statement and specifically the FFI call to
> printk bindings. This was first reported by Timur Tabi on CC.
>
> With CONFIG_RUST_OVERFLOW_CHECKS=y and CONFIG_RUST_BUILD_ASSERT_ALLOW=y, the
> following patch when applied to nova-core will fail to build with following
> errors. The question is why does the overflow checking fail since the
> arithmetic is valid, and why only during printing (and say not during the
> call to write32).
>
> MODPOST Module.symvers
> ERROR: modpost: "rust_build_error" [drivers/gpu/nova-core/nova_core.ko] undefined!
> make[2]: *** [scripts/Makefile.modpost:147: Module.symvers] Error 1
> make[1]: *** [/home/joelaf/repo/linux-nova-rm-call/Makefile:1961: modpost] Error 2
> make: *** [Makefile:248: __sub-make] Error 2
>
> Any comments or thoughts?
>
Io::write32 tries to do a bounds check at compile time and if it cannot
be done it causes a build error. it looks like because a pointer to
offset is passed across a ffi boundary, rustc makes no assumptions about
the value of offset. so it cannot do the bounds check at compile time
and causes a build error.
Best regards,
Andrew Ballance
next prev parent reply other threads:[~2025-09-12 0:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-11 21:31 Printing with overflow checks can cause modpost errors Joel Fernandes
2025-09-12 0:27 ` Andrew Ballance [this message]
2025-09-12 2:53 ` Joel Fernandes
2025-09-12 4:08 ` Andrew Ballance
2025-09-12 8:27 ` Miguel Ojeda
2025-09-12 9:45 ` Alice Ryhl
2025-09-12 10:08 ` Miguel Ojeda
2025-09-16 10:32 ` Joel Fernandes
2025-09-16 10:48 ` Joel Fernandes
2025-09-16 18:52 ` Joel Fernandes
2025-09-17 23:18 ` Timur Tabi
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=aMNo7qRCp_yprUAW@my-computer \
--to=andrewjballance@gmail.com \
--cc=acourbot@nvidia.com \
--cc=apopple@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=ttabi@nvidia.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).