It should be no checkbox, but a button.
For exact the reason why you're asking, it should be no checkbox. It is no setting, but a trigger for an action, so a widget which triggers actions should be used, which is a button.
If you absolutely need to use a checkbox, then check it and gray-out all the other checkboxes.
Then you still have a difficult choice: Check all the grayed-out checkboxes (visualizing the selection) or do not change them (allow to use the old set of checkmarks when unchecking "select all"). A possible solution may be to check all, gray them out and store the previous configuration. When the user unchecks "select all", you enable them again and restore the previous selection.
If you do not gray them out and use a "select all" checkbox, your next question would be: What happens, if the user disables one of the checkboxes? Should the "select all" checkbox be disabled? Should it stay enabled, even when not all checkboxes are enabled? And how can I then use "select all", when it is still checked, but the configuration below is changed?
So use a button. And consider an additional "uncheck all" button.