Skip to content

detect and handle attribute packed #994

Description

@lsf37

The seL4 C code uses the GCC attributed packed for some structs that are not used in the proofs.

The C parser accepts and ignores the attribute. This is dangerous, because if the attribute is at some point accidentally used for a struct that is relevant for verification, the memory layout generated by the parser will be wrong (wrong offsets, overall size, and alignment, because the compiler will not add padding and the C parser will). Tom found the same issue during binary verification before: https://sel4.atlassian.net/browse/SELFOUR-1590

We should have some kind of check/mechanism for making sure packed is not used accidentally. We could try to forbid it completely, but that will conflict with existing code behind the machine interface and may not always be possible.

Maybe we C parser could recognise the attribute and make the structure unusable in Isabelle by not deriving any of the UMM properties. That would mean the corresponding functions are still translatable and will not fail the build, but we will not be able to prove anything about them unless we derive those properties manually. I'm not clear on what this would do to binary verification -- it would likely fail those functions, but they would have been failing before if the memory layout is not the same as the compiler has.

The other option would be to model packed properly, but that would mean a fairly large change, probably another type class for those kinds of structs, and all that for structs that we explicitly do not want to use in the proofs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-parseranything about the C/Simpl parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions