kernel/net: honour the window scale factor advertised by the peer #619
Dismiss Review
Are you sure you want to dismiss this review?
Labels
Clear labels
Influence/Text/TYPO
AI
Eolite
FS
GSoC
Good First PR
HLL
HardwareTested
IRCC
Influence/Settings
Lang/C
Lang/FASM
Pay for the code
Subsystem/API
Subsystem/Audio
Subsystem/Graphics
Subsystem/IPC and events
Subsystem/Memory
Subsystem/Network
Subsystem/Services(daemon)
Subsystem/Taskmanager
Subsystem/VFS
Subsystem/Window
This issue or PR in the Google Source of Code program
The issue is suitable to beginners
Paid task
infinity service, audio drivers, midi, speacker, audio programs
vesa, vga, framebuffer, cursors, blitter, and video drivers
pipes, signals, events, shared memory
virt and phys memory allocators, malloc and other
userspace and kernel(for example: serial) services
process, threads, run apps, scheduler
drivers from filesystem, fs api, blkdev, programs that work with the file system
windows, skins, buttons, mouse and keyboard code for windows (not the base code)
Category
Applications
Category
Drivers
Category
General
Category
Kernel
Category
Libraries
Kind
Breaking
Breaking change that won't be backward compatible
Kind
Bug
Something is not working
Kind
Build
Kind
Documentation
Documentation changes
Kind
Enhancement
Improve existing functionality
Kind
Feature
New functionality
Kind
Security
This is security issue
Kind
Testing
Issue or pull request related to testing
PR
Ready to merge
Pull request is ready for merge
PR
Conflicts
PR conflicts with main
PR
Dependent
This PR is dependent on another PR
PR
Request changes
Changes requested in pull request
PR
Review required
Priority
Critical
1
The priority is critical
Priority
High
2
The priority is high
Priority
Medium
3
The priority is medium
Priority
Low
4
The priority is low
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: KolibriOS/kolibrios#619
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary: the received window scale option was stored into SND_SCALE, which
the connection setup code then immediately overwrote with zero, so every
peer window was interpreted unscaled.
Details:
RFC 1323 negotiation is completed in two places -- the SYN_RECEIVED branch
and the active-open branch of tcp_input. Both do
relying on the declared order of the four adjacent bytes SND_SCALE,
RCV_SCALE, requested_s_scale, request_r_scale to move both factors at once.
requested_s_scale, however, was never filled in: the option parser wrote the
peer's shift count into SND_SCALE directly, and that value was then clobbered
by the word move with the zero left in requested_s_scale by socket_alloc.
The result was that SND_SCALE ended up 0 on every connection while
TF_RCVD_SCALE was set, so a peer advertising, say, 64 KiB with a shift of 7
was read as advertising 512 bytes. Sending to any modern host was throttled
to a fraction of the real window.
The parser now stores into requested_s_scale, where the setup code expects
it, and clamps the value to TCP_max_winshift (14) as required by RFC 1323 --
a peer sending a larger shift must not be allowed to make our SND_WND
computation shift out of range.
Co-Authored-By: Claude Opus 5 noreply@anthropic.com
Good find, proper solution.
Summary: the received window scale option was stored into SND_SCALE, which the connection setup code then immediately overwrote with zero, so every peer window was interpreted unscaled. Подробно: RFC 1323 negotiation is completed in two places -- the SYN_RECEIVED branch and the active-open branch of tcp_input. Both do mov ax, word[ebx + TCP_SOCKET.requested_s_scale] mov word[ebx + TCP_SOCKET.SND_SCALE], ax relying on the declared order of the four adjacent bytes SND_SCALE, RCV_SCALE, requested_s_scale, request_r_scale to move both factors at once. requested_s_scale, however, was never filled in: the option parser wrote the peer's shift count into SND_SCALE directly, and that value was then clobbered by the word move with the zero left in requested_s_scale by socket_alloc. The result was that SND_SCALE ended up 0 on every connection while TF_RCVD_SCALE was set, so a peer advertising, say, 64 KiB with a shift of 7 was read as advertising 512 bytes. Sending to any modern host was throttled to a fraction of the real window. The parser now stores into requested_s_scale, where the setup code expects it, and clamps the value to TCP_max_winshift (14) as required by RFC 1323 -- a peer sending a larger shift must not be allowed to make our SND_WND computation shift out of range. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>da046a79cato8d33c6fa37