Skip to content

Replace AsSliceU8 trait with zerocopy::AsBytes #692

Description

@mkroening

Padding is uninitialized: Glossary - Unsafe Code Guidelines Reference

We do not check for padding, neither is AsSliceU8 unsafe.
zerocopy::AsBytes performs these checks.

Activity

  1. joannejchen commented on Mar 27, 2023

    @joannejchen
    Contributor

    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?

  2. mkroening commented on Mar 27, 2023

    @mkroening
    MemberAuthor

    Sure, do you want to do all three issues?

    PS: To assign @scotran, he has to be a participant of this issue. Just write anything, then I can add him as well.

  3. joannejchen commented on Mar 27, 2023

    @joannejchen
    Contributor

    Yep, all three issues would be great!

  4. joannejchen commented on Apr 20, 2023

    @joannejchen
    Contributor

    Hi @mkroening! I was able to switch the VirtioNetHdr (currently reflected in the pull request created) from implementing AsSliceU8 to deriving AsBytes, but I ran into an issue when trying to change from AsSliceU8 to AsBytes for the Cmd and Rsp structs (https://github.com/hermitcore/libhermit-rs/blob/master/src/fs/fuse.rs#L293): #[derive(AsBytes)] is not supported on types with type parameters. Digging around, there seems to be a workaround (google/zerocopy#10), but this would require using repr(transparent), which then cannot be used alongside repr(C) or repr(packed), which would strip padding and possibly cause alignment issue.

    I just wanted to touch base first as to whether this would be the desired approach, and if so, I can continue looking into how to derive AsBytes for structs with type parameters.

  5. added 7 commits that reference this issue on Apr 20, 2023
    7f09f38
    f046402
    096b8d4
    5934f22
    eb56619
    2b7bb6c
    697de57
  6. mkroening commented on Dec 7, 2023

    @mkroening
    MemberAuthor

    Just as an aside, there is a proposal for DynSized, with a very similar purpose to our AsSliceU8: rust-lang/rfcs#3536

  7. cagatay-y commented on Sep 17, 2024

    @cagatay-y
    Contributor

    AsSliceU8 was removed with #1316. I think we can close this issue.

  8. mkroening commented on Sep 17, 2024

    @mkroening
    MemberAuthor

    Superseded by #1316

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

Metadata

Metadata

Assignees

Labels

soundnessSomething is unsound.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions