RBAC: Fix use-after-free in security::acl_store #17414
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
acl_store: Sub node_hash_map for flat_hash_map in remove_bindings
We maintain a running vector of roles principal views to delete from a small
cache maintained by each matched acl_entry_set. The value type is a view to
avoid excessive copying, but that view is always into the principal component
of a key entry (acl_binding) in a flat_hash_map.
This is problematic because any insertion into flat_hash_map might result in
a rehash, invalidating key pointers (including the pointer to key struct member
contained in the principal_view), resulting in use-after-free errors whenever
the following conditions are met:
This commit also adds a test for this (common) situation. I've verified that
without this change, the test does indeed crash as expected.
Fixes https://github.com/redpanda-data/core-internal/issues/1202
Backports Required
Release Notes