Skip to content

fix UB in Daemonize::privileged_action#57

Open
27factorial wants to merge 1 commit intoknsd:masterfrom
27factorial:master
Open

fix UB in Daemonize::privileged_action#57
27factorial wants to merge 1 commit intoknsd:masterfrom
27factorial:master

Conversation

@27factorial
Copy link

Fixes UB in Daemonize::privileged_action by removing the transmute from Daemonize<T> to Daemonize<N>.

Transmuting between Daemonize<T> and Daemonize<N> is not guaranteed to be valid, as the transmute may temporarily put self.privileged_action into an invalid state.

The type layout of Daemonize<T> and Daemonize<N> are also not guaranteed to be equivalent, since the compiler may reorder the fields of different instances of the same generic type according to the Transmutes section of the Rustonomicon.

The solution used is to construct a Daemonize<N> manually and fill in the common fields from self, rather than transmuting and replacing just the privileged_action field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant