* [PATCH-next] x86/kernel: Fix unchecked return value
@ 2021-05-15 20:22 Khaled ROMDHANI
2021-05-15 20:36 ` Borislav Petkov
0 siblings, 1 reply; 4+ messages in thread
From: Khaled ROMDHANI @ 2021-05-15 20:22 UTC (permalink / raw)
To: peterz, jpoimboe, jbaron, rostedt, ardb, tglx, mingo, bp, x86, hpa
Cc: Khaled ROMDHANI, linux-kernel, kernel-janitors
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")
Signed-off-by: Khaled ROMDHANI <khaledromdhani216@gmail.com>
---
arch/x86/kernel/jump_label.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
index a762dc1c615e..bf0ea003b6e7 100644
--- a/arch/x86/kernel/jump_label.c
+++ b/arch/x86/kernel/jump_label.c
@@ -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;
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH-next] x86/kernel: Fix unchecked return value
2021-05-15 20:22 [PATCH-next] x86/kernel: Fix unchecked return value Khaled ROMDHANI
@ 2021-05-15 20:36 ` Borislav Petkov
2021-05-15 20:51 ` Colin Ian King
0 siblings, 1 reply; 4+ messages in thread
From: Borislav Petkov @ 2021-05-15 20:36 UTC (permalink / raw)
To: Khaled ROMDHANI
Cc: peterz, jpoimboe, jbaron, rostedt, ardb, tglx, mingo, x86, hpa,
linux-kernel, kernel-janitors
On Sat, May 15, 2021 at 09:22:12PM +0100, Khaled ROMDHANI wrote:
> 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")
> Signed-off-by: Khaled ROMDHANI <khaledromdhani216@gmail.com>
> ---
> arch/x86/kernel/jump_label.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
> index a762dc1c615e..bf0ea003b6e7 100644
> --- a/arch/x86/kernel/jump_label.c
> +++ b/arch/x86/kernel/jump_label.c
> @@ -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...
> BUG_ON(insn.length != 2 && insn.length != 5);
^^^^^^^^^^^^^
... this line.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH-next] x86/kernel: Fix unchecked return value
2021-05-15 20:36 ` Borislav Petkov
@ 2021-05-15 20:51 ` Colin Ian King
2021-05-16 13:17 ` Khaled Romdhani
0 siblings, 1 reply; 4+ messages in thread
From: Colin Ian King @ 2021-05-15 20:51 UTC (permalink / raw)
To: Borislav Petkov, Khaled ROMDHANI
Cc: peterz, jpoimboe, jbaron, rostedt, ardb, tglx, mingo, x86, hpa,
linux-kernel, kernel-janitors
On 15/05/2021 21:36, Borislav Petkov wrote:
> On Sat, May 15, 2021 at 09:22:12PM +0100, Khaled ROMDHANI wrote:
>> 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")
>> Signed-off-by: Khaled ROMDHANI <khaledromdhani216@gmail.com>
>> ---
>> arch/x86/kernel/jump_label.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
>> index a762dc1c615e..bf0ea003b6e7 100644
>> --- a/arch/x86/kernel/jump_label.c
>> +++ b/arch/x86/kernel/jump_label.c
>> @@ -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...
>
>> BUG_ON(insn.length != 2 && insn.length != 5);
> ^^^^^^^^^^^^^
>
> ... this line.
>
>
Indeed. One needs to be careful with false positives with Coverity.
Colin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH-next] x86/kernel: Fix unchecked return value
2021-05-15 20:51 ` Colin Ian King
@ 2021-05-16 13:17 ` Khaled Romdhani
0 siblings, 0 replies; 4+ messages in thread
From: Khaled Romdhani @ 2021-05-16 13:17 UTC (permalink / raw)
To: Colin Ian King, Borislav Petkov
Cc: peterz, jpoimboe, jbaron, rostedt, ardb, tglx, mingo, x86, hpa,
linux-kernel, kernel-janitors
On Sat, May 15, 2021 at 09:51:23PM +0100, Colin Ian King wrote:
> On 15/05/2021 21:36, Borislav Petkov wrote:
> > On Sat, May 15, 2021 at 09:22:12PM +0100, Khaled ROMDHANI wrote:
> >> 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")
> >> Signed-off-by: Khaled ROMDHANI <khaledromdhani216@gmail.com>
> >> ---
> >> arch/x86/kernel/jump_label.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
> >> index a762dc1c615e..bf0ea003b6e7 100644
> >> --- a/arch/x86/kernel/jump_label.c
> >> +++ b/arch/x86/kernel/jump_label.c
> >> @@ -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...
> >
> >> BUG_ON(insn.length != 2 && insn.length != 5);
> > ^^^^^^^^^^^^^
> >
> > ... this line.
> >
> >
> Indeed. One needs to be careful with false positives with Coverity.
>
> Colin
Yes. I shall be.
Thanks,
Khaled.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-16 13:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-15 20:22 [PATCH-next] x86/kernel: Fix unchecked return value Khaled ROMDHANI
2021-05-15 20:36 ` Borislav Petkov
2021-05-15 20:51 ` Colin Ian King
2021-05-16 13:17 ` Khaled Romdhani
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.