Skip to content

Cancellation safety #1

@Nugine

Description

@Nugine

Worker::tag_recv accepts &mut [MaybeUninit<u8>] as a data buffer.

pub async fn tag_recv(&self, tag: u64, buf: &mut [MaybeUninit<u8>]) -> usize {
let (_, len) = self.tag_recv_mask(tag, u64::max_value(), buf).await;
len
}

However, a future can be cancelled(dropped) at any time. While the IO operation is still in progress, the data buffer may be used after free. It's an unsoundness issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions