[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190905202041.138085-1-edumazet@google.com>
Date: Thu, 5 Sep 2019 13:20:41 -0700
From: Eric Dumazet <edumazet@...gle.com>
To: "David S . Miller" <davem@...emloft.net>
Cc: netdev <netdev@...r.kernel.org>,
Eric Dumazet <edumazet@...gle.com>,
Eric Dumazet <eric.dumazet@...il.com>,
Luke Hsiao <lukehsiao@...gle.com>,
Neal Cardwell <ncardwell@...gle.com>,
Davide Caratti <dcaratti@...hat.com>
Subject: [PATCH net] tcp: ulp: fix possible crash in tcp_diag_get_aux_size()
tcp_diag_get_aux_size() can be called with sockets in any state.
icsk_ulp_ops is only present for full sockets.
For SYN_RECV or TIME_WAIT ones we would access garbage.
Fixes: 61723b393292 ("tcp: ulp: add functions to dump ulp-specific information")
Signed-off-by: Eric Dumazet <edumazet@...gle.com>
Reported-by: Luke Hsiao <lukehsiao@...gle.com>
Reported-by: Neal Cardwell <ncardwell@...gle.com>
Cc: Davide Caratti <dcaratti@...hat.com>
---
net/ipv4/tcp_diag.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
index babc156deabb573f11bba344215d2c3712c4a3cd..81a8221d650a94be53d17354c60ddd0c655eaccf 100644
--- a/net/ipv4/tcp_diag.c
+++ b/net/ipv4/tcp_diag.c
@@ -163,7 +163,7 @@ static size_t tcp_diag_get_aux_size(struct sock *sk, bool net_admin)
}
#endif
- if (net_admin) {
+ if (net_admin && sk_fullsock(sk)) {
const struct tcp_ulp_ops *ulp_ops;
ulp_ops = icsk->icsk_ulp_ops;
--
2.23.0.187.g17f5b7556c-goog
Powered by blists - more mailing lists