linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Khaled Romdhani <khaledromdhani216@gmail.com>
To: Colin Ian King <colin.king@canonical.com>,
	Borislav Petkov <bp@alien8.de>
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: Sun, 16 May 2021 14:17:14 +0100	[thread overview]
Message-ID: <20210516131714.GB32445@ard0534> (raw)
In-Reply-To: <6f149c2e-eeb0-6b50-2b54-a56ae4646ea5@canonical.com>

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.

      reply	other threads:[~2021-05-16 13:17 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
2021-05-16 13:17     ` Khaled Romdhani [this message]

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=20210516131714.GB32445@ard0534 \
    --to=khaledromdhani216@gmail.com \
    --cc=ardb@kernel.org \
    --cc=bp@alien8.de \
    --cc=colin.king@canonical.com \
    --cc=hpa@zytor.com \
    --cc=jbaron@akamai.com \
    --cc=jpoimboe@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).