-
Notifications
You must be signed in to change notification settings - Fork 84
Analysis of longjmp/setjmp #970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 19 commits
Commits
Show all changes
186 commits
Select commit
Hold shift + click to select a range
4aeb47e
Add tests from #764
michael-schwarz 19e5cda
Add looping test
michael-schwarz 1e405d0
Add library definition
michael-schwarz f29df38
Add rudimentary jumpbufferset domain
michael-schwarz ea79053
Rudimentary tracking of jmp targets
michael-schwarz 3885a17
Analysis getting jump targets
michael-schwarz 029b5af
Store hash in jmpbuf
michael-schwarz c277745
Lift to deal with setjmp
michael-schwarz ed0e795
Detect if longjmp comes from same context
michael-schwarz 66cd6af
Add special node for longjmp targets
michael-schwarz 80d54fb
Towards a working implementation
michael-schwarz c121838
Raise deadcode
michael-schwarz 8899033
Add new node type for returns through longjmp
michael-schwarz 3633c2e
Side-effecting to new unknown for non-local jumps
michael-schwarz 4de1cee
First steps for longjump across functions
michael-schwarz ecd0746
Insert TODO
michael-schwarz e5bb2b9
Track second component in activeLongjmp
michael-schwarz 34ecc9f
Pass along return value
michael-schwarz 934cffe
Skip failing tests
michael-schwarz 04626e3
Make global example global
michael-schwarz 78ec16d
Add missing cases for JumpBuffers
michael-schwarz 74a43fc
Replace `assert` with `__goblint_check`
michael-schwarz cbb6832
Uncomment working test
michael-schwarz 25ce5ca
Add TODO
michael-schwarz 3c20157
Fixes & Unskip two tests
michael-schwarz 9b392d3
Solve issue with duplicate locals
michael-schwarz c14881b
Unskip further working test
michael-schwarz 6746713
Add working tests
michael-schwarz 5595704
Unskip all working tests
michael-schwarz bf8e761
Test 64/18 add explanation
michael-schwarz ea017ae
Add some tests for jumping through multiple functions
michael-schwarz d9b1c15
Add comments & failing test
michael-schwarz 1c9c75e
Use combine, highlight issue
michael-schwarz 105cac4
Add `longjmpthrough` option to combine
michael-schwarz 1c622ac
Handling for logjump from deeper down callstack
michael-schwarz ab7e3b9
Cleanup debug messages
michael-schwarz 887d919
Produce warnings for inappropriate longjmp arg
michael-schwarz 6a42c3e
Use typeOf from Cilfacade instead of from CIL
michael-schwarz cf0b766
Cleanup tracing
michael-schwarz 2b4a1b4
Warn for longjmps up the stack
michael-schwarz f9cd2b5
Better error messages for invalid jumps
michael-schwarz b1fc86b
Add example where warnings still break :(
michael-schwarz 2e4b46f
Add path-sensitive analysis of active setjumps
michael-schwarz c784dd3
Be path-sensitive in set of active longjumps
michael-schwarz a30455a
Fix typos in test name
michael-schwarz cc37046
Use set of valid longjmps to warn if invalid one is performed
michael-schwarz 98b5ab5
Add example for the non-termination of the analysis
michael-schwarz bd80fbc
Add further example
michael-schwarz f4ebfd4
Simplify code
michael-schwarz cd0d9ff
Cleanup
michael-schwarz 3eafede
Add example of multi-threaded case
michael-schwarz 57c21a6
Example for non-unique jmpbufs
michael-schwarz 4462258
Fix so warn is annotation and not race
michael-schwarz 026c000
Merge branch 'master' into longjmp
michael-schwarz 9e6e48f
Update gobview
michael-schwarz ec95f29
Formatting
michael-schwarz 5ec9b26
Add analysis tracking set of locally wirtten values since setjmp
michael-schwarz 8554e39
Tracking of modified locals
michael-schwarz 850b0d6
Add poison variables analysis
michael-schwarz aaf3516
Proof of Concept Poison
michael-schwarz 2777e08
Add libpng example
michael-schwarz e244c0b
Example where wrappers are needed
michael-schwarz a6b8537
Upon invalidate keep jmp_buffers
michael-schwarz a05872a
Actually start with `JmpBufs.bot()` in `bot_value`
michael-schwarz e3550fe
Also poison for non-local longjmps
michael-schwarz a7a0122
Add possibility to trace setjmp
michael-schwarz 53988b8
Remove LHS of assignments again in `poisonVariables`
michael-schwarz 1ba7e5b
Add future test for malloc uniqueness
michael-schwarz ec1ce3e
Use domain for jump buffers that keeps def. elems on T
michael-schwarz be75b8e
Add test for strange things they actually do
michael-schwarz 4bb1492
Slimmed down version of the evil men do
michael-schwarz af4ce3b
Strong updates of structs (#1006)
michael-schwarz dfd8eae
Provide proper ask for taints
michael-schwarz 3c0bcbb
Fix outdated comment
michael-schwarz 7ae2cd2
Comment on `IterSysVars` missing in `hash_arg`
michael-schwarz a8eba70
Include `goblint.h` where that was missing
michael-schwarz d5cbef1
Rm TODO from test that now succeeds
michael-schwarz 3053b7a
Modify test 66/05 so it does something different
michael-schwarz 7823e24
Temporary stopgap
michael-schwarz 98d7401
Use appropriate ask from `ctx_fd'` in combine
michael-schwarz cc193c8
Use iter on JmpBufDomain directly
michael-schwarz 6b90d22
Add readme to setjmp/longjmp examples
michael-schwarz 1fe9175
Cleanup
michael-schwarz 8df94e7
Use correct one-path value also if setjmp has no LHS
michael-schwarz db7d39c
Remove variables from poison again when function returns
michael-schwarz 886981d
Use `path_ctx` in `rec_ctx`
michael-schwarz 7a81623
Better comment
michael-schwarz 132004d
Removed unused argument `origins`
michael-schwarz 0b8426d
Update comments
michael-schwarz 1954860
Cleanup
michael-schwarz f503719
66/39 disable intervals to get rid of overflow warning
michael-schwarz 97e53d4
Take pointers into account for poison
michael-schwarz 896f897
Do not call `filter` on top
michael-schwarz 4dc4672
Add case for lval of call poisonous
michael-schwarz e53162e
Deal with poisoning issues arising from recursive calls
michael-schwarz 7e4bfdc
Do not flag poison for `AddrOf` and `StartOf`
michael-schwarz aa58c5e
Add possibility to split according to return value of `setjmp`
michael-schwarz 489656d
Use `exsplit` for sensitivity in lval of setjmp
michael-schwarz 97512ba
Analysis to warn when calls to setjmp happen potentially in the scope…
michael-schwarz 0276700
`66/45` disable deadcode warnings so `NOWARN` tests correct thing
michael-schwarz 26af4d1
Warn when jmpbufs are copied simply by content
michael-schwarz 2776a1d
Derive eq, ord, hash for FlagHelper to allow comparisons between diff…
jerhard 3ff73b2
Add example highlighting the issue with this keyword binding
michael-schwarz abb9f1a
Warn on `longjmp` to bottom buffer
michael-schwarz 99c73fc
Do not set for explicit bot value
michael-schwarz 3478609
unskip working test
michael-schwarz 7c41ae5
Skip incrementally broken OS X tests
michael-schwarz 7a605fb
Skip incremental 13/01
michael-schwarz 4c80826
Prefix warning about modified locals with Information to make sure th…
michael-schwarz 8c0af07
Remove unnecessary TODO
michael-schwarz 9681d36
Add C argument to GVarF
sim642 e3dc81b
Add longjmpto and longjmpret to GVarF
sim642 7c6a154
Add D argument to GVarG
sim642 d02a85a
Add local domain to GVarG
sim642 dd47104
Replace LongjmpTo node with longjmpto global
sim642 3125e06
Replace LongjmpFromFunction node with longjmpret global
sim642 f4ec418
Remove now unnecessary LongjmpTo and LongjmpFromFunction nodes
sim642 6d0e55d
Extract ControlSpecC to file module to allow dependency cycle breaking
sim642 1f7424f
Don't use hash for longjmp
sim642 5511e85
Make longjmpthrough argument non-optional
sim642 3a1a173
Do return before longjmpret
sim642 0ead7ae
Add failing test for local longjmp with value 0
sim642 4b249c1
Add separate longjmp_return variable
sim642 76edb0e
Remove now unnecessary longjmpthrough
sim642 d1c7796
Merge branch 'longjmp' into longjmp-refactor
sim642 3964ccb
Move longjmp modified locals warning to setjmp
sim642 de36d50
Fix longjmp modified vars warning locations in test
sim642 a1f3db3
Move longjmp poisoning to setjmp
sim642 3f76a99
Remove longjmp target node statement matching
sim642 47f4287
Clean up longjmp handling in tf_normal_call
sim642 16f5619
Clean up longjmp handling in tf_special_call
sim642 b5d0548
Clean up setjmp handling in tf_special_call
sim642 c0ec4e4
Fixes in tf_normal_call longjmp handling
sim642 7e70553
Unify normal and longjmp combine
sim642 e7ca236
Unskip incremental tests
sim642 7aa0202
Merge branch 'master' into longjmp-refactor
sim642 fa87bb9
Shorten longjmp helper analyses' code
sim642 910560c
Upload suite_result as artifact in locked workflow
sim642 d0934fd
Extract LongjmpLifter from FromSpec
sim642 ef07840
Revert "Add local domain to GVarG"
sim642 b7a04e5
Revert "Add D argument to GVarG"
sim642 72e7e95
Revert "Add longjmpto and longjmpret to GVarF"
sim642 11189cf
Revert "Add C argument to GVarF"
sim642 e92700f
Check tracing before longjmp trace
sim642 d39cd31
Fix LongjmpLifter domain naming
sim642 9bb73ee
Extract conv_ctx in LongjmpLifter
sim642 ca26a83
Fix expsplit setjmp warnings
sim642 6c6e45a
Remove unused savesigs and sigrestore fields
sim642 1f6f195
Fix LongjmpLifter lazy indentation
sim642 2120845
Move longjmp-ed variable warning to poisonVariables analysis
sim642 ccbd06b
Remove now-unused Poison event
sim642 2be1c73
Use Longjmped event for base assign
sim642 aaaba6e
Use IdentitySpec for vla analysis
sim642 e9b884a
Move setjmp VLA warning to vla analysis
sim642 cfdcd1a
Remove now-unused MayBeInVLAScope query
sim642 4b90f4a
Move Goblintutil.longjmp_return to base analysis
sim642 dfe6f5c
Remove LONGJMP_RETURN from base state
sim642 ba3437a
Use Access events for modifiedSinceLongjmp
sim642 d7708d3
Use Access events for poisonVariables checks
sim642 6eafd22
Remove now-unnecessary check_exp in poisonVariables analysis
sim642 f2eb6e0
Use Access events for poisonVariables writes
sim642 5c121a4
Remove unused relevants_from_lval_opt in modifiedSinceLongjmp analysis
sim642 e10a091
Refactor poisonVariables return
sim642 3713ef9
Clean up EvalJumpBuf
sim642 0e43d1e
Clean up base Setjmp & Longjmp
sim642 61e7e3c
Add failing test for longjmp with indeterminate non-top value
sim642 4937abf
Merge branch 'longjmp' into longjmp-refactor
sim642 0c5d390
Fix base longjmp indefinite value change
sim642 a1e13ba
Categorize longjmp warnings
sim642 0bc2f1e
Add Cilfacade.isVLAType for vla analysis
sim642 e81f3b3
Add is_top checks back to poisonVariables analysis
sim642 0f8f7b0
Enable OCaml backtraces in locked workflow
sim642 04c56e5
Use pretty instead of show in longjmp messages and tracing
sim642 37c3ce1
Refactor taintPartialContexts return
sim642 0e9af2c
Remove hardcoded analysis names in access analysis
sim642 e4d855e
Check global_initialization for threadreturn main thread workaround
sim642 be360d1
Merge branch 'master' into longjmp
sim642 7940e98
Merge branch 'longjmp' into longjmp-refactor
sim642 b25b900
Add must/may back to longjmp value messages
sim642 655a7ae
Fix activeLongjmp analysis threadenter TODO
sim642 63fdd47
Add problematic example
michael-schwarz 2937c0a
Fix longjmp combine to not assign to lval
sim642 167a13b
Remove passing TODO from longjmp/multifun test
sim642 1f38378
Merge pull request #1015 from goblint/longjmp-refactor
sim642 578264c
Move sigsetjmp & siglongjmp to POSIX group
sim642 99ed984
Fix base longjmp comment indentation
sim642 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| (** Analysis tracking which longjmp is currently active *) | ||
|
|
||
| open Prelude.Ana | ||
| open Analyses | ||
|
|
||
| (* module Spec : Analyses.MCPSpec with module D = Lattice.Unit and module C = Lattice.Unit and type marshal = unit = *) | ||
| (* No signature so others can override module G *) | ||
| module Spec = | ||
| struct | ||
| include Analyses.DefaultSpec | ||
|
|
||
| let name () = "activeLongjmp" | ||
| module D = JmpBufDomain.JmpBufSet | ||
| module C = Lattice.Unit | ||
|
|
||
| (* transfer functions *) | ||
| let assign ctx (lval:lval) (rval:exp) : D.t = | ||
| ctx.local | ||
|
|
||
| let branch ctx (exp:exp) (tv:bool) : D.t = | ||
| ctx.local | ||
|
|
||
| let body ctx (f:fundec) : D.t = | ||
| ctx.local | ||
|
|
||
| let return ctx (exp:exp option) (f:fundec) : D.t = | ||
| ctx.local | ||
|
|
||
| let enter ctx (lval: lval option) (f:fundec) (args:exp list) : (D.t * D.t) list = | ||
| [ctx.local, ctx.local] | ||
|
|
||
| let combine ctx (lval:lval option) fexp (f:fundec) (args:exp list) fc (au:D.t) : D.t = | ||
| au | ||
|
|
||
| let special ctx (lval: lval option) (f:varinfo) (arglist:exp list) : D.t = | ||
| let desc = LibraryFunctions.find f in | ||
| match desc.special arglist, f.vname with | ||
| | Longjmp {env; value; sigrestore}, _ -> | ||
| (* Put current buffer into set *) | ||
| let bufs = ctx.ask (EvalJumpBuf env) in | ||
| bufs | ||
| | _ -> ctx.local | ||
|
|
||
| let startstate v = D.bot () | ||
| let threadenter ctx lval f args = [D.top ()] | ||
| let threadspawn ctx lval f args fctx = ctx.local | ||
| let exitstate v = D.top () | ||
|
|
||
| let context _ _ = () | ||
|
|
||
| let query ctx (type a) (q: a Queries.t): a Queries.result = | ||
| match q with | ||
| | ActiveJumpBuf -> | ||
| (* Does not compile without annotation: "This instance (...) is ambiguous: it would escape the scope of its equation" *) | ||
| (ctx.local:JmpBufDomain.JmpBufSet.t) | ||
| | _ -> Queries.Result.top q | ||
| end | ||
|
|
||
| let _ = | ||
| MCP.register_analysis (module Spec : MCPSpec) |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| module BufferEntry = Printable.ProdSimple(Node)(IntDomain.Flattened) | ||
|
|
||
| module JmpBufSet = | ||
| struct | ||
| include SetDomain.ToppedSet (BufferEntry) (struct let topname = "All jumpbufs" end) | ||
| let name () = "Jumpbuffers" | ||
| end |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.