stdlib audit: inheritable DLS for configurable options#11228
stdlib audit: inheritable DLS for configurable options#11228Octachron merged 2 commits intoocaml:trunkfrom
Conversation
|
When I call We could consider the following:
So I guess my question is: do we want domain-local state here or really global (atomic) state? |
|
Like @gasche I would prefer the setting for hash table randomization to be an atomic global rather than per-domain. A per-domain setting for the temporary directory makes perfect sense, but the hash table randomization setting is peculiar, in particular because it (purposefully) can be changed only once. Applications that want to protect against hash table collision attacks are supposed to call |
|
I agree that it also make sense to have randomized a global setting. However, I am not sure if it should be an atomic itself? If multiple domains are at play, don't we have the problem that Thus I have the impression that changing
by ensuring that the order |
|
You're probably right that an atomic bool or a bool ref make little difference in this particular case. The good thing about atomic bool is that it makes the intent clear right in the source code: yes, this is not protected by a mutex, but we have determined that it's OK to access concurrently. |
|
I also found a counter-example to my mental model of the issue:
I would expect that the second domain eventually see the write to |
|
I have switched to an atomic for randomized. |
xavierleroy
left a comment
There was a problem hiding this comment.
Looks very good to me. Minor documentation nitpick below.
| protect themselves against the denial-of-service attack described | ||
| in {!create} call [Hashtbl.randomize()] at initialization | ||
| time. | ||
| time before any children domains are created. |
There was a problem hiding this comment.
I believe "child domains" is more widely used than "children domains". An example from an Oracle documentation: "When a UNIX process initiates one or more dependent processes, we call these child processes, or children."
This said you could also write "before any domains are created".
There was a problem hiding this comment.
I believe that child domains is better than any domains since there is no ambiguity on the first domain. And yes child domains sound better than children domains.
There was a problem hiding this comment.
But doesn't child introduce a concept that doesn't really exist ? AFAIK there no notion of parent/child relationship in domains.
Yet another proposal: before any new domain is created.
There was a problem hiding this comment.
There is a notion of parent and child domains introduced by domain local storage. Nevertheless, you are right that it better to not introduce adjacent concepts in the description. At the same time, speaking of before new domains muddles a bit the notion of before. So maybe before any domains is the right compromise since the main domain cannot be created by users.
3e66caf to
13057dd
Compare
stdlib/filename.mli
Outdated
| (** Change the temporary directory returned by {!Filename.get_temp_dir_name} | ||
| and used by {!Filename.temp_file} and {!Filename.open_temp_file}. | ||
| The temporary directory is a domain-local value which is inherited | ||
| by children domains. |
There was a problem hiding this comment.
Another "children domains" that I missed on first reading.
There was a problem hiding this comment.
Fixed, there are no longer any remnant of "children domains" in the repository.
13057dd to
8216acb
Compare
The
HashtblandFilenamemodules expose two configurable default options as global mutable states: the state inHashtbltracks if hash tables are randomized by default, whereas the one inFilenamestores the default directory name for temporary files.The expected use case for both options is that they will be set during the initialization part of the program and then left alone.
This PR proposes to make this policy more explicit by storing those configurable options as domain-local states which are inherited by children domains. With this change, the behavior of concurrent mutation of those state is more specified and it is no longer possible to use those global variables for synchronization purpose.
Another option would be to document the expected policy for updating those variables in #11227.