All of lore.kernel.org
 help / color / mirror / Atom feed
From: Colin Ian King <colin.king@canonical.com>
To: Borislav Petkov <bp@alien8.de>,
	Khaled ROMDHANI <khaledromdhani216@gmail.com>
Cc: peterz@infradead.org, jpoimboe@redhat.com, jbaron@akamai.com,
	rostedt@goodmis.org, ardb@kernel.org, tglx@linutronix.de,
	mingo@redhat.com, x86@kernel.org, hpa@zytor.com,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH-next] x86/kernel: Fix unchecked return value
Date: Sat, 15 May 2021 21:51:23 +0100	[thread overview]
Message-ID: <6f149c2e-eeb0-6b50-2b54-a56ae4646ea5@canonical.com> (raw)
In-Reply-To: <YKAw3Yl8c6nU1zng@zn.tnic>

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

  reply	other threads:[~2021-05-15 20:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-05-16 13:17     ` Khaled Romdhani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6f149c2e-eeb0-6b50-2b54-a56ae4646ea5@canonical.com \
    --to=colin.king@canonical.com \
    --cc=ardb@kernel.org \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jbaron@akamai.com \
    --cc=jpoimboe@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=khaledromdhani216@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.