[llvm-dev] How does sanitizers in compiler-rt work?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] How does sanitizers in compiler-rt work?

ORiordan, Martin via llvm-dev

Can anybody give me any pointer on how compiler-rt, especially the sanitizers work? Do they operate on IR as any other LLVM pass? Or are they integral part of the frontend itself? I couldn't spot any documentation on the internals of compiler-rt project? What happens (sequence of actions) when I pass -fsanitizer=dataflow to clang?

Precisely, I intend to alter the behaviour of DFSan to suit my need. Therefore, I need to know how it gets integrated in the tool-chain. Initially, my idea was to insert the dfsan_set_label() calls to the IR and pass it to DFSan. However, I am not sure if it's designed to run on the source only, not on IR.

--

Thanks & Regards,

Dipanjan

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] How does sanitizers in compiler-rt work?

ORiordan, Martin via llvm-dev

On Jun 16, 2017, at 4:11 AM, Dipanjan Das via llvm-dev <[hidden email]> wrote:


Can anybody give me any pointer on how compiler-rt, especially the sanitizers work? Do they operate on IR as any other LLVM pass? Or are they integral part of the frontend itself? I couldn't spot any documentation on the internals of compiler-rt project? What happens (sequence of actions) when I pass -fsanitizer=dataflow to clang?

Passing -fsanitize=dataflow tells clang to insert the dataflow sanitizer's instrumentation pass into the normal compilation pipeline. The instrumentation occurs at the LLVM IR level. The pass may insert calls into runtime functions which are provided by compiler-rt. Therefore, in order to link a program compiled with -fsanitize=dataflow, the appropriate runtime library from compiler-rt is required.


Precisely, I intend to alter the behaviour of DFSan to suit my need.

What is your need, exactly?


Therefore, I need to know how it gets integrated in the tool-chain. Initially, my idea was to insert the dfsan_set_label() calls to the IR and pass it to DFSan. However, I am not sure if it's designed to run on the source only, not on IR.

You should take a look at lib/Transforms/Instrumentation/DataFlowSanitizer.cpp. There doesn't appear to be much done at the source level.

best,
vedant


--

Thanks & Regards,

Dipanjan
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] How does sanitizers in compiler-rt work?

ORiordan, Martin via llvm-dev

Hi Vedant,

Thanks for the pointers. Please find my replies inline.

On 16 June 2017 at 14:48, Vedant Kumar <[hidden email]> wrote:

On Jun 16, 2017, at 4:11 AM, Dipanjan Das via llvm-dev <[hidden email]> wrote:


Can anybody give me any pointer on how compiler-rt, especially the sanitizers work? Do they operate on IR as any other LLVM pass? Or are they integral part of the frontend itself? I couldn't spot any documentation on the internals of compiler-rt project? What happens (sequence of actions) when I pass -fsanitizer=dataflow to clang?

Passing -fsanitize=dataflow tells clang to insert the dataflow sanitizer's instrumentation pass into the normal compilation pipeline. The instrumentation occurs at the LLVM IR level. The pass may insert calls into runtime functions which are provided by compiler-rt. Therefore, in order to link a program compiled with -fsanitize=dataflow, the appropriate runtime library from compiler-rt is required.


Precisely, I intend to alter the behaviour of DFSan to suit my need.

What is your need, exactly?


Instead of manually inserting the dfsan_create_label() and dfsan_set_label() calls in the source, I want to automatically insert those calls in the IR for all the input variables in scanf(). I intend to run the DFsan pass afterwards, thus instrumenting the IR further as required.
 
Therefore, I need to know how it gets integrated in the tool-chain. Initially, my idea was to insert the dfsan_set_label() calls to the IR and pass it to DFSan. However, I am not sure if it's designed to run on the source only, not on IR.

You should take a look at lib/Transforms/Instrumentation/DataFlowSanitizer.cpp. There doesn't appear to be much done at the source level.

best,
vedant


--

Thanks & Regards,

Dipanjan
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev




--

Thanks & Regards,

Dipanjan

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev