Repository navigation
Challenge 13: unbounded verification of strlen's loop - #798
larkindaniel wants to merge 2 commits into
Conversation
|
Some context here: @larkindaniel is working with me. I was wanting to see whether strlen could be unboundedly verified (I thought it could be), even if that wasn't a condition for the original challenge as stated. However, this PR changes the upstream code; perhaps the relevant changes could be mergeable upstream. We talked about the approach in #681, and could follow it more closely as well. In terms of improving the verification, this PR verifies more than we had collectively verified in the past, so I would say that it's a step forward, but not unmitigated, because of the upstream change. And, to be fair, it also doesn't verify the FFI branch. That's out of scope of verify-std in general, even if it is the more likely threat to actual safety. Would welcome thoughts by @feliperodri and others as well. |
Items inside `const_eval_select!` can't be named from outside, so a harness can't reach the loop. Move it, unchanged, into `strlen_loop`. No change in behaviour.
Add a loop invariant to `strlen_loop` and a harness that checks it for strings of any length. Both are Kani-only.
f298b0a to
7b4315f
Compare
Towards #150. Follow-up to #638, which verifies
strlenwith bounded harnesses.This proves the loop in
strlen'sif constarm for strings of any length, using a loop invariant instead of an unwind bound.Changes
strlen_loopso a harness can call it. Items insideconst_eval_select!can't be named from outside. The compiled code is identical.check_strlen_loop_unbounded. Both are Kani-only.How it works
The harness allocates a buffer of any size up to 2^48 bytes and picks any nul in it,
nul_at. The loop invariant islen <= nul_at. Sincenul_atcan be any nul,len <= nul_atat the end meanslenis the first one.Planting bugs in the loop (e.g.
len += 2, or!= 1instead of!= 0) makes the harness fail.Not proven
--object-bits 12-Z uninit-checksis off in CI)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.