tcp: md5: allow changing MD5 keys in all socket states
Subsystems (3)
PATCH 1/1 tcp: md5: allow changing MD5 keys in all socket states
This essentially reverts commit 721230326891 ("tcp: md5: reject TCP_MD5SIG or TCP_MD5SIG_EXT on established sockets")
Mathieu reported that many vendors BGP implementations can actually switch TCP MD5 on established flows.
Quoting Mathieu :
Here is a list of a few network vendors along with their behavior with respect to TCP MD5:
- Cisco: Allows for password to be changed, but within the hold-down
timer (~180 seconds).
- Juniper: When password is initially set on active connection it will reset, but after that any subsequent password changes no network resets.
- Nokia: No notes on if they flap the tcp connection or not.
- Ericsson/RedBack: Allows for 2 password (old/new) to co-exist until both sides are ok with new passwords.
- Meta-Switch: Expects the password to be set before a connection is attempted, but no further info on whether they reset the TCP connection on a change.
- Avaya: Disable the neighbor, then set password, then re-enable.
- Zebos: Would normally allow the change when socket connected.
We can revert my prior change because commit 9424e2e7ad93 ("tcp: md5: fix potential overestimation of TCP option space") removed the leak of 4 kernel bytes to the wire that was the main reason for my patch.
While doing my investigations, I found a bug when a MD5 key is changed, leading to these commits that stable teams want to consider before backporting this revert :
Commit 6a2febec338d ("tcp: md5: add missing memory barriers in tcp_md5_do_add()/tcp_md5_hash_key()") Commit e6ced831ef11 ("tcp: md5: refine tcp_md5_do_add()/tcp_md5_hash_key() barriers")
--- net/ipv4/tcp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
net/ipv4/tcp.c +1 -4
@@ -3246,10 +3246,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,#ifdef CONFIG_TCP_MD5SIG case TCP_MD5SIG :case TCP_MD5SIG_EXT : -if ((1 << sk->sk_state) & (TCPF_CLOSE |TCPF_LISTEN )) - err = tp->af_specific->md5_parse (sk, optname, optval, optlen); -else - err = -EINVAL ; + err = tp->af_specific->md5_parse (sk, optname, optval, optlen);break ;#endif case TCP_USER_TIMEOUT :
Signature · 1 line
2.27.0.212.ge8ba1cc988-goog
Quoted 24 lines · ----- On Jul 1, 2020, at 9:39 PM, Eric Dumazet [email protected] wrote:
This essentially reverts commit 721230326891 ("tcp: md5: reject
TCP_MD5SIGorTCP_MD5SIG_EXTon established sockets")Mathieu reported that many vendors BGP implementations can actually switch TCP MD5 on established flows.
Quoting Mathieu :
Here is a list of a few network vendors along with their behavior with respect to TCP MD5:- Cisco: Allows for password to be changed, but within the hold-down
timer (~180 seconds).- Juniper: When password is initially set on active connection it will reset, but after that any subsequent password changes no network resets.
- Nokia: No notes on if they flap the tcp connection or not.
- Ericsson/RedBack: Allows for 2 password (old/new) to co-exist until both sides are ok with new passwords.
- Meta-Switch: Expects the password to be set before a connection is attempted, but no further info on whether they reset the TCP connection on a change.
- Avaya: Disable the neighbor, then set password, then re-enable.
- Zebos: Would normally allow the change when socket connected.
Quoted 4 lines
We can revert my prior change because commit
9424e2e7ad93("tcp: md5: fix potential
overestimation of TCP option space") removed the leak of 4 kernel bytes to the wire that was the main reason for my patch.
Hi Eric,
This is excellent news! Thanks for looking into it.
As this revert re-enables all ABI scenarios previously supported, I suspect this means knowing whether transitions of live TCP sockets from no-md5 to enabled-md5 is often used in practice is now irrelevant ?
Thanks,
Mathieu
Quoted 38 lines
While doing my investigations, I found a bug when a MD5 key is changed, leading to these commits that stable teams want to consider before backporting this revert :
Commit
6a2febec338d("tcp: md5: add missing memory barriers in tcp_md5_do_add()/tcp_md5_hash_key()")
Commite6ced831ef11("tcp: md5: refine tcp_md5_do_add()/tcp_md5_hash_key() barriers")Fixes 721230326891 "tcp: md5: reject TCP_MD5SIG or TCP_MD5SIG_EXT onestablished sockets"
Signed-off-by Eric Dumazet <[email protected]>Reported-by Mathieu Desnoyers <[email protected]>---
net/ipv4/tcp.c| 5 +----1 file changed, 1 insertion(+), 4 deletions(-)net/ipv4/tcp.c +0
-0index
c33f7c6aff8eea81d374644cd251bd2b96292651..861fbd84c9cf58af4126c80a27925cd6f70f300d100644net/ipv4/tcp.c +1
-5@@ -3246,10 +3246,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,#ifdef CONFIG_TCP_MD5SIG case TCP_MD5SIG :case TCP_MD5SIG_EXT : -if ((1 << sk->sk_state) & (TCPF_CLOSE |TCPF_LISTEN )) - err = tp->af_specific->md5_parse (sk, optname, optval, optlen); -else - err = -EINVAL ; + err = tp->af_specific->md5_parse (sk, optname, optval, optlen);break ;#endif case TCP_USER_TIMEOUT : --2.27.0.212.ge8ba1cc988-goog
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
Quoted 32 lines · Mathieu Desnoyers
Quoted 24 lines · ----- On Jul 1, 2020, at 9:39 PM, Eric Dumazet [email protected] wrote:
This essentially reverts commit 721230326891 ("tcp: md5: reject
TCP_MD5SIGorTCP_MD5SIG_EXTon established sockets")Mathieu reported that many vendors BGP implementations can actually switch TCP MD5 on established flows.
Quoting Mathieu :
Here is a list of a few network vendors along with their behavior with respect to TCP MD5:- Cisco: Allows for password to be changed, but within the hold-down
timer (~180 seconds).- Juniper: When password is initially set on active connection it will reset, but after that any subsequent password changes no network resets.
- Nokia: No notes on if they flap the tcp connection or not.
- Ericsson/RedBack: Allows for 2 password (old/new) to co-exist until both sides are ok with new passwords.
- Meta-Switch: Expects the password to be set before a connection is attempted, but no further info on whether they reset the TCP connection on a change.
- Avaya: Disable the neighbor, then set password, then re-enable.
- Zebos: Would normally allow the change when socket connected.Quoted 4 lines
We can revert my prior change because commit
9424e2e7ad93("tcp: md5: fix potential
overestimation of TCP option space") removed the leak of 4 kernel bytes to the wire that was the main reason for my patch.
Quoted 7 lines
Hi Eric,
This is excellent news! Thanks for looking into it.
As this revert re-enables all ABI scenarios previously supported, I suspect this means knowing whether transitions of live TCP sockets from no-md5 to enabled-md5 is often used in practice is now irrelevant ?
I can only answer this question for two linux peers. They should behave correctly,
although lack of SACK might cause slowdown in lossy environments.
In any case, we revert to a prior situation, so if anything is broken, we will need more details,
like a packet capture.
Quoted 49 lines
Thanks,
Mathieu
Quoted 37 lines
While doing my investigations, I found a bug when a MD5 key is changed, leading to these commits that stable teams want to consider before backporting this revert :
Commit
6a2febec338d("tcp: md5: add missing memory barriers in tcp_md5_do_add()/tcp_md5_hash_key()")
Commite6ced831ef11("tcp: md5: refine tcp_md5_do_add()/tcp_md5_hash_key() barriers")Fixes 721230326891 "tcp: md5: reject TCP_MD5SIG or TCP_MD5SIG_EXT onestablished sockets"
Signed-off-by Eric Dumazet <[email protected]>Reported-by Mathieu Desnoyers <[email protected]>---
net/ipv4/tcp.c| 5 +----1 file changed, 1 insertion(+), 4 deletions(-)net/ipv4/tcp.c +0
-0index
c33f7c6aff8eea81d374644cd251bd2b96292651..861fbd84c9cf58af4126c80a27925cd6f70f300d100644net/ipv4/tcp.c +1
-5@@ -3246,10 +3246,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,#ifdef CONFIG_TCP_MD5SIG case TCP_MD5SIG :case TCP_MD5SIG_EXT : -if ((1 << sk->sk_state) & (TCPF_CLOSE |TCPF_LISTEN )) - err = tp->af_specific->md5_parse (sk, optname, optval, optlen); -else - err = -EINVAL ; + err = tp->af_specific->md5_parse (sk, optname, optval, optlen);break ;#endif case TCP_USER_TIMEOUT : --Quoted 1 line
2.27.0.212.ge8ba1cc988-goog
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Wed, 1 Jul 2020 18:39:33 -0700
Quoted 31 lines
This essentially reverts commit 721230326891 ("tcp: md5: reject
TCP_MD5SIGorTCP_MD5SIG_EXTon established sockets")Mathieu reported that many vendors BGP implementations can actually switch TCP MD5 on established flows.
Quoting Mathieu :
Here is a list of a few network vendors along with their behavior with respect to TCP MD5:- Cisco: Allows for password to be changed, but within the hold-down
timer (~180 seconds).- Juniper: When password is initially set on active connection it will reset, but after that any subsequent password changes no network resets.
- Nokia: No notes on if they flap the tcp connection or not.
- Ericsson/RedBack: Allows for 2 password (old/new) to co-exist until both sides are ok with new passwords.
- Meta-Switch: Expects the password to be set before a connection is attempted, but no further info on whether they reset the TCP connection on a change.
- Avaya: Disable the neighbor, then set password, then re-enable.
- Zebos: Would normally allow the change when socket connected.We can revert my prior change because commit
9424e2e7ad93("tcp: md5: fix potential overestimation of TCP option space") removed the leak of 4 kernel bytes to the wire that was the main reason for my patch.While doing my investigations, I found a bug when a MD5 key is changed, leading to these commits that stable teams want to consider before backporting this revert :
Quoted 6 lines
Commit
6a2febec338d("tcp: md5: add missing memory barriers in tcp_md5_do_add()/tcp_md5_hash_key()") Commite6ced831ef11("tcp: md5: refine tcp_md5_do_add()/tcp_md5_hash_key() barriers")Fixes 721230326891 "tcp: md5: reject TCP_MD5SIG or TCP_MD5SIG_EXT on established sockets"Signed-off-by Eric Dumazet <[email protected]>Reported-by Mathieu Desnoyers <[email protected]>
Applied and queued up for -stable with those other two commits.
Thanks!