tcp: ulp: fix possible crash in tcp_diag_get_aux_size()
Subsystems (3)
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.
--- net/ipv4/tcp_diag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_diag.c +1 -1
@@ -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
Quoted 5 lines · Eric Dumazet
tcp_diag_get_aux_size()can be called with sockets in any state.
icsk_ulp_opsis only present for full sockets.
Quoted 8 lines
For
SYN_RECVorTIME_WAITones we would access garbage.Fixes 61723b393292 ("tcp: ulp: add functions to dump ulp-specific information")Signed-off-by Eric Dumazet <[email protected]>Reported-by Luke Hsiao <[email protected]>Reported-by Neal Cardwell <[email protected]>Cc Davide Caratti <[email protected]>---
Sorry for the 'net' tag. This patch targets net-next tree only.
Quoted 6 lines · Eric Dumazet
tcp_diag_get_aux_size()can be called with sockets in any state.
icsk_ulp_opsis only present for full sockets.For
SYN_RECVorTIME_WAITones we would access garbage.
hello Eric,
thanks for fixing this!
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_opsis only present for full sockets.For
SYN_RECVorTIME_WAITones we would access garbage.Fixes 61723b393292 ("tcp: ulp: add functions to dump ulp-specific information")Signed-off-by Eric Dumazet <[email protected]>Reported-by Luke Hsiao <[email protected]>Reported-by Neal Cardwell <[email protected]>
Applied to net-next, thanks Eric.