Hi Tim,

On  Sa 12 Mai 2018 17:44:54 CEST, Tim Duesterhus wrote:

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.

Would you be willing to propose the above upstream?
https://github.com/tinyproxy/tinyproxy

Help with approaching upstream with above analysis will be highly welcome.

If you are not available for this, please let me know, and I will forward the necessary info.

Thanks,
Mike
--

DAS-NETZWERKTEAM
mike gabriel, herweg 7, 24357 fleckeby
mobile: +49 (1520) 1976 148
landline: +49 (4354) 8390 139

GnuPG Fingerprint: 9BFB AEE8 6C0A A5FF BF22  0782 9AF4 6B30 2577 1B31
mail: mike.gabr...@das-netzwerkteam.de, http://das-netzwerkteam.de

Attachment: pgpaloG7zzT29.pgp
Description: Digitale PGP-Signatur

Reply via email to