Skip to content

vmsplice in yes can lead to errors. #7625

@halyavin

Description

@halyavin

The utility yes uses vmsplice to write data to the pipe. This leads to Linux kernel having links to buffer memory in user space. Once the utility gets a write error to the pipe, it exits and frees the buffer. This means that buffer memory can be reused for other allocations and so can be changed. If there are kernel links to the buffer memory in user space, reading from such kernel buffer will get a wrong result.

One might think that since pipe is closed, there are no kernel links to the buffer memory anymore. Unfortunately, this is not always the case. If another program uses splice to read yes data from the pipe, it can move the kernel link to the other pipe. Now such program can close the pipe from yes first and cause yes to exit, corrupting inflight data in the second pipe which points to the buffer memory in yes program.

This wouldn't happen if the buffer was allocated with mmap outside of memory manager control. Such memory can be unmapped on function exit preventing any chance of it being corrupted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions