diff options
author | Eric Dumazet <edumazet@google.com> | 2015-03-11 21:53:14 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-11 21:55:28 -0400 |
commit | 33cf7c90fe2f97afb1cadaa0cfb782cb9d1b9ee2 (patch) | |
tree | 7a0c80d0b2bb618919d966ce5b827c7eb8f843f6 /net/ipv4/inet_timewait_sock.c | |
parent | 654eff45166c7e89d18fc476325c975768b2e347 (diff) |
net: add real socket cookies
A long standing problem in netlink socket dumps is the use
of kernel socket addresses as cookies.
1) It is a security concern.
2) Sockets can be reused quite quickly, so there is
no guarantee a cookie is used once and identify
a flow.
3) request sock, establish sock, and timewait socks
for a given flow have different cookies.
Part of our effort to bring better TCP statistics requires
to switch to a different allocator.
In this patch, I chose to use a per network namespace 64bit generator,
and to use it only in the case a socket needs to be dumped to netlink.
(This might be refined later if needed)
Note that I tried to carry cookies from request sock, to establish sock,
then timewait sockets.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Eric Salo <salo@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inet_timewait_sock.c')
-rw-r--r-- | net/ipv4/inet_timewait_sock.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index 6d592f8555fb..2bd980526631 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c | |||
@@ -195,6 +195,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int stat | |||
195 | tw->tw_ipv6only = 0; | 195 | tw->tw_ipv6only = 0; |
196 | tw->tw_transparent = inet->transparent; | 196 | tw->tw_transparent = inet->transparent; |
197 | tw->tw_prot = sk->sk_prot_creator; | 197 | tw->tw_prot = sk->sk_prot_creator; |
198 | atomic64_set(&tw->tw_cookie, atomic64_read(&sk->sk_cookie)); | ||
198 | twsk_net_set(tw, hold_net(sock_net(sk))); | 199 | twsk_net_set(tw, hold_net(sock_net(sk))); |
199 | /* | 200 | /* |
200 | * Because we use RCU lookups, we should not set tw_refcnt | 201 | * Because we use RCU lookups, we should not set tw_refcnt |