]> andersk Git - splint.git/blame - readmeSecurityChecking.txt
*** empty log message ***
[splint.git] / readmeSecurityChecking.txt
CommitLineData
7bf96067 1Security Checking readme.
2
3This document is meant to describe some of the new options in LCLint which enable security checking. This alpha version contains additional checking not documented in the manual for LCLint 2.5.0
4
5Although this document provides a quick introduction for the new
6features of LCLint it is not intended as a substitute for the LCLint
7manual. We recommend that users unfamiliar with LCLint consult the
8LCLint user guides in addition to this document.
9
10The types of errors which LCLint reports can be controlled flags.
11Theses flags can be set on the commands line or in .lclintrc files. A
12flags by giving LCLint the +flagname option on the command line or in
13a .lclintrc file where flagname is the name of the flag. Similarly
14flags are unset with -flagname.
15
16Buffer Overflows
17
18This section describes options which allow LCLint to detect potential array bounds error.
19
20Overview
21
22LCLint detects buffer overflow errors by generating precondition and
23postcondition constraints at the expression level. We resolve
24constraints using post conditions from previous statements. We
25generate an error message for any constraints which we are unable to
26resolve at the top of a function.
27
28All checking takes place within functions. Interprocedural properties
29are checked using annotations. Annotated versions of the standard libraries are provided innerally.
30
31The new annotations allow programmers to explicitly state function
32preconditions and postconditions using requires and ensures clauses.
33We can use these clauses to describe assumptions about buffers that
34are passed to functions and constrain the state of buffers when
35functions return. For the analyses described here two kinds of assumptions and constraints are used: maxSet, and maxRead.
36
37When used in a requires clause, the maxSet annotation
38describes assumptions about the lowest and highest indices of a buffer that may
39be safely used as an lvalue (e.g., on the left-hand side of an
40assignment). For example, consider
41a function with an array parameter a and an integer parameter i that
42has a precondition requires maxSet(a) >= i. The analysis assumes that
43at the beginning of the function body, a[i] may be used as an lvalue.
44If a[i+1] were used before any modifications to the value of a or i,
45LCLint would generate a warning since the function preconditions are
46not sufficient to guarantee that a[i+1] can be used
47safely as an lvalue. Arrays in C start with index 0, so the
48declaration
49 char buf[MAXSIZE]
50generates the constraints
51 maxSet(buf) = MAXSIZE - 1 and minSet(buf) = 0.
52Similarly, the maxRead constraint indicates the maximum indices of a buffer that may be read safely. The value of
53maxRead for a given buffer is always less than or equal to the value
54of maxSet. In cases where there are elements of the buffer have not
55yet been initialized, the value of maxRead may be lower than the value
56of maxSet.
57
58Checking is controlled by the following flags. If the arraybounds flag
59is set LCLint will report potential array bounds. THIS FLAG MUST BE
60SET IN ORDER FOR BUFFER OVERFLOW ERRORS TO BE REPORTED. There are a number
61of additional options which can be used to fine tune checking.
62
63If the +arrayboundsread is set LCLint will report cases in which an
64index past the end of an array or buffer is read. The default is to
65only report cases in which data is written. Out of bounds reads are
66less dangerous than out of bounds writes but are still security
67problems.
68
69The following are used to fine tune the checking. If the
70constraintlocation flag is set LCLint will include the expression
71which causes LCLint to generate the unresolved constraint in an error
72message. We recommend this options. The orconstraint is used to
73perform slightly more accurate checking by using disjuction
74internally. The performance cost is minimal so we recommend this
75option.
76
77Handling spurious messages
78
79LCLint will occasional report spurious error messages. If you see an error message that you believe to be incorrect first see if you can correct the problem by adding additional precondition annotations. For function with no preconditions LCLint assumes that the function is safe under all conditions. Also consider rewriting the code. Code that is hard for LCLint to understand is often hard was humans to understand as well. You may want to improve the readability and clarity is the code.
80
81If you are sure that the message is spurious you can suppress the message. Adding the /*@i@*/ annotation to a line causes LCLint to suppers all errors generated by the line. Flags can also be set and unset within a program. /*@-flagname@*/ sets a flag to false. /*@+flagname@*/ sets a flag to true and /*@=flagname@*/ returns a flag to its previous state.
82
83
84For example /*@-arroundboundsread@*/ str2[i] = str[i]; /*@=arroundboundsread@*/ would suppress error involving out of bounds reads for the code fragment.
85
86Frequently Asked Questions
87
88I have a function with many buffer overflows but LCLint only reports one error?
89
90LCLint tries to avoid printing redundant error messages. We don't print two constraints if satifying one constraint would satisify another.
91
92LCLint crashes or complains about a bug?
93
94Please report the problem to larochelle@cs.virginia.edu
95
96Where can I find more information about LCLint?
97
98The LCLint web site http://lclint.cs.virginia.edu contains a lot of useful documentation. Such as a paper describing the LCLint extensions for buffer overflow checking.
99The lclint web site also contains information on lclint mailing lists.
100
101
This page took 0.064705 seconds and 5 git commands to generate.