Re: [PATCH 1/2] x86/insn: Fix some potential undefined behavior.

Peter Zijlstra
2020-10-15T10:05:38Z

On Wed, Oct 14, 2020 at 11:21:47PM -0700, Ian Rogers wrote:
> From: Numfor Mbiziwo-Tiapo <nums@google.com>
>
> If insn_init is given a NULL kaddr and 0 buflen then validate_next will
> perform arithmetic on NULL, add a guard to avoid this.

How is this a problem? NULL is (void *)0, you can do arithmetic on that
just fine.

Is UBSAN taking drugs again?

> Don't perform unaligned loads in __get_next and __peek_nbyte_next as
> these are forms of undefined behavior.

Fair enough; that could actually be a problem when we start to
cross-build this stuff. A RISC hosted version of the x86 decoder could
indeed trip this up.

But also, these are two changes in one patch.