提交 a2f88993 编写于 作者: X Xia Fukun 提交者: Yongqiang Liu

signal handling: don't use BUG_ON() for debugging

stable inclusion
from stable-v4.19.267
commit 93d9cef55f8fe463e3b9f6c73c7a32619222c657
category: bugfix
bugzilla: 187828, https://gitee.com/openeuler/kernel/issues/I63UEU
CVE: NA

--------------------------------

[ Upstream commit a382f8fe ]

These are indeed "should not happen" situations, but it turns out recent
changes made the 'task_is_stopped_or_trace()' case trigger (fix for that
exists, is pending more testing), and the BUG_ON() makes it
unnecessarily hard to actually debug for no good reason.

It's been that way for a long time, but let's make it clear: BUG_ON() is
not good for debugging, and should never be used in situations where you
could just say "this shouldn't happen, but we can continue".

Use WARN_ON_ONCE() instead to make sure it gets logged, and then just
continue running.  Instead of making the system basically unusuable
because you crashed the machine while potentially holding some very core
locks (eg this function is commonly called while holding 'tasklist_lock'
for writing).
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NXia Fukun <xiafukun@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 eaab6483
...@@ -1831,12 +1831,12 @@ bool do_notify_parent(struct task_struct *tsk, int sig) ...@@ -1831,12 +1831,12 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
bool autoreap = false; bool autoreap = false;
u64 utime, stime; u64 utime, stime;
BUG_ON(sig == -1); WARN_ON_ONCE(sig == -1);
/* do_notify_parent_cldstop should have been called instead. */ /* do_notify_parent_cldstop should have been called instead. */
BUG_ON(task_is_stopped_or_traced(tsk)); WARN_ON_ONCE(task_is_stopped_or_traced(tsk));
BUG_ON(!tsk->ptrace && WARN_ON_ONCE(!tsk->ptrace &&
(tsk->group_leader != tsk || !thread_group_empty(tsk))); (tsk->group_leader != tsk || !thread_group_empty(tsk)));
if (sig != SIGCHLD) { if (sig != SIGCHLD) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册