-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Prevent TOCTOU bugs in ComponentsQueuedRegistrator #20016
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
/// The [`TypeId`] must not already be registered or queued as a component. | ||
unsafe fn force_register_arbitrary_component( | ||
/// The [`TypeId`] must not already be registered as a component. | ||
unsafe fn register_arbitrary_component( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove force
from the names? They're still queuing without first checking that the components are registered, which is a kind of "forcing".
The names queue_register_component
and register_arbitrary_component
don't do a great job of communicating the difference, although I suppose force_register_arbitrary_component
wasn't much better.
Hmm, I wonder if it would make sense to make a future PR to inline these into their callers so that we don't need two names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point, but at the same time they are no longer really forcing the registration. They are more like register_if_not_enqueued
or something like that, but it doesn't sound so good as a name.
} | ||
|
||
/// Queues this function to run as a resource registrator. | ||
/// Queues this function to run as a resource registratorif the given |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Queues this function to run as a resource registratorif the given | |
/// Queues this function to run as a resource registrator if the given |
Objective
ComponentsQueuedRegistrator::queue_register_component
does not ensure components are registered only once #20014Solution
force_register_
family of functions always enqueue of the component/resource; instead have them check again whether it was already queued or not.Testing