Re: [RFC PATCH 0/2] Faster/parallel SYN handling to mitigate SYN floods

Eric Dumazet
2012-05-30T04:45:42Z

On Tue, 2012-05-29 at 22:17 +0200, Jesper Dangaard Brouer wrote:
> On Mon, 2012-05-28 at 18:14 +0200, Christoph Paasch wrote:
>

> > Concerning (1):
> > I think, there are places where you may have troube because you don't
> > hold the lock.
> > E.g., in tcp_make_synack (called by tcp_v4_send_synack from your
> > tcp_v4_syn_conn_limit) there is:
> >
> > if (sk->sk_userlocks & SOCK_RCVBUF_LOCK &&
> > (req->window_clamp > tcp_full_space(sk) ||
> > req->window_clamp == 0))
> > req->window_clamp = tcp_full_space(sk);
> >
> > Thus, tcp_full_space(sk) may have different values between the check and
> > setting req->window_clamp.
>
> This should be simply solved by using a local stack variable, for
> storing the result from tcp_full_space(sk). Its likely that GCC already
> does this behind our back.
>

Thats not the proper way to handle that situation.

A local stack variable makes no such guarantee. You need ACCESS_ONCE().

This is exactly the kind of things that RCU takes care of.