[all-commits] [llvm/llvm-project] f22442: [BPF] Check jump and memory offsets to avoid trunc...

eddyz87 via All-commits all-commits at lists.llvm.org
Sat Sep 23 09:53:07 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f22442553b8e0840f2fb5345529172a345cfba7d
      https://github.com/llvm/llvm-project/commit/f22442553b8e0840f2fb5345529172a345cfba7d
  Author: Eduard Zingerman <eddyz87 at gmail.com>
  Date:   2023-09-23 (Sat, 23 Sep 2023)

  Changed paths:
    M llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
    M llvm/lib/Target/BPF/BPFInstrInfo.td
    A llvm/test/MC/BPF/bad-offsets.s
    A llvm/test/MC/BPF/expr-offset.s

  Log Message:
  -----------
  [BPF] Check jump and memory offsets to avoid truncation

The following assembly code should issue two errors specifying that
both jump and load offsets are out of range:

  if r1 > r2 goto +100500
  r1 = *(u64 *)(r1 - 100500)

This commit updates BPFAsmParser to check that:
- offset specified for jump is either identifier (label) or a 16-bit
  signed constant;
- offset specified for memory operations is a signed 16-bit constant.

(Which matches expectations in the BPFELFObjectWriter and
 BPFMCCodeEmitter).

Differential Revision: https://reviews.llvm.org/D158425




More information about the All-commits mailing list