Alexei Starovoitov wrote: > On Wed, Oct 14, 2020 at 09:04:23PM -0700, John Fastabend wrote: > > Andrii Nakryiko wrote: > > > On Wed, Oct 14, 2020 at 10:59 AM Alexei Starovoitov > > > <alexei.starovoi...@gmail.com> wrote: > > > > > > > > From: Alexei Starovoitov <a...@kernel.org> > > > > > > > > The 64-bit JEQ/JNE handling in reg_set_min_max() was clearing reg->id > > > > in either > > > > true or false branch. In the case 'if (reg->id)' check was done on the > > > > other > > > > branch the counter part register would have reg->id == 0 when called > > > > into > > > > find_equal_scalars(). In such case the helper would incorrectly > > > > identify other > > > > registers with id == 0 as equivalent and propagate the state > > > > incorrectly. > > > > One thought. It seems we should never have reg->id=0 in find_equal_scalars() > > would it be worthwhile to add an additional check here? Something like, > > > > if (known_reg->id == 0) > > return > > > > Or even a WARN_ON_ONCE() there? Not sold either way, but maybe worth > > thinking > > about. > > That cannot happen anymore due to > if (dst_reg->id && !WARN_ON_ONCE(dst_reg->id != > other_branch_regs[insn->dst_reg].id)) > check in the caller. > I prefer not to repeat the same check twice. Also I really don't like > defensive programming. > if (known_reg->id == 0) > return; > is exactly that. > If we had that already, as Andrii argued in the original thread, we would have > never noticed this issue. <, >, <= ops would have worked, but == would be > sort-of working. It would mark one branch instead of both, and sometimes > neither of the branches. I'd rather have bugs like this one hurting and caught > quickly instead of warm feeling of being safe and sailing into unknown.
Agree. Although a WARN_ON_ONCE would have also been caught.