lib/tinykvm/linux/system_calls.cpp:1828 (SYS_fcntl, F_SETFL) and
:1133 (SYS_setsockopt).
Both are mutating operations on a host fd, but both resolve the vfd with the
plain translate() rather than translate_writable_vfd(). The neighbouring
F_SETLK64 case at :1855 uses translate_writable_vfd(), which is the
intended idiom for a write path — the local variable at :1828 is even already
named writable_fd.
Consequence worth noting for the fork deployment: forks share the master's
real_fd (fds.cpp:303,331), and reset_to() does not restore file status
flags, so a flag set through this path persists across a reset.
Fix: use translate_writable_vfd() in both places.
Found by an internal audit of the host-side Linux emulation. A fix PR with a
regression test follows.
lib/tinykvm/linux/system_calls.cpp:1828(SYS_fcntl,F_SETFL) and:1133(SYS_setsockopt).Both are mutating operations on a host fd, but both resolve the vfd with the
plain
translate()rather thantranslate_writable_vfd(). The neighbouringF_SETLK64case at :1855 usestranslate_writable_vfd(), which is theintended idiom for a write path — the local variable at :1828 is even already
named
writable_fd.Consequence worth noting for the fork deployment: forks share the master's
real_fd(fds.cpp:303,331), andreset_to()does not restore file statusflags, so a flag set through this path persists across a reset.
Fix: use
translate_writable_vfd()in both places.Found by an internal audit of the host-side Linux emulation. A fix PR with a
regression test follows.