fix(tty): preserve raw flags across termios ABI conversions - #2267
Open
fslongjin wants to merge 1 commit into
Open
fix(tty): preserve raw flags across termios ABI conversions#2267fslongjin wants to merge 1 commit into
fslongjin wants to merge 1 commit into
Conversation
TCSETS and the legacy TCSETA family discard flag bits that are not named in the kernel bitflags definitions. This differs from Linux 6.6, which copies the raw flag words and preserves the upper 16 bits when merging legacy termio settings. Preserve all four raw flag words at both ABI conversion boundaries while leaving hardware normalization to the existing driver callbacks. Keep legacy control-character merging and baud-rate extraction unchanged. Use bitflags difference() when restoring old hardware settings after an unsupported driver callback. Unlike the bitflags complement operator, it preserves unnamed bits outside the software-controlled mask, matching tty_termios_copy_hw(). Extend the existing dunitest suite to cover all six set commands, raw flag preservation, legacy control-character tails, input flush behavior, EFAULT without state changes, the 18-byte page-boundary termio ABI and zeroed padding, and console stdin settings. Validation: - Reproduced raw flag loss before the fix: 25 of 26 tty_termios tests passed, with only the new flag-preservation case failing. - After the fix, QEMU x86_64 passed tty_termios (26), tty_tcflush (6), tty_pty_hangup (36), and the existing C termios smoke test. - Verified TCSAFLUSH and legacy settings on ttyS0 stdin, plus a successful apt install of a local test package without the TCSAFLUSH error. - All five added tests passed on host Linux with a PTY. - Kernel build, Rust formatting and whitespace checks passed. Signed-off-by: longjin <[email protected]>
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Summary
TTY attribute setters silently discard flag bits absent from the kernel bitflags definitions. For example, a raw TCSETS request containing 0x80000000 loses that bit on readback, and legacy TCSETA updates cannot preserve it. Linux 6.6 copies the raw flag words and preserves the upper 16 bits when merging legacy settings.
Preserve raw bits in both termios ABI conversions and use
difference()when inheriting old hardware settings, so bitflags complement semantics do not truncate them again. Existing driver normalization, baud-rate handling, locking, and flush/drain ordering remain intact.Extend the existing dunitest suite with coverage for all six setters, legacy control-character preservation, flush versus non-flush behavior, EFAULT without attribute/input changes, page-boundary termio access and zeroed padding, and console stdin settings.
Validation
Related: #1906. The original missing-ioctl support was implemented by #2141; this change fixes the remaining raw-flag preservation gap.