Lightweight Verification of Array Indexing

Lightweight Verification of  Array Indexing
Slide Note
Embed
Share

This research delves into enhancing the safety of array indexing in programming languages to prevent buffer overflow and program crashes. It explores various tools and techniques to provide stronger guarantees to developers while tackling complexities and false positives in analysis.

  • Verification
  • Array Indexing
  • Programming Languages
  • Safety
  • Complexity

Uploaded on Feb 25, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Lightweight Verification of Array Indexing Martin Kellogg*, Vlastimil Dort**, Suzanne Millstein*, Michael D. Ernst* * University of Washington, Seattle ** Charles University, Prague

  2. The problem: unsafe array indexing In unsafe languages (C): buffer overflow! In managed languages (Java, C#, etc.): exception, program crashes 2

  3. The state of the art Strength of guarantees Practical for developers 3

  4. The state of the art Coq KeY Clouso t Strength of guarantees Practical for developers 4

  5. The state of the art Coq KeY Clouso t Strength of guarantees Coverity FindBugs Practical for developers 5

  6. The state of the art Coq KeY Clouso t The Index Checker (this talk) Strength of guarantees Coverity FindBugs Practical for developers 6

  7. Problems with complex analyses - false positives - annotation burden - complex analyses are hard to predict 7

  8. Problems with complex analyses - false positives bounds checking is hard complex analysis complex analysis harder to implement harder to implement more false positives - annotation burden - complex analyses are hard to predict 8

  9. Problems with complex analyses - false positives bounds checking is hard complex analysis complex analysis harder to implement harder to implement more false positives - annotation burden complex analysis complex annotations - complex analyses are hard to predict 9

  10. Problems with complex analyses - false positives bounds checking is hard complex analysis complex analysis harder to implement harder to implement more false positives - annotation burden complex analysis complex annotations complex analyses are hard to predict - 10

  11. Insight: Fundamental problem is complex analyses! 11

  12. Cooperating simple analyses Solve all three problems: 12

  13. Cooperating simple analyses Solve all three problems: simpler implementation fewer false positives 13

  14. Cooperating simple analyses Solve all three problems: simpler implementation fewer false positives simpler abstractions easier to write annotations 14

  15. Cooperating simple analyses Solve all three problems: simpler implementation fewer false positives simpler abstractions easier to write annotations simpler analysis simpler to predict 15

  16. Proving an array access safe T[] a = ; int i = ; ... a[i] ... We need to show that: i is an index for a 16

  17. Proving an array access safe T[] a = ; int i = ; ... a[i] ... We need to show that: i is an index for a i 0 i < a.length 17

  18. Proving an array access safe T[] a = ; int i = ; ... a[i] ... We need to show that: i is an index for a i 0 i < a.length A lower bound on i An upper bound on i 18

  19. A type system for lower bounds T @LowerBoundUnknown int i i -1 @GTENegativeOne int i i 0 @NonNegative int i i 1 @Positive int i 19

  20. A type system for lower bounds T @LowerBoundUnknown int i i -1 @GTENegativeOne int i i 0 @NonNegative int i i 1 @Positive int i 20

  21. A type system for upper bounds if (i >= 0 && i < a.length) { a[i] = ... } 21

  22. A type system for upper bounds if (i >= 0 && i < a.length) { a[i] = ... } i< a.length @LTLengthOf( a ) int i 22

  23. Type systems Linear inequalities i < j Minimum lengths a.length > 10 Negative indices | i | < a.length Lower bounds i 0 Equal lengths a.length = b.length Upper bounds i < a.length 23

  24. Type systems Linear inequalities i < j Minimum lengths a.length > 10 Negative indices | i | < a.length Lower bounds i 0 Equal lengths a.length = b.length Upper bounds i < a.length 24

  25. A type system for minimum array lengths if (a.length >= 3) { a[2] = ...; } 25

  26. A type system for minimum array lengths if (a.length >= 3) { a[2] = ...; } a.length i T @MinLen(i) [] a 26

  27. Evaluation Three case studies: Google Guava (two packages) JFreeChart plume-lib Comparison to existing tools: FindBugs, KeY, Clousot 27

  28. Case Studies Guava JFreeChart plume-lib Total Lines of code 10,694 94,233 14,586 119,503 Bugs found 5 64 20 89 Annotations 510 2,938 241 3,689 False positives 138 386 43 567 Java casts 222 2,740 219 3,181 28

  29. Comparison to other tools: confirmed bugs Bug finder Verif. w/ solver Abs. interpret. Approach Types Tool Index Checker FindBugs KeY Clousot True Positives False Negatives Time (100k LoC) 29

  30. Comparison to other tools: confirmed bugs Bug finder Verif. w/ solver Abs. interpret. Approach Types Tool Index Checker FindBugs KeY Clousot True Positives False Negatives Time (100k LoC) ~10 minutes ~1 minute cannot scale ~200 minutes 30

  31. Comparison to other tools: confirmed bugs Bug finder Verif. w/ solver Abs. interpret. Approach Types Tool Index Checker FindBugs KeY Clousot 18/18 0/18 9/18 16/18 True Positives 0/18 18/18 1/18 2/18 False Negatives Time (100k LoC) ~10 minutes ~1 minute cannot scale ~200 minutes 31

  32. Using the Index Checker Distributed with Checker Framework www.checkerframework.org 32

  33. Contributions A methodology: simple, cooperative type systems An analysis: abstractions for array indexing An implementation and evaluation for Java Verifying the absence of array bounds errors in real codebases (and finding bugs in the process!) 33

More Related Content