Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CT checker: accept S-CT annotations #773

Merged
merged 3 commits into from
Apr 22, 2024
Merged

CT checker: accept S-CT annotations #773

merged 3 commits into from
Apr 22, 2024

Conversation

vbgl
Copy link
Member

@vbgl vbgl commented Mar 29, 2024

Security annotations for the speculative-ct checker are translated (weakened) when handled by the (non-speculative) CT checker.

@vbgl
Copy link
Member Author

vbgl commented Apr 2, 2024

TODO: when there are both annotations for CT and S-CT, ignore the S-CT one instead of failing.

@vbgl vbgl marked this pull request as ready for review April 5, 2024 20:18
@vbgl
Copy link
Member Author

vbgl commented Apr 5, 2024

Done, and symmetrically ignore CT annotations when a S-CT signature is given.

@vbgl vbgl requested a review from bgregoir April 9, 2024 09:50
@@ -1330,7 +1327,7 @@ let init_constraint fenv f =
let process_return i x annot =
let loc = L.loc x and x = L.unloc x in
let an = Option.bind sig_annot (SecurityAnnotations.get_nth_result i) in
let ls, _ = parse_var_annot ~kind_allowed:false ~msf:(not export) annot in
let ls, _ = try parse_var_annot ~kind_allowed:false ~msf:(not export) annot with Annot.AnnotationError _ -> [], Flexible in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This look suspicious, can you explain it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the variable declaration has an annotation that you don’t know about? Just ignore the parse error and pretends there is no annotation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My problem is that you can catch syntax error in the annotation that are recognised.
And this is done silently.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve just added a warning.

return r;
}

#[sct="{n: a, s: secret} × {n: b, s: secret} → c"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to remove the ct annotation here, I got the following
error:
"CCT/success/sct.jazz", line 10 (0) to line 21 (1):
constant type checker: variable(s) level c should be used in the input security annotations
It may be ok since we have a way to use CT annotation. But I think it is not necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a bug in the CT checker? Or, to put it differently, should the CT checker accept free level variables in return type annotations?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea, is that we should be able to have a better translation from
constraint to max.
a -> b -> b, a <= b ---> a -> b -> max (a, b)
a -> b -> c, a <= c, b <= c ---> a -> b -> max (a, b)
Since I am not sur that we can always do this translation, and obtain
a type that is valid for CT, we can keep it like this for the moment.
It is just that the actual translation is simply more partial that what I have in mind.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had understood that you would prefer doing the translation the other way round: use “max” in annotations and translate that to constraints for use in the actual checker.

Security annotations for the speculative-ct checker are translated
(weakened) when handled by the (non-speculative) CT checker.
let ls =
match parse_var_annot ~kind_allowed:false ~msf:(not export) annot with
| exception Annot.AnnotationError (loc, _msg) ->
warn ~loc "ignored annotation"; []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't want to add msg in the warning :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve removed all of this: the SCT checker no longer attempt to parse #poly annotations.

bgregoir
bgregoir previously approved these changes Apr 19, 2024
@bgregoir bgregoir merged commit c8ecf3d into main Apr 22, 2024
1 check passed
@bgregoir bgregoir deleted the jazzct-sct branch April 22, 2024 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants