[BPF] fix a use after free bug
authorYonghong Song <yhs@fb.com>
Tue, 5 Nov 2019 06:12:52 +0000 (22:12 -0800)
committerYonghong Song <yhs@fb.com>
Tue, 5 Nov 2019 06:20:23 +0000 (22:20 -0800)
commit9f34447f3ff525029ec889bf3a82b04678a9d7c0
tree73851ef0092ae02a8bc95acf739973b66d3b26d8
parentf65493a83e3bdb402fb1dfa92bcc25707e961147
[BPF] fix a use after free bug

Commit fff2721286e1 ("[BPF] Fix CO-RE bugs with bitfields")
fixed CO-RE handling bitfield issues. But the implementation
introduced a use after free bug. The "Base" of the intrinsic
might be freed so later on accessing the Type of "Base"
might access the freed memory. The failed test case,
  CodeGen/BPF/CORE/offset-reloc-middle-chain.ll
is exactly used to test such a case.

Similarly to previous attempt to remember Metadata etc,
remember "Base" pointee Alignment in advance to avoid
such use after free bug.
llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp