linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] docs: deprecated.rst: Add BUG()-family
@ 2020-03-14 22:29 Kees Cook
  2020-03-20 23:26 ` Jonathan Corbet
  0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2020-03-14 22:29 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: Gustavo A. R. Silva, Linus Torvalds, Joe Perches, linux-doc,
	linux-kernel

Linus continues to remind[1] people to stop using the BUG()-family of
functions. We should have this better documented (even if checkpatch.pl
has been warning[2] since 2015), so add more details to deprecated.rst,
as a distinct place to point people to for guidance.

[1] https://lore.kernel.org/lkml/CAHk-=whDHsbK3HTOpTF=ue_o04onRwTEaK_ZoJp_fjbqq4+=Jw@mail.gmail.com/
[2] https://git.kernel.org/linus/9d3e3c705eb395528fd8f17208c87581b134da48

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 Documentation/process/deprecated.rst | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
index 8965446f0b71..38843c7a9ad6 100644
--- a/Documentation/process/deprecated.rst
+++ b/Documentation/process/deprecated.rst
@@ -29,6 +29,28 @@ a header file, it isn't the full solution. Such interfaces must either
 be fully removed from the kernel, or added to this file to discourage
 others from using them in the future.
 
+BUG() and BUG_ON()
+------------------
+Use WARN() and WARN_ON() instead, and handle the "impossible"
+error condition as gracefully as possible. While the BUG()-family
+of APIs were originally designed to act as an "impossible situation"
+assert and to kill a kernel thread "safely", they turn out to just be
+too risky. (e.g. "In what order do locks need to be released? Have
+various states been restored?") Very commonly, using BUG() will
+destabilize a system or entirely break it, which makes it impossible
+to debug or even get viable crash reports. Linus has `very strong
+<https://lore.kernel.org/lkml/CA+55aFy6jNLsywVYdGp83AMrXBo_P-pkjkphPGrO=82SPKCpLQ@mail.gmail.com/>`_
+feelings `about this
+<https://lore.kernel.org/lkml/CAHk-=whDHsbK3HTOpTF=ue_o04onRwTEaK_ZoJp_fjbqq4+=Jw@mail.gmail.com/>`_.
+
+Note that the WARN()-family should only be used for "expected to
+be unreachable" situations. If you want to warn about "reachable
+but undesirable" situations, please use the pr_warn()-family of
+functions. System owners may have set the *panic_on_warn* sysctl,
+to make sure their systems do not continue running in the face of
+"unreachable" conditions. (For example, see commits like `this one
+<https://git.kernel.org/linus/d4689846881d160a4d12a514e991a740bcb5d65a>`_.)
+
 open-coded arithmetic in allocator arguments
 --------------------------------------------
 Dynamic size calculations (especially multiplication) should not be
-- 
2.20.1


-- 
Kees Cook

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] docs: deprecated.rst: Add BUG()-family
  2020-03-14 22:29 [PATCH] docs: deprecated.rst: Add BUG()-family Kees Cook
@ 2020-03-20 23:26 ` Jonathan Corbet
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Corbet @ 2020-03-20 23:26 UTC (permalink / raw)
  To: Kees Cook
  Cc: Gustavo A. R. Silva, Linus Torvalds, Joe Perches, linux-doc,
	linux-kernel

On Sat, 14 Mar 2020 15:29:50 -0700
Kees Cook <keescook@chromium.org> wrote:

> Linus continues to remind[1] people to stop using the BUG()-family of
> functions. We should have this better documented (even if checkpatch.pl
> has been warning[2] since 2015), so add more details to deprecated.rst,
> as a distinct place to point people to for guidance.
> 
> [1] https://lore.kernel.org/lkml/CAHk-=whDHsbK3HTOpTF=ue_o04onRwTEaK_ZoJp_fjbqq4+=Jw@mail.gmail.com/
> [2] https://git.kernel.org/linus/9d3e3c705eb395528fd8f17208c87581b134da48
> 
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  Documentation/process/deprecated.rst | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)

Applied, thanks.

jon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-20 23:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-14 22:29 [PATCH] docs: deprecated.rst: Add BUG()-family Kees Cook
2020-03-20 23:26 ` Jonathan Corbet

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).