mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
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: 7bbb765b73
("net/tcp: Merge TCP-MD5 inbound callbacks")
Reported-by: Brian Vazquez <brianvv@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Reviewed-by: Dmitry Safonov <dima@arista.com>
Tested-by: Leonard Crestez <cdleonard@gmail.com>
Link: https://lore.kernel.org/r/20220726115743.2759832-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
5a159128fa
commit
e62d2e1103
@ -4459,9 +4459,18 @@ tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb,
|
||||
return SKB_DROP_REASON_TCP_MD5UNEXPECTED;
|
||||
}
|
||||
|
||||
/* check the signature */
|
||||
genhash = tp->af_specific->calc_md5_hash(newhash, hash_expected,
|
||||
NULL, skb);
|
||||
/* Check the signature.
|
||||
* To support dual stack listeners, we need to handle
|
||||
* IPv4-mapped case.
|
||||
*/
|
||||
if (family == AF_INET)
|
||||
genhash = tcp_v4_md5_hash_skb(newhash,
|
||||
hash_expected,
|
||||
NULL, skb);
|
||||
else
|
||||
genhash = tp->af_specific->calc_md5_hash(newhash,
|
||||
hash_expected,
|
||||
NULL, skb);
|
||||
|
||||
if (genhash || memcmp(hash_location, newhash, 16) != 0) {
|
||||
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5FAILURE);
|
||||
|
Loading…
Reference in New Issue
Block a user