Package: tinyproxy
Version: 1.8.4-2
Severity: important
Tags: upstream ipv6

Dear Maintainer,

I specified two "Listen" directives in my tinyproxy.conf:

  Listen 0.0.0.0
  Listen ::

tinyproxy fails to properly handle those: If the first few requests
arrive at the IPv4 listen the IPv6 listen fails and vice versa.

This can easily be verified using strace. Directly after start tinyproxy
select(2)s between FD 0 and FD 1:

  [pid 11352] select(2, [0 1], NULL, NULL, NULL <unfinished ...>
  [pid 11351] select(2, [0 1], NULL, NULL, NULL <unfinished ...>
  [pid 11350] select(2, [0 1], NULL, NULL, NULL <unfinished ...>
  [pid 11349] select(2, [0 1], NULL, NULL, NULL <unfinished ...>
  [pid 11348] select(2, [0 1], NULL, NULL, NULL <unfinished ...>
  [pid 11347] select(2, [0 1], NULL, NULL, NULL <unfinished ...>
  [pid 11346] select(2, [0 1], NULL, NULL, NULL <unfinished ...>
  [pid 11345] select(2, [0 1], NULL, NULL, NULL <unfinished ...>
  [pid 11344] select(2, [0 1], NULL, NULL, NULL <unfinished ...>
  [pid 11343] select(2, [0 1], NULL, NULL, NULL <unfinished ...>

Once requests arrived tinyproxy either hangs in accept(2), because
multiple children are being woken up, but only one can actually accept(2).
Or they are in the select(2), but only select on FD 0:

  [pid 11352] select(2, [0], NULL, NULL, NULL <unfinished ...>
  [pid 11351] select(2, [0], NULL, NULL, NULL <unfinished ...>
  [pid 11350] accept(0,  <unfinished ...>
  [pid 11349] accept(0,  <unfinished ...>
  [pid 11348] accept(0,  <unfinished ...>
  [pid 11347] accept(0,  <unfinished ...>
  [pid 11346] accept(0,  <unfinished ...>
  [pid 11345] accept(0,  <unfinished ...>
  [pid 11344] accept(0,  <unfinished ...>
  [pid 11343] accept(0,  <unfinished ...>

The issue with missing FD 1 in select(2) is, because tinyproxy does not reset
rfds after the select: 
https://anonscm.debian.org/git/collab-maint/tinyproxy.git/tree/src/child.c#n234

If I am lucky I can achieve that a few children select on FD 0 and FD 1, but
this is not reliable.

Tinyproxy should be fixed like this:
- Ensure that rfds is being reset after the select to ensure it selects on all
  sockets.
- The accept race of the children should be prevented, to prevent the children
  from hanging in the accept(2) for a single socket.

-- System Information:
Debian Release: 9.4
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-6-amd64 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_US.UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set 
to en_US.UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages tinyproxy depends on:
ii  init-system-helpers  1.48
ii  libc6                2.24-11+deb9u3
ii  logrotate            3.11.0-0.1
ii  lsb-base             9.20161125

tinyproxy recommends no packages.

tinyproxy suggests no packages.

-- Configuration Files:
/etc/logrotate.d/tinyproxy changed [not included]
/etc/tinyproxy/tinyproxy.conf changed [not included]

-- no debconf information

Reply via email to