Repository navigation
passthrough: fall back to caller's flags when writeback open promotio… - #263
Merged
jiangliu merged 1 commit intoOct 10, 2026
Merged
Conversation
…n fails With writeback cache enabled, get_writeback_open_flags() promotes O_WRONLY to O_RDWR so the kernel can issue read requests through the handle. For a file the caller may only write (e.g. mode 0o200, where the owner has no read permission) the promoted open fails with EACCES, turning a valid O_WRONLY open or CREATE into a spurious failure: without writeback the kernel would never issue reads on the handle anyway. Retry with the caller's access mode when the promoted open fails with EACCES, keeping the other writeback adjustments (O_APPEND stays cleared): the handle is then genuinely write-only and a kernel READ on it fails with the real error instead. The same fallback covers CREATE, where a mode that denies read access to the owner would otherwise fail the whole creation; if the first attempt already created the file the retry answers EEXIST and the existing-file path opens it with the caller's flags. The fallback is guarded on the access mode actually having been promoted, so an explicit O_RDWR request on a write-only file still fails with EACCES. Ported from PR cloud-hypervisor#220 ("Fix O_WRONLY open for files without read permission"). Co-authored-by: EJ Campbell <ejc3@users.noreply.github.com> Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
jiangliu
requested review from
bergwolf,
eryugey,
imeoer and
liubogithub
as code owners
October 10, 2026 02:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With writeback cache enabled, get_writeback_open_flags() promotes O_WRONLY to O_RDWR so the kernel can issue read requests through the handle. For a file the caller may only write (e.g. mode 0o200, where the owner has no read permission) the promoted open fails with EACCES, turning a valid O_WRONLY open or CREATE into a spurious failure: without writeback the kernel would never issue reads on the handle anyway.
Retry with the caller's access mode when the promoted open fails with EACCES, keeping the other writeback adjustments (O_APPEND stays cleared): the handle is then genuinely write-only and a kernel READ on it fails with the real error instead. The same fallback covers CREATE, where a mode that denies read access to the owner would otherwise fail the whole creation; if the first attempt already created the file the retry answers EEXIST and the existing-file path opens it with the caller's flags.
The fallback is guarded on the access mode actually having been promoted, so an explicit O_RDWR request on a write-only file still fails with EACCES.
Ported from PR #220 ("Fix O_WRONLY open for files without read permission").