Skip to contentSkip to conversation

tcp: ulp: fix possible crash in tcp_diag_get_aux_size()

PATCH Applied Eric Dumazet 3 participants 4 messages Sep 5, 2019 – Sep 7, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
Cc Davide Caratti <[email protected]>
---
 net/ipv4/tcp_diag.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_diag.c +1 -1
index babc156deabb573f11bba344215d2c3712c4a3cd..81a8221d650a94be53d17354c60ddd0c655eaccf 100644
@@ -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;
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#1 lore raw
Quoted 5 lines · Eric Dumazet

tcp_diag_get_aux_size() can be called with sockets in any state.

icsk_ulp_ops is only present for full sockets.

Quoted 8 lines

For SYN_RECV or TIME_WAIT ones we would access garbage.

Fixes 61723b393292 ("tcp: ulp: add functions to dump ulp-specific information")
Cc Davide Caratti <[email protected]>

---

Sorry for the 'net' tag. This patch targets net-next tree only.

maintainer Applied
#3 lore raw
In reply to Eric Dumazet

From: Eric Dumazet <[email protected]>
Date: Thu, 5 Sep 2019 13:20:41 -0700

Quoted 10 lines

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")

Applied to net-next, thanks Eric.