On Wed, Nov 22, 2023 at 7:13 AM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote: > > On Tue, 2023-11-21 at 17:16 -0800, Andrii Nakryiko wrote: > > BPF verifier expects callback subprogs to return values from specified > > range (typically [0, 1]). This requires that r0 at exit is both precise > > (because we rely on specific value range) and is marked as read > > (otherwise state comparison will ignore such register as unimportant). > > > > Add a simple test that validates that all these conditions are enforced. > > > > Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > > --- > > Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx> > > [...] > > > +SEC("?raw_tp") > > +__failure __log_level(2) > > +__flag(BPF_F_TEST_STATE_FREQ) > > Nit: although it is redundant, but maybe also check precision log to > check that r0 is indeed marked precise? > sure, I'll add another expected msg, no problem > > +__msg("from 10 to 12: frame1: R0=scalar(umin=1001) R10=fp0 cb") > > +__msg("At callback return the register R0 has unknown scalar value should have been in (0x0; 0x1)") > > +__naked int callback_precise_return_fail(void) > > [...] > >