On Fri, 2023-12-08 at 09:19 -0800, Yonghong Song wrote: > On 12/8/23 6:34 AM, Eduard Zingerman wrote: > > On Thu, 2023-12-07 at 18:28 -0800, Yonghong Song wrote: > > [...] > > > All context types are defined in include/linux/bpf_types.h. > > > The context type bpf_nf_ctx is missing. [...] > The error message should happen here: > > check_mem_access > ... > } else if (reg->type == PTR_TO_CTX) { > check_ptr_off_reg > __check_ptr_off_reg > if (!fixed_off_ok && reg->off) { > verbose(env, "dereference of modified %s ptr R%d off=%d disallowed\n", > reg_type_str(env, reg->type), regno, reg->off); > return -EACCES; > } > ... > > So the verification error message will be emitted earlier, before convert_ctx_access. > Could you double check? You are correct and I was unaware of this check. A simple test "r1 += 8; r0 = *(u64 *)(r1 + 0);" does indeed report an error. I'll make sure that every context type is annotated with preserve static offset, thank you for pointing this out. [...]