-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
splice
usage may be incorrect if it is possible for the source to be mutated
#116451
Comments
#108283 already reduced the use of splice. Do you have a concrete scenario in mind that I missed? |
@rustbot label +O-linux +T-libs |
Oops, I missed that pull request. Still I suggest reading lkml thread I mention ( https://lore.kernel.org/lkml/[email protected]/ ). It happened after the8472's PR. My understanding of Linus words is so: all uses of splice can cause all kinds of problems, so it should be used only when you fully control your whole data pipeline. So, okay, feel free to close this bug report if you think that the work is already done |
That does not match my understanding because there are multiple scenarios and at least two of them seem safe:
I don't see anything in the thread that directly contradicts this, but, well... people are arguing about a lot of things. See https://lore.kernel.org/lkml/[email protected]/ I do wish Linus had provided a clearer answer on the semantics of SPLICE_F_MOVE. Because I previously believed that all the problematic behavior could only happen when it is set (which Rust never did). The documentation continues to be misleading or confusing:
here it distinguishes between copying and moving and yet further down it says
so I guess there's "moving", "not-really-copying by passing references" and "real copy" and the difference between the first two is never clarified and currently does nothing anyway? 😩 I'd appreciate a SPLICE_F_BYTECOPY flag, just to avoid the userspace copies. |
I would like to see either
I have no problem with us doing whatever Linus says. It's his kernel, after all. But I don't think we should be reading his words like tea leaves. |
I should explain what I mean by reading tea leaves. From that LKML thread, according to him, the documentation is basically wrong:
So I guess the only actual, correct documentation is whatever he just said, which is:
and
This suggests the first case described by the8472 is basically correct usage. But Linus also says:
And Linus acknowledged this suggestion by Matt Whitlock:
This might complicate the second case? It feels pointlessly ambiguous, though. Linus shouldn't nack arbitrary swathes of the documentation and then pretend it's clear what the documentation says. |
splice
usage may be incorrect if it is possible for the source to be mutated
It seems
std::io::copy
sometimes invokessplice
on Linux. Don't do this! Usingsplice
can lead to data corruption (one user reported that his backups was damaged). Also, Linus Torvalds said thatsplice
should not be used as general-purpose copy tool. See details here: systemd/systemd#29044 . There are situations wheresplice
is okay, but it is not good as general-purpose copy mechanism. Use ofsendfile
andcopy_file_range
should be questioned, too. Any other use ofsplice
instd
should be audited, tooRust version: 90f3a6f
The text was updated successfully, but these errors were encountered: