[PATCH] D158425: [BPF] Check jump and memory offsets to avoid truncation

Eduard Zingerman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 21 08:11:44 PDT 2023


eddyz87 added a reviewer: yonghong-song.
eddyz87 added a comment.

Hi Yonghong,

Could you please take a look?
This is a follow-up for this <https://lore.kernel.org/bpf/83e093b1-97ec-14e3-56ee-8258eea66709@linux.dev/> kernel mailing list thread. I diverged from the suggested implementation and used approach described in this <https://lists.llvm.org/pipermail/llvm-dev/2015-December/093093.html> thread. I used the following reasoning:

- range checks are needed for offsets and immediates, which are used in many instructions;
- if check is done in `BPFMCCodeEmitter::encodeInstruction` correct per-instruction operand indexes are needed to extract opreand from `MCInst` => big switch which duplicates information already encoded in the `BPFInstrInfo.td`;
- on the other hand, adjusting operand declarations in `BPFInstrInfo.td` is much more concise.

What do you think?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158425/new/

https://reviews.llvm.org/D158425



More information about the llvm-commits mailing list