CTSRD-CHERI / llvm-project

Fork of LLVM adding CHERI support
48 stars 41 forks source link

Add analyzer to suggest provenance annotations for intptr_t #666

Open brooksdavis opened 1 year ago

brooksdavis commented 1 year ago

In intptr_t expressions llvm generally picks the left hand side as providing provenance and warns about it. It would be nice if an analyzer could look deeper (across function boundaries, etc) and determine:

It could then use that too suggest changes to clarify the programmer's intent rather than just saying it's ambiguous.

Note: this needs to be a static analyzer (possibly whole-program) rather than the compiler, because compiler analysis will depend too much on optimization levels at the like.

eupharina commented 1 year ago

Hi!

I now have a CSA checker that can detect the first two issues (PR https://github.com/CTSRD-CHERI/llvm-project/pull/675). I don't quite understand the third suggestion though (about ptrdiff_t), what the pattern is and why this can be a problem. Could you please give an example or share the link to the commit that addresses this issue in some ported project?