[From nobody Thu Mar 19 22:01:05 2026
Received: (at submit) by bugs.debian.org; 1 Oct 2019 11:39:29 +0000
X-Spam-Checker-Version: SpamAssassin 3.4.2-bugs.debian.org_2005_01_02
 (2018-09-13) on buxtehude.debian.org
X-Spam-Level: 
X-Spam-Status: No, score=-21.7 required=4.0 tests=BAYES_00,DIGITS_LETTERS,
 DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FOURLA,HAS_PACKAGE,
 RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,TXREP,XMAILER_REPORTBUG,
 X_DEBBUGS_CC autolearn=ham autolearn_force=no
 version=3.4.2-bugs.debian.org_2005_01_02
X-Spam-Bayes: score:0.0000 Tokens: new, 58; hammy, 150; neutral, 245; spammy,
 0. spammytokens: hammytokens:0.000-+--H*M:reportbug,
 0.000-+--H*MI:reportbug, 0.000-+--H*x:reportbug,
 0.000-+--H*UA:reportbug, 0.000-+--sysv
Return-path: &lt;dkg@fifthhorseman.net&gt;
Received: from che.mayfirst.org ([162.247.75.118]:40347)
 by buxtehude.debian.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from &lt;dkg@fifthhorseman.net&gt;)
 id 1iFGV7-0006AE-AS
 for submit@bugs.debian.org; Tue, 01 Oct 2019 11:39:29 +0000
DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/simple; 
 d=fifthhorseman.net; i=@fifthhorseman.net; q=dns/txt; 
 s=2019; t=1569929965; h=content-type : mime-version : 
 content-transfer-encoding : from : to : subject : 
 message-id : date : from; 
 bh=66bA3OYbVUeD0tsImw6VS7N/b9eG6YI9+Zy1QO106LE=; 
 b=+pDkyvba9FWvwzwCIn2ZH87vYkw3jl+HTF6cmYxg+CwqgtDGqRxdKRbn
 1iWT1hiIj/TBPQ09QiJx/HsNIyYsAg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fifthhorseman.net; 
 i=@fifthhorseman.net; q=dns/txt; s=2019rsa; t=1569929965; 
 h=content-type : mime-version : content-transfer-encoding 
 : from : to : subject : message-id : date : from; 
 bh=66bA3OYbVUeD0tsImw6VS7N/b9eG6YI9+Zy1QO106LE=; 
 b=vpzWQugrLYlM6e5ssI1LFJybZgOl4cWpgMUmwZ4rvrsg4k9RlysVf0bA
 qdAYSma7/4iIrbLLZjih4SZrEXVaUbVIH0ppAnDq5FoAOpv9VOp06vWmhM
 Y3sh7nw2ZRm6tYYT6vtdtUqhBLZcFMWYSONyQQwfsPDXgavbAx2dO14xSm
 dl99D6K2oITBrSRQvW97k4tmK/eNeb1A3/8Vphzw4/su1ClGOHrHSxjaFG
 3kjVvHDLqCeglM46RhXmc7UzoVvxGBhs3mhYaeSmqe0TtkqWLYRykxVZC0
 zJktWmaoHLkJTKd4BXADKOQO/e83d3Mtl933abT8QeAV/c9MsFJ2dw==
Received: from fifthhorseman.net (ool-6c3a0662.static.optonline.net
 [108.58.6.98])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by che.mayfirst.org (Postfix) with ESMTPSA id 975E4F9A5
 for &lt;submit@bugs.debian.org&gt;; Tue,  1 Oct 2019 07:39:25 -0400 (EDT)
Received: by fifthhorseman.net (Postfix, from userid 1000)
 id EDB9020466; Tue,  1 Oct 2019 13:39:22 +0200 (CEST)
Content-Type: text/plain; charset=&quot;us-ascii&quot;
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: Daniel Kahn Gillmor &lt;dkg@fifthhorseman.net&gt;
To: Debian Bug Tracking System &lt;submit@bugs.debian.org&gt;
Subject: torsocks: nc.openbsd in tight loop when talking to tor via libtorsocks
Message-ID: &lt;156992996292.20038.16150638350008834146.reportbug@alice.fifthhorseman.net&gt;
X-Mailer: reportbug 7.5.3
Date: Tue, 01 Oct 2019 07:39:22 -0400
X-Debbugs-Cc: dkg@fifthhorseman.net
Delivered-To: submit@bugs.debian.org

Package: torsocks
Version: 2.3.0-2+b1
Severity: normal
Control: affects + netcat-openbsd

On my system right now, nc is in a tight loop, burning 100% CPU:

```
0 dkg@alice:~$ strace -p 10348 -T -ttt 2&gt;&amp;1 | head
strace: Process 10348 attached
1569928260.402113 select(4, [3], NULL, NULL, NULL) = 1 (in [3]) &lt;0.000020&gt;
1569928260.402195 recvfrom(3, &quot;&quot;, 10, 0, NULL, NULL) = 0 &lt;0.000015&gt;
1569928260.402300 select(4, [3], NULL, NULL, NULL) = 1 (in [3]) &lt;0.000008&gt;
1569928260.402351 recvfrom(3, &quot;&quot;, 10, 0, NULL, NULL) = 0 &lt;0.000007&gt;
1569928260.402394 select(4, [3], NULL, NULL, NULL) = 1 (in [3]) &lt;0.000007&gt;
1569928260.402436 recvfrom(3, &quot;&quot;, 10, 0, NULL, NULL) = 0 &lt;0.000006&gt;
1569928260.402477 select(4, [3], NULL, NULL, NULL) = 1 (in [3]) &lt;0.000007&gt;
1569928260.402517 recvfrom(3, &quot;&quot;, 10, 0, NULL, NULL) = 0 &lt;0.000006&gt;
1569928260.402558 select(4, [3], NULL, NULL, NULL) = 1 (in [3]) &lt;0.000007&gt;
0 dkg@alice:~$ lsof -p 10348
COMMAND   PID USER   FD   TYPE  DEVICE SIZE/OFF    NODE NAME
nc      10348  dkg  cwd    DIR   254,3    24576  261633 /home/dkg
nc      10348  dkg  rtd    DIR   254,1     4096       2 /
nc      10348  dkg  txt    REG   254,1    43504  135774 /bin/nc.openbsd
nc      10348  dkg  mem    REG   254,1    51696  141113 /lib/x86_64-linux-gnu/libnss_files-2.29.so
nc      10348  dkg  mem    REG   254,1    14592  138268 /lib/x86_64-linux-gnu/libdl-2.29.so
nc      10348  dkg  mem    REG   254,1  1820104  135133 /lib/x86_64-linux-gnu/libc-2.29.so
nc      10348  dkg  mem    REG   254,1    84808  141227 /lib/x86_64-linux-gnu/libresolv-2.29.so
nc      10348  dkg  mem    REG   254,1    96568    5752 /usr/lib/x86_64-linux-gnu/libbsd.so.0.10.0
nc      10348  dkg  mem    REG   254,1    88160  133186 /usr/lib/x86_64-linux-gnu/torsocks/libtorsocks.so.0.0.0
nc      10348  dkg  mem    REG   254,1   165632  131306 /lib/x86_64-linux-gnu/ld-2.29.so
nc      10348  dkg    0r  FIFO    0,12      0t0 8164325 pipe
nc      10348  dkg    1w  FIFO    0,12      0t0 8164326 pipe
nc      10348  dkg    2u   CHR  136,14      0t0      17 /dev/pts/14
nc      10348  dkg    3u  IPv4 8165435      0t0     TCP localhost:48380-&gt;localhost:9050 (CLOSE_WAIT)
0 dkg@alice:~$ 
```

It was invoked as part of an ssh proxycommand:

    torsocks nc jsjr752kjv5evcwv.onion 22

(onion service name is anonymized here)

I tried using ltrace on the same process, but nothing was emitted --
it's doing this loop without crossing any dynamic linker boundaries.

With torsocks-dbgsym and netcat-openbsd-dbgsym installed, and gdb
attached to the process, i see this backtrace:


```
#0  0x00007fb931222187 in __GI___select (nfds=nfds@entry=4, readfds=readfds@entry=0x7fffa2739eb0, writefds=writefds@entry=0x0, exceptfds=exceptfds@entry=0x0, timeout=timeout@entry=0x0)
    at ../sysdeps/unix/sysv/linux/select.c:41
#1  0x00007fb931359623 in wait_on_fd (fd=3) at socks5.c:40
#2  0x00007fb931359838 in recv_data_impl (fd=3, buf=0x7fffa273a070, len=&lt;optimized out&gt;) at socks5.c:69
#3  0x00007fb93135a2b0 in socks5_recv_connect_reply (conn=conn@entry=0x55ca81f32340) at socks5.c:509
#4  0x00007fb931352fca in tsocks_connect_to_tor (conn=conn@entry=0x55ca81f32340) at torsocks.c:500
#5  0x00007fb9313539e1 in tsocks_connect (sockfd=&lt;optimized out&gt;, addr=0x55ca81f32320, addrlen=16) at connect.c:206
#6  0x000055ca80745a7c in connect_with_timeout (ctimeout=&lt;optimized out&gt;, salen=16, sa=0x55ca81f32320, fd=3) at netcat.c:1277
#7  remote_connect (host=0x7fffa273ba37 &quot;jsjr752kjv5evcwv.onion&quot;, port=0x55ca81f321c0 &quot;22&quot;, hints=...) at netcat.c:1203
#8  0x000055ca80743ce0 in main (argc=&lt;optimized out&gt;, argv=&lt;optimized out&gt;) at netcat.c:878
(gdb) 
```

Thanks for maintaining torsocks in debian!

       --dkg

-- System Information:
Debian Release: bullseye/sid
  APT prefers testing-debug
  APT policy: (500, 'testing-debug'), (500, 'testing'), (500, 'stable'), (500, 'oldstable'), (200, 'unstable-debug'), (200, 'unstable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 5.2.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages torsocks depends on:
ii  libc6  2.29-2

Versions of packages torsocks recommends:
ii  tor  0.4.1.6-1

torsocks suggests no packages.

-- no debconf information
]