diff options
author | Eric Dumazet <edumazet@google.com> | 2015-04-16 21:10:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-04-17 13:28:31 -0400 |
commit | 521f1cf1dbb9d5ad858dca5dc75d1b45f64b6589 (patch) | |
tree | 2c6276958f5d7348616d887f4a64f5b78ec6b9ef /net/ipv4/tcp_illinois.c | |
parent | fad9dfefea6405039491e7e4fc21fb6e59e7d26c (diff) |
inet_diag: fix access to tcp cc information
Two different problems are fixed here :
1) inet_sk_diag_fill() might be called without socket lock held.
icsk->icsk_ca_ops can change under us and module be unloaded.
-> Access to freed memory.
Fix this using rcu_read_lock() to prevent module unload.
2) Some TCP Congestion Control modules provide information
but again this is not safe against icsk->icsk_ca_ops
change and nla_put() errors were ignored. Some sockets
could not get the additional info if skb was almost full.
Fix this by returning a status from get_info() handlers and
using rcu protection as well.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_illinois.c')
-rw-r--r-- | net/ipv4/tcp_illinois.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c index 1d5a30a90adf..67476f085e48 100644 --- a/net/ipv4/tcp_illinois.c +++ b/net/ipv4/tcp_illinois.c | |||
@@ -300,8 +300,7 @@ static u32 tcp_illinois_ssthresh(struct sock *sk) | |||
300 | } | 300 | } |
301 | 301 | ||
302 | /* Extract info for Tcp socket info provided via netlink. */ | 302 | /* Extract info for Tcp socket info provided via netlink. */ |
303 | static void tcp_illinois_info(struct sock *sk, u32 ext, | 303 | static int tcp_illinois_info(struct sock *sk, u32 ext, struct sk_buff *skb) |
304 | struct sk_buff *skb) | ||
305 | { | 304 | { |
306 | const struct illinois *ca = inet_csk_ca(sk); | 305 | const struct illinois *ca = inet_csk_ca(sk); |
307 | 306 | ||
@@ -318,8 +317,9 @@ static void tcp_illinois_info(struct sock *sk, u32 ext, | |||
318 | do_div(t, info.tcpv_rttcnt); | 317 | do_div(t, info.tcpv_rttcnt); |
319 | info.tcpv_rtt = t; | 318 | info.tcpv_rtt = t; |
320 | } | 319 | } |
321 | nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); | 320 | return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); |
322 | } | 321 | } |
322 | return 0; | ||
323 | } | 323 | } |
324 | 324 | ||
325 | static struct tcp_congestion_ops tcp_illinois __read_mostly = { | 325 | static struct tcp_congestion_ops tcp_illinois __read_mostly = { |