]> git.tuebingen.mpg.de Git - paraslash.git/commit
afs.c: Introduce client list for afs (fixes dosable bug).
authorAndre Noll <maan@systemlinux.org>
Thu, 4 Oct 2007 14:11:59 +0000 (16:11 +0200)
committerAndre Noll <maan@systemlinux.org>
Thu, 4 Oct 2007 14:11:59 +0000 (16:11 +0200)
commit769888ee3175ed60df3c23caf51cdad5db33d141
tree1d69f1892cd3990b5524ed3e6901146298bd69f1
parentcf1e416e5db97f1673521a63dacaa1487fb875d7
afs.c: Introduce client list for afs (fixes dosable bug).

With the old code, a malicious local user could easily cause a DOS
by connecting to the local afs socket but never sending any data
through that socket. This caused afs to block on the read() from the
new client fd.

This patch fixes this flaw by introducing a doubly liked list of
connected clients.  Each entry in this list contains an open file
descriptor and the time the client connected.

In command_pre_select() we add each fd in the list to the set of
fds to be checked for readability. In command_post_select() we loop
through that list and check each fd again. Whenever the fd for a
client is readable we read from that fd and execute an afs command
if the client sent the valid magic cookie.

However, if the fd is not ready, we close the connection if more than
AFS_CLIENT_TIMEOUT seconds (default: 3) have passed since the client
connected. This hopefully avoids another possible DOS: A malicious
user could try to flood us with connections until the limit of open
fds is reached.
afs.c