[LLVMdev] [RFC] Simple control-flow integrity

Peter Collingbourne peter at pcc.me.uk
Fri Mar 21 13:46:49 PDT 2014


On Fri, Mar 21, 2014 at 12:54:07PM -0700, Tom Roeder wrote:
> On Fri, Mar 21, 2014 at 12:15 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
> >> The way I've implemented it (see the patch I sent to llvm-commits
> >> yesterday), it's not just metadata: the intrinsic lowers to the
> >> jumptable entry code given above. The CFI pass then generates a
> >> function for each jump table; the function consists solely of these
> >> intrinsic calls.
> >
> > Well, the intrinsic you proposed has no effect on the caller and has
> > non-local effects on other specified functions. I'm not aware of any other
> > intrinsic with similar behavior.
> 
> I agree that it's not very similar to other intrinsics. But I don't
> exactly follow these statements. There are definitely intrinsics that
> have no effect on the caller, like llvm.var.annotation.

Yes but the purpose of such intrinsics is to communicate information about
a specific value that may have an effect on analysis, optimization or code
generation for that caller. On the other hand, the intrinsic you are proposing
has nothing to do with the caller.

> And AFAIK,
> there is no non-local behavior: all the intrinsic does is lower to the
> labeled jump instruction; the changes to address-taken functions are
> done separately by the CFI pass. Note that in the patch I sent, the
> intrinsic only takes one argument: the function to jump to. Are there
> other effects in this case?

The non-local effect is that the intrinsic describes the definition of a
function in the global scope. Normally such definitions come from top-level
entities.

> So, maybe it would be better to call it something like
> @llvm.unconditional.jump(i8*)? I could then make it only lower to the
> jump and add an intrinsic that lowered to a function label as well.

I'd imagine that might present more problems. For example, if you used
either intrinsic in the middle of a regular function the behavior would not
necessarily be well defined. It would be necessary to carefully document
where and how these intrinsics may be used.

Thanks,
-- 
Peter



More information about the llvm-dev mailing list