Skip to content

Commit e8285fe

Browse files
committed
TAP update
1 parent b6028d1 commit e8285fe

File tree

209 files changed

+64254
-299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+64254
-299
lines changed

article/correct.c

Lines changed: 0 additions & 23 deletions
This file was deleted.

article/incorrect.c

Lines changed: 0 additions & 14 deletions
This file was deleted.

article/specification.h

Lines changed: 0 additions & 48 deletions
This file was deleted.

confidentiality/confidentiality.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ unsigned user_level;
88
* Should be called at the beginning of main (or ideally before).
99
*/
1010
int init() {
11-
pages = malloc(MAX_PAGE_NB * sizeof(struct Page));
11+
pages = (struct Page*) malloc(MAX_PAGE_NB * sizeof(struct Page));
1212
if(pages == NULL)
1313
return 0;
1414
/*@
1515
loop invariant 0 <= i <= MAX_PAGE_NB;
1616
loop invariant \forall unsigned j; 0 <= j < i ==>
1717
pages[j].status == PAGE_FREE && pages[j].confidentiality_level == 0;
18+
loop assigns i, *(pages + (0 .. MAX_PAGE_NB - 1));
1819
*/
1920
for(unsigned i = 0 ; i < MAX_PAGE_NB ; ++i) {
2021
char* p = malloc(PAGE_SIZE * sizeof(char));
@@ -37,6 +38,7 @@ int init() {
3738
struct Page* find_free_page() {
3839
/*@
3940
loop invariant 0 <= i <= MAX_PAGE_NB;
41+
loop assigns i;
4042
*/
4143
for(int i = 0 ; i < MAX_PAGE_NB ; ++i)
4244
if(pages[i].status == PAGE_FREE)

confidentiality/confidentiality.h

Lines changed: 100 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -161,102 +161,147 @@ int page_decrypt(struct Page* p);
161161

162162
//========================== METAPROPERTIES ====================
163163

164+
/*@
165+
meta \macro,
166+
\name(\forall_page),
167+
\arg_nb(2),
168+
\forall int i; 0 <= i < MAX_PAGE_NB ==>
169+
\let \param_1 = pages + i; \param_2;
170+
171+
meta \macro,
172+
\name(page_data),
173+
\arg_nb(1),
174+
\param_1->data + (0 .. PAGE_SIZE - 1);
175+
176+
meta \macro,
177+
\name(\constant),
178+
\arg_nb(1),
179+
\separated(\written, \param_1);
180+
181+
meta \macro,
182+
\name(\hidden),
183+
\arg_nb(1),
184+
\separated(\read, \param_1);
185+
186+
meta \macro,
187+
\name(not_called),
188+
\arg_nb(1),
189+
!\fguard(\called == \param_1);
190+
191+
logic enum allocation_status page_status(struct Page* p) = p->status;
192+
logic unsigned page_level(struct Page* p) = p->confidentiality_level;
193+
predicate page_allocated(struct Page* p) = p->status == PAGE_ALLOCATED;
194+
predicate page_lower(struct Page* p, unsigned user_level) =
195+
user_level > p->confidentiality_level;
196+
*/
197+
164198
/*@
165199
//Page status is only modified in page_alloc/init/free
166-
meta status_constant: \forall function f;
167-
! \subset(f, {\f(init), \f(page_alloc), \f(page_free)}) ==> \writing(f),
168-
\forall int i; 0 <= i < MAX_PAGE_NB ==> \let p = pages + i;
169-
\separated(\written, &p->status);
200+
meta \prop,
201+
\name(status_constant),
202+
\targets(\diff(\ALL, {init, page_alloc, page_free})),
203+
\context(\writing), \forall_page(p, \constant(&p->status));
170204
*/
171205

172206
/*@
173207
//Never write to a lower confidentiality page outside of free
174-
meta confidential_write: \forall function f;
175-
! \subset(f, {\f(page_free), \f(init)}) ==>
176-
\writing(f),
177-
\forall int i; 0 <= i < MAX_PAGE_NB ==>
178-
\let p = pages + i;
179-
p->status == PAGE_ALLOCATED ==>
180-
user_level > p->confidentiality_level ==>
181-
\separated(\written, p->data + (0.. PAGE_SIZE - 1));
208+
meta \prop,
209+
\name(confidential_write),
210+
\targets(\diff(\ALL, {page_free, init})),
211+
\context(\writing),
212+
\forall_page(p,
213+
page_allocated(p) && user_level > page_level(p) ==>
214+
\constant(page_data(p))
215+
);
182216
*/
183217

184218
/*@
185219
//Never read from a higher confidentiality page
186-
meta confidential_read: \forall function f;
187-
\reading(f),
188-
\forall int i; 0 <= i < MAX_PAGE_NB ==>
189-
\let p = pages + i;
190-
p->status == PAGE_ALLOCATED ==>
191-
user_level < p->confidentiality_level ==>
192-
\separated(\read, p->data + (0.. PAGE_SIZE - 1));
220+
meta \prop,
221+
\name(confidential_read),
222+
\targets(\ALL),
223+
\context(\reading),
224+
\forall_page(p,
225+
page_allocated(p) && user_level < page_level(p) ==>
226+
\hidden(page_data(p))
227+
);
193228
*/
194229

195230
/*@
196231
//Free pages are not written upon
197-
meta constant_free_pages: \forall function f;
198-
!\subset(f, \f(init)) ==> \writing(f),
199-
\forall unsigned i;
200-
0 <= i < MAX_PAGE_NB ==>
201-
pages[i].status == PAGE_FREE ==>
202-
\separated(\written, pages[i].data + (0 .. PAGE_SIZE - 1));
232+
meta \prop,
233+
\name(constant_free_pages),
234+
\targets(\diff(\ALL, init)),
235+
\context(\writing),
236+
\forall_page(p,
237+
!page_allocated(p) ==> \constant(page_data(p))
238+
);
203239
*/
204240

205241
/*@
206242
//Free pages are not read from
207-
meta hidden_free_pages: \forall function f;
208-
!\subset(f, \f(init)) ==> \reading(f),
209-
\forall unsigned i;
210-
0 <= i < MAX_PAGE_NB ==> pages[i].status == PAGE_FREE ==>
211-
\separated(\read, pages[i].data + (0 .. PAGE_SIZE - 1));
243+
meta \prop,
244+
\name(hidden_free_page),
245+
\targets(\diff(\ALL, init)),
246+
\context(\reading),
247+
\forall_page(p,
248+
!page_allocated(p) ==> \hidden(page_data(p))
249+
);
212250
*/
213251

214252
/*@
215253
//Current confidentiality is only modified through raise/lower_conf_level
216-
meta \forall function f;
217-
! \subset(f, {\f(raise_conf_level), \f(lower_conf_level), \f(init)}) ==>
218-
\writing(f), \separated(\written, &user_level);
254+
meta \prop,
255+
\name(curconf_wrapped),
256+
\targets(\diff(\ALL, {raise_conf_level, lower_conf_level, init})),
257+
\context(\writing), \constant(&user_level);
219258
*/
220259

221260
/*@
222261
//Confidentiality modifiers are not called within the library
223-
meta \forall function f;
224-
\calling(f),
225-
\called != (char**) raise_conf_level &&
226-
\called != (char**) lower_conf_level;
262+
meta \prop,
263+
\name(curconf_wrapped_2),
264+
\targets(\ALL),
265+
\context(\calling),
266+
not_called(raise_conf_level) &&
267+
not_called(lower_conf_level);
227268
*/
228269

229270
/*@
230271
//The content of a free page is always null
231-
meta free_page_null: \forall function f; !\subset(f, \f(init)) ==>
232-
\strong_invariant(f),
233-
\forall unsigned i; 0 <= i < MAX_PAGE_NB ==>
234-
pages[i].status == PAGE_FREE ==> clean_page(pages + i);
272+
meta \prop,
273+
\name(free_page_null),
274+
\targets(\diff(\ALL, init)),
275+
\context(\strong_invariant),
276+
\forall_page(p, !page_allocated(p) ==> clean_page(p));
235277
*/
236278

237279
/*@
238280
//The confidentiality of an allocated page is constant outside of encrypt/decrypt
239-
meta constant_conf_level: \forall function f;
240-
! \subset(f, {\f(init), \f(page_encrypt), \f(page_decrypt)}) ==>
241-
\writing(f),
242-
\forall unsigned i; 0 <= i < MAX_PAGE_NB ==>
243-
pages[i].status == PAGE_ALLOCATED ==>
244-
\separated(\written, &pages[i].confidentiality_level);
281+
meta \prop,
282+
\name(constant_conf_level),
283+
\targets(\diff(\ALL, {init, page_encrypt, page_decrypt})),
284+
\context(\writing),
285+
\forall_page(p,
286+
page_allocated(p) ==> \constant(&p->confidentiality_level)
287+
);
245288
*/
246289

247290
/*@
248291
//The encryption level is constant outside of encrypt/decrypt
249-
meta constant_enc_level: \forall function f;
250-
! \subset(f, {\f(init), \f(page_encrypt), \f(page_decrypt)}) ==>
251-
\writing(f),
252-
\forall unsigned i; 0 <= i < MAX_PAGE_NB ==>
253-
\separated(\written, &pages[i].encrypted_level );
292+
meta \prop,
293+
\name(constant_enc_level),
294+
\targets(\diff(\ALL, {init, page_encrypt, page_decrypt})),
295+
\context(\writing),
296+
\forall_page(p, \constant(&p->encrypted_level));
254297
*/
255298

256299
/*@
257300
//The encryption/decryption primitives are only called within page_encrypt
258301
//and page_decrypt
259-
meta encdec_uncalled: \forall function f;
260-
! \subset(f, {\f(page_encrypt), \f(page_decrypt)}) ==> \calling(f),
261-
\called != (char**)encrypt && \called != (char**)decrypt;
302+
meta \prop,
303+
\name(encdec_uncalled),
304+
\targets(\diff(\ALL, {page_encrypt, page_decrypt})),
305+
\context(\calling),
306+
not_called(encrypt) && not_called(decrypt);
262307
*/

0 commit comments

Comments
 (0)