Use common parse routine to read alignment values from bitcode
authorJF Bastien <jfb@google.com>
Sun, 22 Feb 2015 19:32:03 +0000 (19:32 +0000)
committerJF Bastien <jfb@google.com>
Sun, 22 Feb 2015 19:32:03 +0000 (19:32 +0000)
commit8c253f7e88f638ac0108ca8ec34daf236737cd83
tree24cf3837e06a82b3e3bdd084d3ef0382f1b471a4
parent67f22b7af9d3f0907d260172f226f7b53eeddbfb
Use common parse routine to read alignment values from bitcode

While fuzzing LLVM bitcode files, I discovered that (1) the bitcode reader doesn't check that alignments are no larger than 2**29; (2) downstream code doesn't check the range; and (3) for values out of range, corresponding large memory requests (based on alignment size) will fail. This code fixes the bitcode reader to check for valid alignments, fixing this problem.

This CL fixes alignment value on global variables, functions, and instructions: alloca, load, load atomic, store, store atomic.

Patch by Karl Schimpf (kschimpf@google.com).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230180 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/Value.h
lib/Bitcode/Reader/BitcodeReader.cpp
lib/Bitcode/Reader/BitcodeReader.h
test/Bitcode/Inputs/invalid-align.bc [new file with mode: 0644]
test/Bitcode/invalid.test