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

Fix race/failure to list states in get_states_inner #109

Open
faern opened this issue Jul 24, 2024 · 0 comments
Open

Fix race/failure to list states in get_states_inner #109

faern opened this issue Jul 24, 2024 · 0 comments

Comments

@faern
Copy link
Member

faern commented Jul 24, 2024

The way we currently probe the system for PF states is racy and prone to failing. We first check the number of states -> allocate a container -> ask the system to fill the container. If extra states are created between the first and second syscall then the second call will fail, because the container is too small for all the states.

This should ideally not cause the call to fail. Currently the library user has to invent their own retry logic if they want this to be more stable. This is something we probably should integrate into the library itself. The pfctl CLI tool from BSD has this logic built in, so we should probably as well: https://github.com/openbsd/src/blob/master/sbin/pfctl/pfctl.c#L1047

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

No branches or pull requests

1 participant