[PATCH] Add user-defined callback on write() calls to labeled data.

Peter Collingbourne peter at pcc.me.uk
Tue Apr 8 12:54:23 PDT 2014


On Mon, Apr 07, 2014 at 10:59:54PM -0400, Sam Kerner wrote:
> On Wed, Apr 2, 2014 at 7:20 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
> >
> >
> >
> > ================
> > Comment at: lib/dfsan/dfsan.cc:261
> > @@ +260,3 @@
> > +
> > +  dfsan_labeled_write_callback = labeled_write_callback;
> > +
> > ----------------
> > I don't think this approach is correct. We can't store a pointer to the callback function (which uses the instrumented ABI) and call it from the dfsan runtime library using the uninstrumented ABI, as the labels received by the callback function will be wrong (nor is this guaranteed to work at all).
> >
> > We have a trampoline mechanism for safely calling instrumented ABI functions from the dfsan runtime library. Please take a look at how the custom functions pthread_create and dl_iterate_phdr are implemented.
> 
> Those methods take a function pointer as an argument, and I see that
> the presence of a function pointer argument causes a trampoline
> argument to be added to the call to __dfsw_* by the DataFlowSanitizer
> class.  write() has no such callback.
> 
> I could make the function that sets the callback a custom method, so
> that its custom implementation gets a trampoline argument.  Is that a
> reasonable approach, or is there a better way to obtain the
> trampoline?

That was the approach I had in mind.

Thanks,
-- 
Peter



More information about the llvm-commits mailing list