-
Notifications
You must be signed in to change notification settings - Fork 88
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
Virtiofs structs might be allocated with wrong alignment #691
Comments
Hi @mkroening! @scotran and I are part of a Virtualization course at UT Austin, and as part of a project we have to contribute to open source repositories. Can we take up this issue? |
Go for it! :) |
Alignment of the virtiofs struct was previously based on the alignment of the largest field in fuse_in_header/fuse_out_header. Switched to explicitly align on u32, the type of the first field in the header. Fixes hermit-os#691 Signed-off-by: joannejchen <chenjjoanne@gmail.com>
Hi @mrkroening! I created a pull request (#709) with the alignment switched to be based off of the u32 type (the type of the first field in fuse_in_header / fuse_out_header). Are these the changes you intended? |
Alignment of the virtiofs struct was previously based on the alignment of only the first field. Changed to explicitly use the maximum alignment of all of the fields and added assertions to ensure this manually-allocated layout matches the compiler-generated layout. Fixes hermit-os#691 Signed-off-by: joannejchen <chenjjoanne@gmail.com>
Alignment of the virtiofs struct was previously based on the alignment of only the first field. Changed to explicitly use the maximum alignment of all of the fields and added assertions to ensure this manually-allocated layout matches the compiler-generated layout. Fixes hermit-os#691 Signed-off-by: joannejchen <chenjjoanne@gmail.com>
Alignment of the virtiofs struct was previously based on the alignment of only the first field. Changed to explicitly use the maximum alignment of all of the fields and added assertions to ensure this manually-allocated layout matches the compiler-generated layout. Fixes hermit-os#691 Signed-off-by: joannejchen <chenjjoanne@gmail.com>
Alignment of the virtiofs struct was previously based on the alignment of only the first field. Changed to explicitly use the maximum alignment of all of the fields and added assertions to ensure this manually-allocated layout matches the compiler-generated layout. Fixes hermit-os#691 Signed-off-by: joannejchen <chenjjoanne@gmail.com>
Alignment of the virtiofs struct was previously based on the alignment of only the first field. Changed to explicitly use the maximum alignment of all of the fields and added assertions to ensure this manually-allocated layout matches the compiler-generated layout. Fixes hermit-os#691 Signed-off-by: joannejchen <chenjjoanne@gmail.com>
Alignment of the virtiofs struct was previously based on the alignment of only the first field. Changed to explicitly use the maximum alignment of all of the fields and added assertions to ensure this manually-allocated layout matches the compiler-generated layout. Fixes hermit-os#691 Signed-off-by: joannejchen <chenjjoanne@gmail.com>
Thanks for the clarification! I have updated it to pad the layout (and consequently changes the asserts and passing around of the layout as you mentioned), and luckily it doesn't seem to have broken anything! LMK if there's any other issues or fixes! |
709: Change alignment of virtiofs structs to be based on the first field. r=mkroening a=joannejchen Alignment of the virtiofs struct was previously based on the alignment of the largest field in fuse_in_header/fuse_out_header. Switched to explicitly align on u32, the type of the first field in the header. Fixes #691 Co-authored-by: joannejchen <chenjjoanne@gmail.com>
There are places that manually allocate fuse DSTs with this layout:
https://github.com/hermitcore/libhermit-rs/blob/4a9c2c4f4b3df5a335286939e5eff7f7484d331f/src/fs/fuse.rs#L372
where
Cmd
is defined like this:https://github.com/hermitcore/libhermit-rs/blob/4a9c2c4f4b3df5a335286939e5eff7f7484d331f/src/fs/fuse.rs#L291-L297
The layout of the manual allocation has to exactly match the layout returned by
Layout::from_value
of the allocated value (this is something we should add assertions for).Specifically, the alignment might be wrong here for certain fields.
The alignment of a parent struct is not the alignment of the first field as assumed in this code, but the biggest alignment of all fields.
So instead of just the alignment of the first field (
fuse_in_header
in this case), we should request the maximum alignment of all fields.The text was updated successfully, but these errors were encountered: