Repository navigation
[bufferoverrun] fix the minimum of two capped symbolic bounds - #2333
Closed
VladimirMakaev wants to merge 1 commit into
Closed
VladimirMakaev wants to merge 1 commit into
VladimirMakaev wants to merge 1 commit into
Conversation
A bound `c - max(d, s)` is capped at `c - d`, the value it takes once the max picks the
constant. For two such bounds `exact_min` combined the caps with `max` instead of `min`, so for
incomparable operands it returned a value above their true minimum. Through `underapprox_min`
and `overapprox_max` that made the interval join drop values, and overruns on the dropped
values went unreported.
int pick(int x, int b) {
int k = x; if (k < -1) k = -1; k = k + 1; /* 1 + max(-1, x) */
int m = x; if (m < 2) m = 2; /* max(2, x) */
return b ? k : m; /* joined to 1 + max(-1, x), which is 0 at x = -20, so */
} /* a[pick(-20, g())] = 0 on a two-element array was silent */
The join is now `1 + max(1, x)`, the exact maximum, so no precision is given up. The same
branch is reached from `overapprox_min` and `underapprox_max`, where the old value was sound
but loose and is now exact as well, so pruning and `min`/`max` can get tighter. The companion
case for `c + min(d, s)` already combined the caps with `min` and is unchanged.
## Test plan
New C cases in `codetoanalyze/c/bufferoverrun/minmax.c` for the joined upper bound, the joined
lower bound and an unsigned symbol: each overrun is now reported and each in-bounds companion
stays silent. Every other expectation is unchanged.
Contributor
|
bufferoverrun has been deprecated for a long time with no one with expertise around. I doubt we will get to a place where we can find real issues, but let me know if you have a plan here. |
Contributor
Author
|
Thanks, closing this: we'll keep the bufferoverrun changes in our fork and won't pursue them upstream. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A bound
c - max(d, s)is capped atc - d, the value it takes once the max picks theconstant. For two such bounds
exact_mincombined the caps withmaxinstead ofmin, so forincomparable operands it returned a value above their true minimum. Through
underapprox_minand
overapprox_maxthat made the interval join drop values, and overruns on the droppedvalues went unreported.
The join is now
1 + max(1, x), the exact maximum, so no precision is given up. The samebranch is reached from
overapprox_minandunderapprox_max, where the old value was soundbut loose and is now exact as well, so pruning and
min/maxcan get tighter. The companioncase for
c + min(d, s)already combined the caps withminand is unchanged.Test plan
New C cases in
codetoanalyze/c/bufferoverrun/minmax.cfor the joined upper bound, the joinedlower bound and an unsigned symbol: each overrun is now reported and each in-bounds companion
stays silent. Every other expectation is unchanged.
The macOS build and the Objective-C buffer-overrun target this change affects also pass:
VladimirMakaev#13