Skip to contentSkip to conversation

arch/x86: Return value from notify_die should to be checked.

PATCH In review Bo YU 4 participants 5 messages Jun 21, 2020 – Jun 22, 2020 x86

lore
Share & tools
lore

Bo YU

author
#0 lore raw

PATCH 1/1 arch/x86: Return value from notify_die should to be checked.

This is detected by Coverity scan: #CID: 1464472(CHECKED_RETURN)

Fixes c94082656dac7(x86: Use enum instead of literals for trap values)

---
arch/x86/kernel/traps.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/traps.c +0 -0
index af75109485c2..bf014fb59017 100644
@@ -401,7 +401,8 @@ DEFINE_IDTENTRY_DF(exc_double_fault)
 
	nmi_enter();
	instrumentation_begin();

- notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV);
+ if (notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV))
+ return;

	tsk->thread.error_code = error_code;
	tsk->thread.trap_nr = X86_TRAP_DF;

--
2.11.0

#1 lore raw
Quoted 13 lines · Bo YU

This is detected by Coverity scan: #CID: 1464472(CHECKED_RETURN)

Fixes c94082656dac7(x86: Use enum instead of literals for trap values)

---
arch/x86/kernel/traps.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/traps.c +0 -0
index af75109485c2..bf014fb59017 100644

arch/x86/kernel/traps.c DEFINE_IDTENTRY_DF(exc_double_fault) · line 406

Quoted 7 lines
arch/x86/kernel/traps.c +2 -1
@@ -401,7 +401,8 @@ DEFINE_IDTENTRY_DF(exc_double_fault)
 
     nmi_enter();
     instrumentation_begin();
-    notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV);
+    if (notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV))
+        return;
 

This change is not correct, if there's a double fault then we should die even if notify_die() fails. So the appropriate change to make Coverity happy is probably:

(void) notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV);

alex.

maintainer
#2 lore raw
Quoted 1 line · Alexandre Chartre

So the appropriate change to make Coverity happy

Or we can stop "fixing" the kernel in order to shut up tools and not do anything.

Signature · 1 line
Sent from a small device: formatting sux and brevity is inevitable.
#3 lore raw
Quoted 4 lines · Boris Petkov
Quoted 1 line · Alexandre Chartre

So the appropriate change to make Coverity happy

Or we can stop "fixing" the kernel in order to shut up tools and not do anything.

Agreed, no change required here.

author
#4 lore raw
Quoted 8 lines · Peter Zijlstra
Quoted 4 lines · Boris Petkov
Quoted 1 line · Alexandre Chartre

So the appropriate change to make Coverity happy

Or we can stop "fixing" the kernel in order to shut up tools and not do anything.

Agreed, no change required here.

Ok, thanks for everyone.