News for hackers. Stuff that matters.
Re:Writing correct lock-free and distributed stateful system... by munin on Friday May 19, 2017 @07:40AM (#14374626)
This is a gap in this kind of verification work. Systems like coq get around this by having a facility to "extract" code from the proof itself. You would define your algorithm as a Fixpoint, prove properties of that Fixpoint, then extract that Fixpoint into some ocaml code and use it directly in your real programs. This closes the loop you describe, insamuch as you trust the extraction process and the ocaml compiler and runtime (but other work is ongoing to close that loop as well).
Re:Writing correct lock-free and distributed stateful system... by pron on Friday May 19, 2017 @09:56AM (#14375639)
It's not "getting around", and one could write an extraction tool like that for TLA+, too. The difficulty is simply verifying any system, by whatever method, end-to-end, namely verifying that the high-level global correctness properties are preserved all the way down to machine code. We simply have no idea how to do it for real-world, large software, and in those cases it's been done for small, simple software (seL4, CompCert), the process was extremely expensive.
Re:Writing correct lock-free and distributed stateful system... by chrisseaton on Friday May 19, 2017 @07:46AM (#14374670)
The loop is always open though. Who verifies your verification code? Who verifies the processor implementation? All you can do is reduce the gap in the loop surely?
Re:Writing correct lock-free and distributed stateful system... by munin on Friday May 19, 2017 @09:27AM (#14375372)
You can close all of those. You can have large amounts of your verifier itself be verified. You can verify the CPU design (hardware people tell me this used to be standard, and a lot of the formal methods community has roots in verifying hardware).

What you can't close is the language that you use to do all the verification in, itself. You wind up with a core calculus that you have to stare at really hard and trust / prove via other means.

Re:Writing correct lock-free and distributed stateful system... by nickpsecurity on Friday May 19, 2017 @12:40PM (#14377302)
To support your point, Jared Davis and Magnus Myreen did the Milawa prover that builds the logic and implementation in layers starting with a hand-checked, tiny logic. Builds all the way to first-order prover with each layer getting re-checked by those below where feasible. Uses Myreen's method for verification to assembly (or machine code?). So, it's already been done.

http://www.cs.utexas.edu/users/jared/milawa/Web/

The other approach I investigated was proving the logics sound in set theory given it's well-understood, trusted, and widely deployed by mathematicians. Once the logics like FOL or HOL are verified, we just have to verify the specs and checkers (already done to in progress). Run on diverse hardware to prevent glitches there. From then on, mainly just look at logical specs since we should be good. I also found a verified compiler that uses Z specs with Prolog code... a method that might be used with Milawa for bootstrapping trust.

Re:Writing correct lock-free and distributed stateful system... by roblabla on Friday May 19, 2017 @11:08AM (#14376398)
Isn't this susceptible to a trusting trust[0] attack, where your verifier has a bug that makes it verify itself, even though it shouldn't ?

It's always possible there is a loop somewhere. The best you can hope for is make it infinitesimally small.

[0]: http://wiki.c2.com/?TheKenThompsonHack

Re:Writing correct lock-free and distributed stateful system... by seagreen on Friday May 19, 2017 @12:01PM (#14376942)
There's been a simple counter to trusting trust attacks since 2009: https://www.dwheeler.com/trusting-trust/
Re:Writing correct lock-free and distributed stateful system... by nonsince on Saturday May 20, 2017 @01:31AM (#14381184)
If I understand the abstract correctly, that relies on having a trusted compiler, which assumably would have to be bootstrapped ultimately from a trusted hand-written compiler in machine code. This effectively counters malicious trusting trust attacks but does not effectively counter trusting trust attacks due to error, because your entire trusted stack has to be correct.

That's not to say there's no way to close the loop here, simply that I don't know that this is it.

Re:Writing correct lock-free and distributed stateful system... by dllthomas on Saturday May 20, 2017 @12:26PM (#14383104)
You don't understand the abstract correctly. It relies on having compilers from diverse sources, unlikely to share the same malicious modification. It does not rely on any of them being trusted.
Re:Writing correct lock-free and distributed stateful system... by mcguire on Friday May 19, 2017 @11:56AM (#14376897)
A trusting trust attack cannot be eliminated, only be made prohibitively expensive. One way to do that is by using multiple verifier back-ends.
Re:Writing correct lock-free and distributed stateful system... by nickpsecurity on Friday May 19, 2017 @12:30PM (#14377195)
No. The Karger attack on compilers that Thompson talked about was mitigated far as methods to use before Thompson even published it. You just use a verified interpreter, compiler, and/or CPU for the bootstrap. Hardware is couriered with tamper-evident seals. Software built from source or at least use crypto to verify source. It's also least likely attack you'll run into: 0-days in your stuff or compilers optimising away security is more common.

A medium-assurance solution is 3+ compilers with same input and output on diverse hardware by diverse teams unlikely to collude all producing ssme result. If hardware, you can do that with chips plus voting scheme.

Re:Writing correct lock-free and distributed stateful system... by paulddraper on Saturday May 20, 2017 @07:26AM (#14381904)
Considering there is an infinitesimally small chance that a meteor will kill me before I hit "submit", I'll take that chance.

EDIT: Whew!

Re:Writing correct lock-free and distributed stateful system... by DanWaterworth on Friday May 19, 2017 @11:05AM (#14376365)
You always have to make assumptions in any formal system able to express arithmetic as proved by Gödel.
Re:Writing correct lock-free and distributed stateful system... by nickpsecurity on Friday May 19, 2017 @07:53AM (#14374708)
It's been done down to the hardware. Originally by Computational Logic Inc for FM9001 whose prover became ACL2. Then Verisoft went from apps to OS to C subset to VAMP processor (DLX-style). Recently people are doing HOL to hardware that will integrate with HOL/Light whose core is a few hundred or thousand lines to trust. Those people eliminated trust requirements in everything from extraction mechanisms to provers to assembly generation:

http://www.cse.chalmers.se/~myreen/

Follow he and his colleagues work for all that. Especially Milawa and CakeML. If you want a starting point, a small, Forth-like processor verifiable by hand on a node verifiable by eye could run the initial interpreter and prover for the first, real CPU. Plus, common practice is to split work into untrusted generation of artifacts with traces that are verified by a trusted checker that's comparatively tiny and simple. The little CPU would just run the checkers. You can run the generation on anything you like with the speed benefit. :)

Re:Writing correct lock-free and distributed stateful system... by unboxed_type on Friday May 19, 2017 @08:09AM (#14374805)
What about real CPUs (much more complex than 'Forth CPU'), network adapters (has its own CPU), memory controllers, real OS kernels, POSIX library (which is sometimes loosely specified) and so on?

As far as I understand modern truly reliable system (commerical avionics-like) still must be relatively simple to be verified up to hardware level.

Re:Writing correct lock-free and distributed stateful system... by nickpsecurity on Friday May 19, 2017 @09:27AM (#14375369)
Real CPU's are formally verified for certain properties with rigorous tests. That's why they have only 100-300 errors in something with a billion transistors. That practice started after a recall. Now, for examples of full, mathematical verification of about every aspect you're looking at VAMP and AAMP7G.

http://www.spbguga.ru/files/Formal_Verification_of_a_Process...

http://www.ccs.neu.edu/home/pete/acl206/slides/hardin.pdf

VAMP is a pretty-complex, DLX-style CPU. I think they extended it to multicore or concurrency of some kind in another work. Original was single core, though. Passed all the FPGA tests. The AAMP7G combines a stack machine, over a hundred instructions, microcode engine, and separation kernel into one CPU. It was first in recent times in high-assurance security to use microcoding. I tell everyone to do that since it lets us easily change the behavior of the hardware without reverifying everything. Their tools also let you verify software semi-automatically against a model of the hardware ISA. Main stuff is paywalled but this is best free one I could get you. On availability side, they also run three units at once with a voter to reduce the odds the chip will fail. Truly high-assurance exemplar in availability and security.

The prover is ACL2. You can do a trusted checker for that in few lines of code. You might need a lot of RAM and CPU time, though. Even all that can be a few blocks verified by eye and hand that you just plaster over a bunch of silicon then verify correctness automatically. There's also techniques where a partial failure can be magnified into total, visible failure. Tandem/HP NonStop does stuff like that to catch and replace failed components before system downtime happens. So, you can be reasonably sure the components are working even if defects happen during fabrication.

Re:Writing correct lock-free and distributed stateful system... by joshuata on Friday May 19, 2017 @12:52PM (#14377417)
An interesting solution to this problem is verification witnesses[1]. A witness is a machine readable record of a verification task. Several different programs can read the witness and verify it independently. It is especially useful for counterexamples, where it can be a simple program trace to the error state. Given the input program and witness another can check whether the error state is reached.

[1] https://www.sosy-lab.org/~dbeyer/verification-witnesses/

Re:Writing correct lock-free and distributed stateful system... by samth on Friday May 19, 2017 @11:20AM (#14376524)
Right, the concept of the TCB (trusted computing base) is the important thing. Good discussions of remaining TCB in verified code are in the seL4 work, or in this paper: https://www.cs.princeton.edu/~appel/papers/verif-sha-2.pdf
Re:Writing correct lock-free and distributed stateful system... by nickpsecurity on Friday May 19, 2017 @12:32PM (#14377218)
See my link to Myreen's page and follow all those people's publications. Much of the TCB functions in papers like that has been eliminated in other work. It just needs to be cross-checked, integrated, and applied.
Re:Writing correct lock-free and distributed stateful system... by samth on Friday May 19, 2017 @01:58PM (#14377963)
Right, that's one of the nice things about Appel's paper: he shows how to integrate a few different pieces to significantly reduce the TCB (ie, it doesn't include anything about C the language at all).
Re:Writing correct lock-free and distributed stateful system... by nickpsecurity on Friday May 19, 2017 @01:59PM (#14377976)
I think the one you're talking about got the TCB down to a few hundred lines of C. Done in Twelf.
Re:Writing correct lock-free and distributed stateful system... by samth on Friday May 19, 2017 @05:34PM (#14379521)
No, I'm talking about the one I linked to, which is done in Coq.
Re:Writing correct lock-free and distributed stateful system... by nickpsecurity on Friday May 19, 2017 @09:15PM (#14380486)
Oh my bad. I just saw work such as seL4 then assumed it was a seL4 reference. I actually didn't have this one by Appel. Thanks for the paper! :)

Here's the one I was referencing with the tiny TCB:

https://www.cs.princeton.edu/~appel/papers/flit.pdf

OK. So, it was a few Kloc. Still smaller than Coq. They could probably get it even smaller with recent work given translation validation knocks compilers out of TCB. So, in between 803-2668loc.

Re:Writing correct lock-free and distributed stateful system... by dronemallone on Friday May 19, 2017 @09:41AM (#14375494)
That "facility" is the Curry-Howard correspondence!
Re:Writing correct lock-free and distributed stateful system... by mafribe on Friday May 19, 2017 @11:15AM (#14376471)
Not necessarily. Isabelle/HOL, an prover not based on CH but on the LCF-architecture, can also do program extraction, see e.g. Program extraction in Isabelle:

https://wwwbroy.in.tum.de/~berghofe/papers/TYPES2002_slides....

Re:Writing correct lock-free and distributed stateful system... by samth on Friday May 19, 2017 @05:36PM (#14379533)
Extraction of terms written using Fixpoint isn't really the Curry-Howard correspondence. Instead, the correspondence is between (for example) proofs of correctness and terms in the Calculus of Constructions.

[Fixpoint terms are also CIC programs, so there's a sense in which they're related, but it's not really about Curry-Howard.]

Re:Writing correct lock-free and distributed stateful system... by nonsince on Saturday May 20, 2017 @01:20AM (#14381172)
If the OCaml code is Standard ML-compliant you could run it on Cake, then you only have to trust the conversion