Skip to content

Is lock required for accessing map/program objects in hash maps? #707

Answered by dthaler
shankarseal asked this question in Q&A
Discussion options

You must be logged in to vote

A lock is acquired in _delete_array_map_entry_with_reference() so I think the lack of acquiring it in _delete_hash_map_entry_with_reference() is probably a bug. If I remember right, the lock is trying to provide a guarantee against things like ID reuse where ebpf_object_reference_by_id() ends up referencing an object other than the one originally stored in the map. Though I think the ID generation algorithm uses a 2-byte counter per index so you can't get ID reuse unless you could do 2^16 deletion/additions in between snapshotting the entry value (ID) and taking the tracking list lock inside ebpf_object_reference_by_id(). If we think that is sufficient protection then a separate lock is n…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@shankarseal
Comment options

shankarseal Jan 10, 2022
Maintainer Author

@dthaler
Comment options

@shankarseal
Comment options

shankarseal Jan 11, 2022
Maintainer Author

Answer selected by dthaler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants