Resolving the almost decade old checker dependency issue in the - - PowerPoint PPT Presentation

resolving the almost decade old checker dependency issue
SMART_READER_LITE
LIVE PREVIEW

Resolving the almost decade old checker dependency issue in the - - PowerPoint PPT Presentation

. . . . . . . . . . . . . . . . Resolving the almost decade old checker dependency issue in the Clang Static Analyzer Kristf Umann dkszelethus@gmail.com Etvs Lornd University, Budapest Ericsson Hungary . . . . . .


slide-1
SLIDE 1

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Resolving the almost decade old checker dependency issue in the Clang Static Analyzer

Kristóf Umann dkszelethus@gmail.com

Eötvös Loránd University, Budapest Ericsson Hungary

April 8., 2019

slide-2
SLIDE 2

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

The original problem: easy-to-mess-up command line interface

clang -cc1 -analyze myfile.cpp \

  • analyzer-checker=cplusplus.InnerPointer \
  • analyzer-config note-as-warning=true

...meant to be notes-as-warnings clang -cc1 -analyze myfile.cpp \

  • analyzer-checker=cplusplus.InnerPointer \
  • analyzer-config unix.Malloc:Optimist=true

...meant to be Optimistic

slide-3
SLIDE 3

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

No warnings, no errors, the analyzer simply doesn’t do what you intended...

slide-4
SLIDE 4

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Bug unearthed: ”The Checker Naming Bug”

Multiple checker objects could receive the same name Incorrect checker names in bug reports Errors while parsing checker confjgurations

slide-5
SLIDE 5

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Real-life problems coming from the Checker Naming Bug

clang -cc1 -analyze myfile.cpp \

  • analyzer-checker=cplusplus.InnerPointer \
  • analyzer-config unix.Malloc:Optimistic=true
slide-6
SLIDE 6

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Real-life problems coming from the Checker Naming Bug

clang -cc1 -analyze myfile.cpp \

  • analyzer-checker=cplusplus.InnerPointer \
  • analyzer-config cplusplus.InnerPointer:Optimistic=true
slide-7
SLIDE 7

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

InnerPointerChecker and MallocChecker have the same name!

Turns out InnerPointerChecker depends on MallocChecker! InnerPointerChecker enables both itself and MallocChecker Fixing this bug implies the need to reimplement dependencies...

slide-8
SLIDE 8

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

  • sx.NSOrCFErrorDerefChecker
  • sx.coreFoundation.CFError
  • sx.cocoa.NSError

unix.cstring.CStringModeling alpha.unix.cstring.BufgerOverlap alpha.unix.cstring.NotNullTerminated unix.cstring.NullArg alpha.unix.cstring.OutOfBounds unix.cstring.BadSizeArg unix.DynamicMemoryModeling cplusplus.InnerPointer unix.Malloc unix.MismatchedDeallocator cplusplus.NewDelete cplusplus.NewDeleteLeaks security.insecureAPI.SecuritySyntaxChecker security.insecureAPI.UncheckedReturn security.insecureAPI.bcmp security.insecureAPI.bcopy a bunch more security checkers security.insecureAPI.mktemp security.insecureAPI.DeprecatedOrUnsafeBufgerHandling security.FloatLoopCounter alpha.cplusplus.IteratorModeling alpha.cplusplus.InvalidatedIterator alpha.cplusplus.IteratorRange alpha.cplusplus.MismatchedIterator alpha.osx.IvarInvalidationModeling alpha.osx.InstanceVariableInvalidation alpha.osx.MissingInvalidationMethod core.DynamicTypePropagation

  • sx.cocoa.ObjCGenerics
  • sx.cocoa.RetainCountBase
  • sx.OSObjectRetainCount
  • sx.cocoa.RetainCount

core.StackAddrEscapeBase alpha.core.StackAddressAsyncEscape core.StackAddressEscape core.CallAndMessage alpha.core.CallAndMessageUnInitRefArg valist.ValistBase valist.CopyToSelf valist.Uninitialized valist.Unterminated

slide-9
SLIDE 9

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

CString Modeling object? alpha.unix.cstring.BufgerOverlap alpha.unix.cstring.NotNullTerminated unix.cstring.NullArg alpha.unix.cstring.OutOfBounds unix.cstring.BadSizeArg unix.Malloc cplusplus.InnerPointer unix.MismatchedDeallocator cplusplus.NewDelete cplusplus.NewDeleteLeaks Too complex to fjt on a slide...

clang -cc1 -analyze myfile.cpp \

  • analyzer-checker=cplusplus.InnerPointer \
  • analyzer-config unix.Malloc:Optimistic=true
slide-10
SLIDE 10

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

CString Modeling object? alpha.unix.cstring.BufgerOverlap alpha.unix.cstring.NotNullTerminated unix.cstring.NullArg alpha.unix.cstring.OutOfBounds unix.cstring.BadSizeArg unix.Malloc cplusplus.InnerPointer unix.MismatchedDeallocator cplusplus.NewDelete cplusplus.NewDeleteLeaks

clang -cc1 -analyze myfile.cpp \

  • analyzer-checker=cplusplus.InnerPointer \
  • analyzer-config cplusplus.InnerPointer:Optimistic=true
slide-11
SLIDE 11

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

CString Modeling object? alpha.unix.cstring.BufgerOverlap alpha.unix.cstring.NotNullTerminated unix.cstring.NullArg alpha.unix.cstring.OutOfBounds unix.cstring.BadSizeArg unix.Malloc cplusplus.InnerPointer unix.MismatchedDeallocator cplusplus.NewDelete cplusplus.NewDeleteLeaks

How do we solve this?

slide-12
SLIDE 12

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

unix.cstring.CStringModeling alpha.unix.cstring.BufgerOverlap alpha.unix.cstring.NotNullTerminated unix.cstring.NullArg alpha.unix.cstring.OutOfBounds unix.cstring.BadSizeArg unix.DynamicMemoryModeling cplusplus.InnerPointer unix.Malloc unix.MismatchedDeallocator cplusplus.NewDelete cplusplus.NewDeleteLeaks

Be able to represent dependencies with a directed tree

slide-13
SLIDE 13

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Resolve dependencies at a higher level

Declare dependencies in TableGen Don’t allow checkers to enable more than one checker Make sure dependencies are enabled in the correct order def InnerPointerChecker : Checker<"InnerPointer">, HelpText<"Looks for pointers to temp. strings">, Dependencies<[DynamicMemoryModeling]>, Documentation<NotDocumented>;

slide-14
SLIDE 14

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Conclusion

We are able to list checker dependencies We can now list and verify checker options Checker names won’t depend on how we invoke the analyzer Plugins can now depend on builtin checkers Already in trunk!

slide-15
SLIDE 15

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

  • sx.NSOrCFErrorDerefChecker
  • sx.coreFoundation.CFError
  • sx.cocoa.NSError

unix.cstring.CStringModeling alpha.unix.cstring.BufgerOverlap alpha.unix.cstring.NotNullTerminated unix.cstring.NullArg alpha.unix.cstring.OutOfBounds unix.cstring.BadSizeArg unix.DynamicMemoryModeling cplusplus.InnerPointer unix.Malloc unix.MismatchedDeallocator cplusplus.NewDelete cplusplus.NewDeleteLeaks security.insecureAPI.SecuritySyntaxChecker security.insecureAPI.UncheckedReturn security.insecureAPI.bcmp security.insecureAPI.bcopy a bunch more security checkers security.insecureAPI.mktemp security.insecureAPI.DeprecatedOrUnsafeBufgerHandling security.FloatLoopCounter alpha.cplusplus.IteratorModeling alpha.cplusplus.InvalidatedIterator alpha.cplusplus.IteratorRange alpha.cplusplus.MismatchedIterator alpha.osx.IvarInvalidationModeling alpha.osx.InstanceVariableInvalidation alpha.osx.MissingInvalidationMethod core.DynamicTypePropagation

  • sx.cocoa.ObjCGenerics
  • sx.cocoa.RetainCountBase
  • sx.OSObjectRetainCount
  • sx.cocoa.RetainCount

core.StackAddrEscapeBase alpha.core.StackAddressAsyncEscape core.StackAddressEscape core.CallAndMessage alpha.core.CallAndMessageUnInitRefArg valist.ValistBase valist.CopyToSelf valist.Uninitialized valist.Unterminated

Thank you for your attention!