Messages in this thread | | | Date | Fri, 4 Dec 2020 09:18:42 +0900 | From | Masami Hiramatsu <> | Subject | Re: [PATCH v2 1/3] x86/uprobes: Fix not using prefixes.nbytes for loop over prefixes.bytes |
| |
On Thu, 3 Dec 2020 13:37:57 +0100 Borislav Petkov <bp@alien8.de> wrote:
> On Thu, Dec 03, 2020 at 01:50:37PM +0900, Masami Hiramatsu wrote: > > Since the insn.prefixes.nbytes can be bigger than the size of > > insn.prefixes.bytes[] when a same prefix is repeated, we have to > > check whether the insn.prefixes.bytes[i] != 0 and i < 4 instead > > of insn.prefixes.nbytes. > > This introduces for_each_insn_prefix() macro for this purpose. > > > > Fixes: 2b1444983508 ("uprobes, mm, x86: Add the ability to install and remove uprobes breakpoints") > > Reported-by: syzbot+9b64b619f10f19d19a7c@syzkaller.appspotmail.com > > Debugged-by: Kees Cook <keescook@chromium.org> > > Reviewed-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> > > Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> > > Cc: stable@vger.kernel.org > > --- > > Changes in v2: > > - Add for_each_insn_prefix() macro and fix to check index first. > > --- > > arch/x86/include/asm/insn.h | 15 +++++++++++++++ > > arch/x86/kernel/uprobes.c | 10 ++++++---- > > 2 files changed, 21 insertions(+), 4 deletions(-) > > Warning: Kernel ABI header at 'tools/arch/x86/include/asm/insn.h' differs from latest version at 'arch/x86/include/asm/insn.h'
Oops.
> > > diff --git a/arch/x86/include/asm/insn.h b/arch/x86/include/asm/insn.h > > index 5c1ae3eff9d4..e6b38ebd3a1c 100644 > > --- a/arch/x86/include/asm/insn.h > > +++ b/arch/x86/include/asm/insn.h > > @@ -201,6 +201,21 @@ static inline int insn_offset_immediate(struct insn *insn) > > return insn_offset_displacement(insn) + insn->displacement.nbytes; > > } > > > > +/** > > + * for_each_insn_prefix() -- Iterate prefixes in the instruction > > + * @insn: Pointer to struct insn. > > + * @idx: Index storage. > > + * @prefix: Prefix byte. > > + * > > + * Iterate prefix bytes of given @insn. Each prefix byte is stored in @prefix > > + * and the index is stored in @idx (note that this @idx is just for a cursor, > > + * do not change it.) > > + * Since prefixes.nbytes can be bigger than 4 if some prefixes are repeated, > > + * we can not use it for looping over the prefixes. > > Please use passive voice: no "we" or "I", etc,
OK.
> > > + */ > > +#define for_each_insn_prefix(insn, idx, prefix) \ > > + for (idx = 0; idx < 4 && (prefix = insn->prefixes.bytes[idx]) != 0; idx++) > > Btw, looking at the struct insn definition, that prefixes member should > have a comment above it that those are the legacy prefixes which can be > <= 4. But that's minor. > > In any case, I'll fix up the minor issues now but pls remember to do > them in the future.
OK, I will add a macro with comment for it.
Thank you,
> > Thx. > > -- > Regards/Gruss, > Boris. > > https://people.kernel.org/tglx/notes-about-netiquette
-- Masami Hiramatsu <mhiramat@kernel.org>
| |