lkml.org 
[lkml]   [2022]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v1] arch/x86/kernel: check the return value of insn_decode_kernel()
On Fri,  2 Sep 2022 00:47:06 -0700
Li Zhong <floridsleeves@gmail.com> wrote:

> @@ -20,9 +20,10 @@
> int arch_jump_entry_size(struct jump_entry *entry)
> {
> struct insn insn = {};
> + int ret;
>
> - insn_decode_kernel(&insn, (void *)jump_entry_code(entry));
> - BUG_ON(insn.length != 2 && insn.length != 5);
> + ret = insn_decode_kernel(&insn, (void *)jump_entry_code(entry));

It's highly unlikely that length will be 2 or 5 if ret is not zero (as it
is initialized to zero going into this function).

> + BUG_ON(ret < 0 || insn.length != 2 && insn.length != 5);

In any case, you need parenthesis around the && condition.

-- Steve


>
> return insn.length;

\
 
 \ /
  Last update: 2022-09-07 03:59    [W:0.035 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site