Skip to content
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

Do not make a file description blocking while it is still in use #151

Merged
merged 6 commits into from
May 1, 2024

Conversation

DemiMarie
Copy link
Contributor

use_stdio_socket means that stdin and stdout FDs use the same file description, which is certainly the case for socket-based services. Before this change, it was set to false in this case. This would cause the file description to be made blocking while it is still in use, potentially causing deadlocks.

git blame points to commit 0802df7 ("Factor out process_child_io"), but I suspect the actual bug dates back as far as the introduction of socket-based services in 76697e3 ("Working socket-based qrexec").

Fixes: QubesOS/qubes-issues#9169

@DemiMarie
Copy link
Contributor Author

@marmarek can you test this?

Copy link

codecov bot commented Apr 28, 2024

Codecov Report

Attention: Patch coverage is 70.09346% with 32 lines in your changes are missing coverage. Please review.

Project coverage is 77.54%. Comparing base (652b8f5) to head (c2f197c).

Files Patch % Lines
daemon/qrexec-client.c 11.11% 16 Missing ⚠️
libqrexec/exec.c 55.55% 8 Missing ⚠️
agent/qrexec-client-vm.c 58.82% 7 Missing ⚠️
libqrexec/process_io.c 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #151      +/-   ##
==========================================
- Coverage   77.64%   77.54%   -0.11%     
==========================================
  Files          54       54              
  Lines        9412     9435      +23     
==========================================
+ Hits         7308     7316       +8     
- Misses       2104     2119      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@marmarek
Copy link
Member

It doesn't help.

@qubesos-bot
Copy link

qubesos-bot commented Apr 28, 2024

OpenQA test summary

Complete test suite and dependencies: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.2&build=2024043003-4.2&flavor=pull-requests

New failures, excluding unstable

Compared to: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.2&build=2024041501-4.2&flavor=update

Failed tests

36 failures

Fixed failures

Compared to: https://openqa.qubes-os.org/tests/97064#dependencies

19 fixed

Unstable tests

  • system_tests_basic_vm_qrexec_gui

    TC_20_AudioVM_Pulse_debian-12-xfce/test_220_audio_play_pulseaudio (2/5 times with errors)
    • job 94385 AssertionError: too short audio, expected 10s, got 8.26902494331065...
    • job 95164 AssertionError: too short audio, expected 10s, got 9.06335600907029...
    TC_20_AudioVM_Pulse_fedora-39-xfce/test_220_audio_play_pulseaudio (1/5 times with errors)
    • job 94385 AssertionError: too short audio, expected 10s, got 8.97528344671201...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_220_audio_play_pulseaudio (5/5 times with errors)
    • job 94385 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95164 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 96347 AssertionError: only silence detected, no useful audio data
    • job 97080 AssertionError: only silence detected, no useful audio data
    • job 97185 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_221_audio_rec_muted_pulseaudio (2/5 times with errors)
    • job 94385 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95164 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_222_audio_rec_unmuted_pulseaudio (5/5 times with errors)
    • job 94385 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95164 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 96347 AssertionError: only silence detected, no useful audio data
    • job 97080 AssertionError: only silence detected, no useful audio data
    • job 97185 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_223_audio_play_hvm (2/5 times with errors)
    • job 94385 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95164 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_224_audio_rec_muted_hvm (2/5 times with errors)
    • job 94385 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95164 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_225_audio_rec_unmuted_hvm (2/5 times with errors)
    • job 94385 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95164 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_PipeWire_debian-12-xfce/test_226_audio_playback_pipewire (2/5 times with errors)
    • job 94385 AssertionError: too short audio, expected 10s, got 9.34784580498866...
    • job 95164 AssertionError: too short audio, expected 10s, got 9.49097505668934...
  • system_tests_pvgrub_salt_storage

    TC_41_HVMGrub_debian-12-xfce/test_000_standalone_vm (3/5 times with errors)
    • job 96359 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
    • job 97092 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
    • job 97197 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
    TC_41_HVMGrub_debian-12-xfce/test_010_template_based_vm (3/5 times with errors)
    • job 96359 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
    • job 97092 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
    • job 97197 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
  • system_tests_extra

    TC_00_QVCTest_debian-12-xfce/test_010_screenshare (1/5 times with errors)
    • job 94380 ^^^^^^^^^^^^^^^^^^^^^^... AssertionError
    TC_00_QVCTest_fedora-39-xfce/test_010_screenshare (1/5 times with errors)
    • job 94380 ^^^^^^^^^^^^^^^^^^^^^^... AssertionError
    TC_00_QVCTest_whonix-gateway-17/test_010_screenshare (1/5 times with errors)
    • job 94380 AssertionError: 'qubes-video-companion screenshare' exited early (1...
    TC_00_QVCTest_whonix-workstation-17/test_010_screenshare (1/5 times with errors)
    • job 94380 AssertionError: 'qubes-video-companion screenshare' exited early (1...
    TC_00_QVCTest_debian-12-xfce/test_020_webcam (1/5 times with errors)
    • job 94380 ^^^^^^^^^^^^^^^^^^^^^^... AssertionError
    TC_00_QVCTest_fedora-39-xfce/test_020_webcam (1/5 times with errors)
    • job 94380 ~~~~^~~~~~~~~~... ZeroDivisionError: division by zero
    TC_00_QVCTest_whonix-gateway-17/test_020_webcam (1/5 times with errors)
    • job 94380 self.assertIsNone(p.returncode)... AssertionError: 1 is not None
    TC_00_QVCTest_whonix-workstation-17/test_020_webcam (1/5 times with errors)
    • job 94380 self.assertIsNone(p.returncode)... AssertionError: 1 is not None
    TC_00_Appmenus/test_121_create_appvm_with_whitelist (1/5 times with errors)
    • job 94380 '/tmp/tmpb0w885he/test-inst-app/apps/org.qubes-os.qubes-vm-setting...
  • system_tests_usbproxy

    TC_20_USBProxy_core3_debian-12-xfce/test_030_detach (1/5 times with errors)
    • job 95187 AssertionError: 0 == 0 : Device disconnection failed
    TC_20_USBProxy_core3_whonix-gateway-17/test_070_attach_not_installed_front (1/5 times with errors)
    • job 97173 qubesusbproxy.core3ext.QubesUSBException: Device attach failed: 202...
    TC_20_USBProxy_core3_debian-12-xfce/test_090_attach_stubdom (1/5 times with errors)
    • job 97608 AssertionError: 1 != 0 : Device connection failed
    TC_20_USBProxy_core3_fedora-39-xfce/test_090_attach_stubdom (1/5 times with errors)
    • job 97608 AssertionError: 1 != 0 : Device connection failed
  • system_tests_network_ipv6

    VmIPv6Networking_debian-12-xfce/test_031_firewall_dynamic_block (1/5 times with errors)
    • job 97090 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^... AssertionError
    VmIPv6Networking_fedora-39-xfce/test_031_firewall_dynamic_block (2/5 times with errors)
    • job 96357 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^... AssertionError
    • job 97090 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^... AssertionError
  • system_tests_network_updates

    TC_10_QvmTemplate_whonix-gateway-17/test_010_template_install (1/5 times with errors)
    • job 97201 AssertionError: libvirt event impl drain timeout
    TC_11_QvmTemplateMgmtVM_fedora-39-xfce/test_010_template_install (1/5 times with errors)
    • job 96358 AssertionError: libvirt event impl drain timeout
  • system_tests_dispvm

    TC_20_DispVM_fedora-39-xfce/test_100_open_in_dispvm (1/5 times with errors)
    • job 94390 AssertionError: './open-file test.txt' failed with ./open-file test...
  • system_tests_devices

    TC_00_List_debian-12-xfce/test_001_list_loop_mounted (1/5 times with errors)
    • job 96351 AssertionError: Device test-inst-vm:loop0 (/tmp/test.img) should no...
  • system_tests_basic_vm_qrexec_gui_btrfs

    TC_20_AudioVM_Pulse_debian-12-xfce-pool/test_220_audio_play_pulseaudio (2/5 times with errors)
    • job 94386 AssertionError: too short audio, expected 10s, got 9.32555555555555...
    • job 95165 AssertionError: too short audio, expected 10s, got 8.28539682539682...
    TC_20_AudioVM_Pulse_fedora-39-xfce-pool/test_220_audio_play_pulseaudio (2/5 times with errors)
    • job 94386 AssertionError: too short audio, expected 10s, got 9.21634920634920...
    • job 95165 AssertionError: too short audio, expected 10s, got 9.25759637188208...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_220_audio_play_pulseaudio (5/5 times with errors)
    • job 94386 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95165 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 96348 AssertionError: only silence detected, no useful audio data
    • job 97081 AssertionError: only silence detected, no useful audio data
    • job 97186 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_221_audio_rec_muted_pulseaudio (2/5 times with errors)
    • job 94386 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95165 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_222_audio_rec_unmuted_pulseaudio (5/5 times with errors)
    • job 94386 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95165 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 96348 AssertionError: only silence detected, no useful audio data
    • job 97081 AssertionError: only silence detected, no useful audio data
    • job 97186 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_223_audio_play_hvm (2/5 times with errors)
    • job 94386 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95165 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_224_audio_rec_muted_hvm (2/5 times with errors)
    • job 94386 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95165 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_225_audio_rec_unmuted_hvm (2/5 times with errors)
    • job 94386 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95165 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_PipeWire_fedora-39-xfce-pool/test_226_audio_playback_pipewire (1/5 times with errors)
    • job 94386 AssertionError: too short audio, expected 10s, got 7.64335600907029...
  • system_tests_basic_vm_qrexec_gui_xfs

    TC_20_AudioVM_Pulse_debian-12-xfce-pool/test_220_audio_play_pulseaudio (3/5 times with errors)
    • job 94192 AssertionError: too short audio, expected 10s, got 9.48453514739229...
    • job 94388 AssertionError: too short audio, expected 10s, got 9.32911564625850...
    • job 95167 AssertionError: too short audio, expected 10s, got 8.98888888888888...
    TC_20_AudioVM_Pulse_fedora-39-xfce-pool/test_220_audio_play_pulseaudio (2/5 times with errors)
    • job 94192 AssertionError: too short audio, expected 10s, got 9.49594104308390...
    • job 94388 AssertionError: too short audio, expected 10s, got 8.73632653061224...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_220_audio_play_pulseaudio (5/5 times with errors)
    • job 94192 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 94388 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95167 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 97083 AssertionError: only silence detected, no useful audio data
    • job 97188 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_221_audio_rec_muted_pulseaudio (3/5 times with errors)
    • job 94192 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 94388 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95167 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_debian-12-xfce-pool/test_222_audio_rec_unmuted_pulseaudio (2/5 times with errors)
    • job 94388 AssertionError: only silence detected, no useful audio data
    • job 97083 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_222_audio_rec_unmuted_pulseaudio (5/5 times with errors)
    • job 94192 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 94388 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95167 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 97083 AssertionError: only silence detected, no useful audio data
    • job 97188 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_223_audio_play_hvm (3/5 times with errors)
    • job 94192 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 94388 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95167 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_224_audio_rec_muted_hvm (3/5 times with errors)
    • job 94192 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 94388 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95167 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_225_audio_rec_unmuted_hvm (3/5 times with errors)
    • job 94192 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 94388 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95167 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_PipeWire_debian-12-xfce-pool/test_226_audio_playback_pipewire (1/5 times with errors)
    • job 95167 AssertionError: too short audio, expected 10s, got 9.48408163265306...
    TC_20_AudioVM_PipeWire_fedora-39-xfce-pool/test_226_audio_playback_pipewire (2/5 times with errors)
    • job 94388 AssertionError: too short audio, expected 10s, got 9.47580498866213...
    • job 95167 AssertionError: too short audio, expected 10s, got 9.47213151927437...
  • system_tests_basic_vm_qrexec_gui@hw1

    TC_20_AudioVM_Pulse_debian-12-xfce/test_220_audio_play_pulseaudio (2/5 times with errors)
    • job 94385 AssertionError: too short audio, expected 10s, got 8.26902494331065...
    • job 95164 AssertionError: too short audio, expected 10s, got 9.06335600907029...
    TC_20_AudioVM_Pulse_fedora-39-xfce/test_220_audio_play_pulseaudio (1/5 times with errors)
    • job 94385 AssertionError: too short audio, expected 10s, got 8.97528344671201...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_220_audio_play_pulseaudio (5/5 times with errors)
    • job 94385 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95164 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 96347 AssertionError: only silence detected, no useful audio data
    • job 97080 AssertionError: only silence detected, no useful audio data
    • job 97185 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_221_audio_rec_muted_pulseaudio (2/5 times with errors)
    • job 94385 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95164 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_222_audio_rec_unmuted_pulseaudio (5/5 times with errors)
    • job 94385 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95164 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 96347 AssertionError: only silence detected, no useful audio data
    • job 97080 AssertionError: only silence detected, no useful audio data
    • job 97185 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_223_audio_play_hvm (2/5 times with errors)
    • job 94385 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95164 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_224_audio_rec_muted_hvm (2/5 times with errors)
    • job 94385 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95164 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_225_audio_rec_unmuted_hvm (2/5 times with errors)
    • job 94385 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 95164 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_PipeWire_debian-12-xfce/test_226_audio_playback_pipewire (2/5 times with errors)
    • job 94385 AssertionError: too short audio, expected 10s, got 9.34784580498866...
    • job 95164 AssertionError: too short audio, expected 10s, got 9.49097505668934...
  • system_tests_basic_vm_qrexec_gui_ext4

    TC_20_AudioVM_Pulse_debian-12-xfce-pool/test_220_audio_play_pulseaudio (1/5 times with errors)
    • job 95166 AssertionError: too short audio, expected 10s, got 9.13657596371882...
    TC_20_AudioVM_Pulse_fedora-39-xfce-pool/test_220_audio_play_pulseaudio (1/5 times with errors)
    • job 95166 AssertionError: too short audio, expected 10s, got 9.01439909297052...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_220_audio_play_pulseaudio (5/5 times with errors)
    • job 95166 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 96349 AssertionError: only silence detected, no useful audio data
    • job 97082 AssertionError: only silence detected, no useful audio data
    • job 97187 AssertionError: only silence detected, no useful audio data
    • job 97622 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_221_audio_rec_muted_pulseaudio (1/5 times with errors)
    • job 95166 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_222_audio_rec_unmuted_pulseaudio (5/5 times with errors)
    • job 95166 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 96349 AssertionError: only silence detected, no useful audio data
    • job 97082 AssertionError: only silence detected, no useful audio data
    • job 97187 AssertionError: only silence detected, no useful audio data
    • job 97622 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_debian-12-xfce-pool/test_223_audio_play_hvm (1/5 times with errors)
    • job 97622 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_fedora-39-xfce-pool/test_223_audio_play_hvm (1/5 times with errors)
    • job 97622 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_223_audio_play_hvm (1/5 times with errors)
    • job 95166 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_224_audio_rec_muted_hvm (1/5 times with errors)
    • job 95166 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_fedora-39-xfce-pool/test_225_audio_rec_unmuted_hvm (1/5 times with errors)
    • job 97622 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_225_audio_rec_unmuted_hvm (1/5 times with errors)
    • job 95166 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_PipeWire_fedora-39-xfce-pool/test_226_audio_playback_pipewire (1/5 times with errors)
    • job 95166 AssertionError: too short audio, expected 10s, got 9.48775510204081...
  • system_tests_basic_vm_qrexec_gui_zfs

    TC_00_Basic/test_120_start_standalone_with_cdrom_dom0 (1/5 times with errors)
    • job 95180 AssertionError: 1 != 0 : b'Timeout waiting for dom0:loop4 device to...
    TC_20_AudioVM_Pulse_debian-12-xfce-pool/test_220_audio_play_pulseaudio (1/5 times with errors)
    • job 95180 AssertionError: too short audio, expected 10s, got 8.96707482993197...
    TC_20_AudioVM_Pulse_fedora-39-xfce-pool/test_220_audio_play_pulseaudio (1/5 times with errors)
    • job 95180 AssertionError: too short audio, expected 10s, got 8.61614512471655...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_220_audio_play_pulseaudio (5/5 times with errors)
    • job 95180 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 96337 AssertionError: only silence detected, no useful audio data
    • job 97096 AssertionError: only silence detected, no useful audio data
    • job 97175 AssertionError: only silence detected, no useful audio data
    • job 97636 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_221_audio_rec_muted_pulseaudio (1/5 times with errors)
    • job 95180 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_222_audio_rec_unmuted_pulseaudio (5/5 times with errors)
    • job 95180 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    • job 96337 AssertionError: only silence detected, no useful audio data
    • job 97096 AssertionError: only silence detected, no useful audio data
    • job 97175 AssertionError: only silence detected, no useful audio data
    • job 97636 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_debian-12-xfce-pool/test_223_audio_play_hvm (1/5 times with errors)
    • job 97636 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_fedora-39-xfce-pool/test_223_audio_play_hvm (2/5 times with errors)
    • job 95180 AssertionError: frequency 3517.990148595454 not in specified range,...
    • job 97636 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_223_audio_play_hvm (1/5 times with errors)
    • job 95180 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_224_audio_rec_muted_hvm (1/5 times with errors)
    • job 95180 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...
    TC_20_AudioVM_Pulse_fedora-39-xfce-pool/test_225_audio_rec_unmuted_hvm (1/5 times with errors)
    • job 97636 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_225_audio_rec_unmuted_hvm (1/5 times with errors)
    • job 95180 AssertionError: Timeout waiting for pulseaudio start in test-inst-v...

@DemiMarie DemiMarie force-pushed the fix-socket-eof branch 3 times, most recently from c8a4d61 to af79fb5 Compare April 29, 2024 04:13
@DemiMarie DemiMarie requested a review from marmarek April 29, 2024 04:13
@DemiMarie
Copy link
Contributor Author

To avoid breaking on musl libc and to ensure correct behavior if close_range() isn’t supported, I decided to use a loop over /proc/self/fd as the fallback. It was not hard to write.

If the file descriptor numbers were bad, a dup2() could clobber a file
descriptor that gets used later.
@DemiMarie DemiMarie force-pushed the fix-socket-eof branch 2 times, most recently from 10df2e5 to b5a027a Compare April 30, 2024 00:00
@DemiMarie DemiMarie requested a review from marmarek April 30, 2024 00:50
This is both more correct (it avoids assuming an arbitrary maximum file
descriptor value) and faster.  If close_range() is not supported by the
kernel or libc, fall back to the old code.
The status pipe was closed by fix_fds(), so all of the subsequent
operations on it were operating on a closed file descriptor.  If
exec_func() returned, the subsequent write() would operate on a file
descriptor that might have been reused for another purpose, but none of
the registered execution functions ever returned.  Just call abort() if
they do return.
There is no need for stdin_fd and stdout_fd to be distinct file
descriptors, so long as the code is careful to not close a file
descriptor that is still in use.  This extra care allows for close() to
be used in preference to shutdown(), unless the same socket is being
used for both stdin and stdout.  close() has the advantage that it does
not interfere with other users of the same file description, which
allows the "was this inherited from another process?" hack to be
eliminated.  Instead, use the file descriptor number to determine
whether blocking mode needs to be restored - it only needs to be
restored for inherited file descriptors.

To avoid lots of error-prone boilerplate, use a single function to close
stdin_fd or stdout_fd, and wrap it with macros that select the right one
to use.  These macros also pass the correct argument for shutdown(2) and
set the just-closed FD to -1, eliminating a nasty potential source of
bugs.  The function automatically chooses between close(2) and
shutdown(2) based on whether the two file descriptor arguments it is
passed are identical, ensuring that shutdown(2) is only used if needed.
Furthermore, the function knows (based on the file descriptor number) if
the file descriptor was inherited from another process, and therefore
whether it needs to be restored to blocking mode.

This also avoids making a file descriptor blocking while still in use.
Since the code now knows if stdin and stdout use the same file
descriptor, it can avoid setting the blocking flag on a file descriptor
that is still in use, which could cause a deadlock.  This works in every
case except where both stdin and stdout are passed from a parent process
and share a file description.

git blame points to commit 0802df7
("Factor out process_child_io"), but I suspect the actual bug dates back
as far as the introduction of socket-based services in
76697e3 ("Working socket-based qrexec").
They make sense for local processes, but for remote processes, stdin_fd
and stdout_fd are backwards, and stderr_fd is -1.
It is critical that EOF from the service gets propagated to
the stdout of qrexec-client-vm or qrexec-client.  Otherwise, the caller
will not recognize that EOF has happened and may wait forever for data
that will never arrive.  In QubesOS/qubes-issues#9169, this caused curl
to hang when reading a plaintext HTTP/1.0 response from tinyproxy, which
relies on EOF to delimit the response.

The bug will trigger iff all of the following conditions are met:

1. The remote side must close the writing side of the connection, either
   by closing or shutting down a socket.
2. If the remote service is executable, it must _not_ exit.
3. qrexec-client-vm or qrexec-client must _not_ get EOF on stdin.
4. Either the remote side does not close its stdin, or the local side
   does not continue to write data.
5. The same file description is used for both stdin and stdout of the
   local qrexec-client or qrexec-client-vm process.
6. qrexec-client or qrexec-client-vm connect the stdin and stdout of the
   remote process to their own stdin and stdout, not the stdin and
   stdout of a locally spawned command.

To fix this bug, add flags to qrexec-client and qrexec-client-vm that
cause the socket passed as file descriptor 0 to be used for both stdin
and stdout.

Fixes: QubesOS/qubes-issues#9169
@marmarek marmarek merged commit 4c24dfe into QubesOS:main May 1, 2024
2 of 4 checks passed
@DemiMarie DemiMarie deleted the fix-socket-eof branch May 1, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using TCP qrexec for updates proxy hangs on EOF
3 participants