x86/kernel: Fix unchecked return value
Subsystems (3)
From the coverity scan analysis, the return value from insn_decode_kernel is not checked. It is a macro constructed from the insn_decode function which may fail and return negative integer. Fix this by explicitly checking the return value.
Addresses-Coverity: ("Unchecked return value")
--- arch/x86/kernel/jump_label.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/jump_label.c +1 -1
@@ -23,7 +23,7 @@ int arch_jump_entry_size(struct jump_entry *entry) {struct insn insn = {}; -insn_decode_kernel (&insn, (void *)jump_entry_code (entry)); +WARN_ON (insn_decode_kernel (&insn, (void *)jump_entry_code (entry)));BUG_ON (insn.length !=2 && insn.length !=5 );return insn.length;
Signature · 1 line
2.17.1
Borislav Petkov
maintainerQuoted 17 lines · Khaled ROMDHANI
From the coverity scan analysis, the return value from
insn_decode_kernelis not checked. It is a macro constructed from theinsn_decodefunction which may fail and return negative integer. Fix this by explicitly checking the return value.Addresses-Coverity: ("Unchecked return value")
Signed-off-by Khaled ROMDHANI <[email protected]>--- arch/x86/kernel/jump_label.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/kernel/jump_label.c +0
-0
arch/x86/kernel/jump_label.c int arch_jump_entry_size(struct jump_entry *entry) · line 26
Quoted 5 lines
arch/x86/kernel/jump_label.c +1
-1@@ -23,7 +23,7 @@ int arch_jump_entry_size(struct jump_entry *entry) {struct insn insn = {}; -insn_decode_kernel (&insn, (void *)jump_entry_code (entry)); +WARN_ON (insn_decode_kernel (&insn, (void *)jump_entry_code (entry)));
I don't think coverity is smart enough to notice...
arch/x86/kernel/jump_label.c int arch_jump_entry_size(struct jump_entry *entry) · line 27
Quoted 1 line
arch/x86/kernel/jump_label.c +0
-0BUG_ON (insn.length !=2 && insn.length !=5 );
^^^^^^^^^^^^^
... this line.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 26 lines · Borislav Petkov
Quoted 17 lines · Khaled ROMDHANI
From the coverity scan analysis, the return value from
insn_decode_kernelis not checked. It is a macro constructed from theinsn_decodefunction which may fail and return negative integer. Fix this by explicitly checking the return value.Addresses-Coverity: ("Unchecked return value")
Signed-off-by Khaled ROMDHANI <[email protected]>--- arch/x86/kernel/jump_label.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/kernel/jump_label.c +0
-0arch/x86/kernel/jump_label.c int arch_jump_entry_size(struct jump_entry *entry) · line 26
Quoted 5 lines
arch/x86/kernel/jump_label.c +1
-1@@ -23,7 +23,7 @@ int arch_jump_entry_size(struct jump_entry *entry) {struct insn insn = {}; -insn_decode_kernel (&insn, (void *)jump_entry_code (entry)); +WARN_ON (insn_decode_kernel (&insn, (void *)jump_entry_code (entry)));I don't think coverity is smart enough to notice...
Quoted 6 lines
arch/x86/kernel/jump_label.c int arch_jump_entry_size(struct jump_entry *entry) · line 27
Quoted 1 line
arch/x86/kernel/jump_label.c +0
-0BUG_ON (insn.length !=2 && insn.length !=5 );^^^^^^^^^^^^^... this line.
Indeed. One needs to be careful with false positives with Coverity.
Colin
Quoted 28 lines · Colin Ian King
Quoted 27 lines · Borislav Petkov
Quoted 17 lines · Khaled ROMDHANI
From the coverity scan analysis, the return value from
insn_decode_kernelis not checked. It is a macro constructed from theinsn_decodefunction which may fail and return negative integer. Fix this by explicitly checking the return value.Addresses-Coverity: ("Unchecked return value")
Signed-off-by Khaled ROMDHANI <[email protected]>--- arch/x86/kernel/jump_label.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/kernel/jump_label.c +0
-0arch/x86/kernel/jump_label.c int arch_jump_entry_size(struct jump_entry *entry) · line 26
Quoted 5 lines
arch/x86/kernel/jump_label.c +1
-1@@ -23,7 +23,7 @@ int arch_jump_entry_size(struct jump_entry *entry) {struct insn insn = {}; -insn_decode_kernel (&insn, (void *)jump_entry_code (entry)); +WARN_ON (insn_decode_kernel (&insn, (void *)jump_entry_code (entry)));I don't think coverity is smart enough to notice...
Quoted 1 line
arch/x86/kernel/jump_label.c +0
-0BUG_ON (insn.length !=2 && insn.length !=5 );
Quoted 8 lines
Quoted 5 lines
^^^^^^^^^^^^^... this line.
Indeed. One needs to be careful with false positives with Coverity.
Colin
Yes. I shall be.
Thanks,
Khaled.