Skip to content

Commit e62d2e1

Browse files
edumazetkuba-moo
authored andcommitted
tcp: md5: fix IPv4-mapped support
After the blamed commit, IPv4 SYN packets handled by a dual stack IPv6 socket are dropped, even if perfectly valid. $ nstat | grep MD5 TcpExtTCPMD5Failure 5 0.0 For a dual stack listener, an incoming IPv4 SYN packet would call tcp_inbound_md5_hash() with @family == AF_INET, while tp->af_specific is pointing to tcp_sock_ipv6_specific. Only later when an IPv4-mapped child is created, tp->af_specific is changed to tcp_sock_ipv6_mapped_specific. Fixes: 7bbb765 ("net/tcp: Merge TCP-MD5 inbound callbacks") Reported-by: Brian Vazquez <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: David Ahern <[email protected]> Reviewed-by: Dmitry Safonov <[email protected]> Tested-by: Leonard Crestez <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5a15912 commit e62d2e1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

net/ipv4/tcp.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4459,9 +4459,18 @@ tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb,
44594459
return SKB_DROP_REASON_TCP_MD5UNEXPECTED;
44604460
}
44614461

4462-
/* check the signature */
4463-
genhash = tp->af_specific->calc_md5_hash(newhash, hash_expected,
4464-
NULL, skb);
4462+
/* Check the signature.
4463+
* To support dual stack listeners, we need to handle
4464+
* IPv4-mapped case.
4465+
*/
4466+
if (family == AF_INET)
4467+
genhash = tcp_v4_md5_hash_skb(newhash,
4468+
hash_expected,
4469+
NULL, skb);
4470+
else
4471+
genhash = tp->af_specific->calc_md5_hash(newhash,
4472+
hash_expected,
4473+
NULL, skb);
44654474

44664475
if (genhash || memcmp(hash_location, newhash, 16) != 0) {
44674476
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5FAILURE);

0 commit comments

Comments
 (0)