This is a second attempt at fixing narrow loads from context fields backed by smaller-in-size target fields, when load offset is beyond the target field. Following Yonghong suggestion, verifier now emits an 'wX = 0' or 'rX = 0' instruction for loads from offsets outside of target field. Cc: Yonghong Song <yhs@xxxxxx> [v1] https://lore.kernel.org/bpf/20200710173123.427983-1-jakub@xxxxxxxxxxxxxx/ Jakub Sitnicki (2): bpf: Load zeros for narrow loads beyond target field selftests/bpf: Add test for narrow loads from context at an offset kernel/bpf/verifier.c | 23 ++++- .../selftests/bpf/prog_tests/narrow_load.c | 84 +++++++++++++++++++ .../selftests/bpf/progs/test_narrow_load.c | 43 ++++++++++ 3 files changed, 148 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/narrow_load.c create mode 100644 tools/testing/selftests/bpf/progs/test_narrow_load.c -- 2.25.4