]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Improve DoS avoidance in RPC stream oriented transports. The TCP transport
authorwpaul <wpaul@FreeBSD.org>
Mon, 18 May 1998 16:12:13 +0000 (16:12 +0000)
committerwpaul <wpaul@FreeBSD.org>
Mon, 18 May 1998 16:12:13 +0000 (16:12 +0000)
commite50ecde61b58719278311e5263d7a7d121e43c33
treecb141f2330f2e5f488adb26943c138910b970379
parent3620341ce9b1059b839e53c1dd529116f970a036
Improve DoS avoidance in RPC stream oriented transports. The TCP transport
uses readtcp() to gather data from the network; readtcp() uses select(),
with a timeout of 35 seconds. The problem with this is that if you
connect to a TCP server, send two bytes of data, then just pause, the
server will remain blocked in readtcp() for up to 35 seconds, which is
sort of a long time. If you keep doing this every 35 seconds, you can
keep the server occupied indefinitely.

To fix this, I modified readtcp() (and its cousin, readunix() in svc_unix.c)
to monitor all service transport handles instead of just the current socket.
This allows the server to keep handling new connections that arrive while
readtcp() is running. This prevents one client from potentially monopolizing
a server.

Also, while I was here, I fixed a bug in the timeout calculations. Someone
attempted to adjust the timeout so that if select() returned EINTR and the
loop was restarted, the timeout would be reduced so that rather than waiting
for another 35 seconds, you could never wait for more than 35 seconds total.
Unfortunately, the calculation was wrong, and the timeout could expire much
sooner than 35 seconds.
lib/libc/rpc/svc_tcp.c
lib/libc/rpc/svc_unix.c