Package: trickle
Version: 1.07-10
Severity: normal

Dear Maintainer,

At the top of 'trickle's reimplementation of socket() in the file 
trickle-overload.c it has a check that includes 'type == SOCK_STREAM', so that 
only connections of type SOCK_STREAM are eligible for processing.

Some programs open the socket with 'type = SOCK_STREAM | SOCK_CLOEXEC'. The 
`SOCK_CLOEXEC` is a Linux extension (since 2.6.27) that avoids the use of a 
subsequent fcntl() call to set the close-on-exec flag.

Unfortunately 'SOCK_STREAM' is not the same as 'SOCK_STREAM | SOCK_CLOEXEC' so 
the 'trickle' processing will not take place.

You can see the effect with this sample ruby code, where the download is not 
restricted in any way.

cat >test.rb <<x
require 'net/http'

Net::HTTP.get_response(URI.parse("http://download.thinkbroadband.com/50MB.zip";))
x

trickle -s -d 10 ruby test.rb

Running 'strace -e trace=socket ruby test.rb' clearly shows the socket() calls 
with 'SOCK_STREAM | SOCK_CLOEXEC'.

I can't see any #define available in sys/socket.h that can be used to mask out 
the socket type from the extension fields, but 0x4ff  could work (for now). Or 
you could mask out (SOCK_NONBLOCK | SOCK_CLOEXEC) from the type before checking 
that it's SOCK_STREAM. But maybe there's a better way.



-- System Information:
Debian Release: stretch/sid
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)

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

Versions of packages trickle depends on:
ii  libbsd0         0.8.3-1
ii  libc6           2.22-7
ii  libevent-2.0-5  2.0.21-stable-2+b1

trickle recommends no packages.

trickle suggests no packages.

-- no debconf information

Reply via email to