From: FUJITA Tomonori <tomo@flapping.org>
To: ojeda@kernel.org
Cc: a.hindborg@kernel.org, acourbot@nvidia.com, aliceryhl@google.com,
bjorn3_gh@protonmail.com, boqun@kernel.org, dakr@kernel.org,
daniel.almeida@collabora.com, gary@garyguo.net,
lossin@kernel.org, tamird@kernel.org, tmgross@umich.edu,
work@onurozkan.dev, rust-for-linux@vger.kernel.org,
FUJITA Tomonori <fujita.tomonori@gmail.com>
Subject: [PATCH v1 1/2] rust: bug: document when to use the WARN macros
Date: Sat, 3 Oct 2026 21:39:02 +0900 [thread overview]
Message-ID: <20261003123903.113572-2-tomo@flapping.org> (raw)
In-Reply-To: <20261003123903.113572-1-tomo@flapping.org>
From: FUJITA Tomonori <fujita.tomonori@gmail.com>
Add a note to the module documentation, based on the comment in
`include/asm-generic/bug.h`: use the WARN macros only for kernel bugs,
not for invalid inputs from user space, the network or devices.
Also mention `panic_on_warn`, since a warning can then crash the
machine.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
---
rust/kernel/bug.rs | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/rust/kernel/bug.rs b/rust/kernel/bug.rs
index 6abed2c055b1..569dc05d75ad 100644
--- a/rust/kernel/bug.rs
+++ b/rust/kernel/bug.rs
@@ -4,6 +4,11 @@
//! Support for BUG and WARN functionality.
//!
+//! Use the WARN macros only for kernel bugs that the kernel can recover
+//! from. Do not use them for invalid inputs from user space, the network or
+//! devices, or for transient conditions like `ENOMEM` or `EAGAIN`. A warning
+//! can crash the machine when `panic_on_warn` is enabled.
+//!
//! C header: [`include/asm-generic/bug.h`](srctree/include/asm-generic/bug.h)
#[macro_export]
--
2.43.0
next prev parent reply other threads:[~2026-10-03 12:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-03 12:39 [PATCH v1 0/2] rust: bug: add warn_once macro FUJITA Tomonori
2026-10-03 12:39 ` FUJITA Tomonori [this message]
2026-10-04 8:08 ` [PATCH v1 1/2] rust: bug: document when to use the WARN macros Andreas Hindborg
2026-10-03 12:39 ` [PATCH v1 2/2] rust: bug: add warn_once macro FUJITA Tomonori
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=20261003123903.113572-2-tomo@flapping.org \
--to=tomo@flapping.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox