Skip to content

Leakage-aware specification for memmove - #581

Open
JasonGross wants to merge 1 commit into
mit-plv:masterfrom
JasonGross:fable/leakage-memmove
Open

JasonGross wants to merge 1 commit into
mit-plv:masterfrom
JasonGross:fable/leakage-memmove

Conversation

@JasonGross

Copy link
Copy Markdown
Contributor

Both spec instances of memmove (spec_of_memmove and spec_of_memmove_array) now use the leakage program logic: the postcondition additionally says k' = f dst src n ++ k, where the leakage function f is quantified before the ghost variables, so the leakage depends only on the two pointers and the length, never on the bytes being moved. The concrete function is memmove_trace: it branches on the same pointer comparison the code does and then unrolls the copy loop, leaking the store and load addresses of every iteration. The two loop proofs use LeakageLoops.tailrec with the leakage equation in the loop invariant. br_memcpy in memcpy.v is the only caller of these specs, so its spec becomes a leakage spec too (memmove's leakage followed by the call's leak_unit).

Requested in #565.

Written by Claude Fable 5.1.
🤖 Generated with Claude Code
https://claude.ai/code/session_01YJbiRBkJtM7x6PvYV6hmEm

Both spec instances of memmove (spec_of_memmove over map.of_list_word_at and
spec_of_memmove_array over Array.array ptsto) now use the leakage program
logic: the postcondition additionally says k' = f dst src n ++ k, where the
leakage function f is quantified before the ghost variables, so the leakage
of memmove depends only on the two pointers and the length, never on the
bytes being moved. f is memmove_trace: it branches on the same pointer
comparison the code does and then unrolls the copy loop (memmove_loop_trace)
leaking the store and load addresses of every iteration. The two loop proofs
use LeakageLoops.tailrec with the leakage equation in the loop invariant.

br_memcpy in memcpy.v is the only caller of these specs; its spec becomes a
leakage spec too (k' = f p_d p_s n ++ k, with f = memmove's leakage function
followed by the call's leak_unit).

Requested by Andres Erbsen in mit-plv#565.

Written by Claude Fable 5.1.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJbiRBkJtM7x6PvYV6hmEm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant