lkml.org 
[lkml]   [1999]   [Mar]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] af_unix fix for a panic a DoS and a memory leak [Re:


On Wed, 3 Mar 1999 kuznet@ms2.inr.ac.ru wrote:

> > + /* Fail if the listen backlog is just full. -arca */
> > + if (other->ack_backlog >= other->max_ack_backlog)
> > + goto out;
> > +
>
> Ough, guys: it is wrong. Let's make it in more liberal way yet,
> f.e.
>
> struct wait_queue *unix_global_ack_queue;
> ....
>
> restart:
> /* Find listening sock */
> other=unix_find_other(sunaddr, addr_len, sk->type, hash, &err);
>
> if (other && other->ack_backlog >= other->max_ack_backlog) {
> if (other->dead || other->state != TCP_LISTEN) {
> unix_unlock(other);
> return -ECONNREFUSED;
> }
>
> unix_unlock(other);
>
> if (nonblock)
> return -EAGAIN;
> sleep_on_interruptible(&unix_global_ack_queue);
> if (signal_pending(current))
> return -ERESTARTSYS;
> goto restart;
> }
>
> /* create new sock for complete connection */
> newsk = unix_create1(NULL, 1);
>
> ....
> and wake_up_interruptible(&unix_global_ack_queue) on all --ack_backlog

OK, that makes sense. Actually I would do the following: have a
sysctl-controllable amount of slack. That is, add atomic_t
pending_dead_SYNs initialized to 0, increase it each time we are
closing the connecting end of not-yet-accepted connection and decrease
each time we return such beast on accept(). Now, do
sleep_on_interruptible() only if pending_dead_SYNs is greater than
dead_SYN_slack.

Check for not-yet-accepted being
unix_peer(sk) && !unix_peer(sk)->dead && !unix_peer(sk)->socket
from the connecting side and unix_peer(skb->sk)->dead on the accepting
one.

> On dgrams the same trick can be used, only using
> sk->receive_queue.qlen instead of ack_backlog and some reasonable bound.
>
> What do you think?

Sounds fine. In your variant: "connect() exceeding the the backlog limit
on listening socket blocks". I propose the following addition "... if the
system-wide limit on closed pending connects is also exceeded". It still
gives the syn-flood protection, but it gives more graceful behaviour.
Comments?
Cheers,
Al


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:50    [W:1.061 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site