diff mbox

[1/1,v2] tcp: Fixed MD5 key lookups when adding/removing MD5.

Message ID 1371209403-28275-1-git-send-email-aydin.arik@alliedtelesis.co.nz
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Aydin Arik June 14, 2013, 11:30 a.m. UTC
MD5 key lookups on a given TCP socket were being performed
incorrectly. This fix alters parameter inputs to the MD5
lookup function tcp_md5_do_lookup, which is called by functions
tcp_md5_do_add and tcp_md5_do_del. Specifically, the change now
inputs the correct address and address family required to make
a proper lookup.

Commit a915da9b69273815527ccb3789421cb7027b545b ("tcp: md5: rcu conversion")
is the source of the regression.

Signed-off-by: Aydin Arik <aydin.arik@alliedtelesis.co.nz>
---
 net/ipv4/tcp_ipv4.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Eric Dumazet June 14, 2013, 12:58 p.m. UTC | #1
On Fri, 2013-06-14 at 23:30 +1200, Aydin Arik wrote:
> MD5 key lookups on a given TCP socket were being performed
> incorrectly. This fix alters parameter inputs to the MD5
> lookup function tcp_md5_do_lookup, which is called by functions
> tcp_md5_do_add and tcp_md5_do_del. Specifically, the change now
> inputs the correct address and address family required to make
> a proper lookup.
> 
> Commit a915da9b69273815527ccb3789421cb7027b545b ("tcp: md5: rcu conversion")
> is the source of the regression.
> 
> Signed-off-by: Aydin Arik <aydin.arik@alliedtelesis.co.nz>
> ---
>  net/ipv4/tcp_ipv4.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> index d09203c..da84cdb 100644
> --- a/net/ipv4/tcp_ipv4.c
> +++ b/net/ipv4/tcp_ipv4.c
> @@ -1005,7 +1005,7 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
>  	struct tcp_sock *tp = tcp_sk(sk);
>  	struct tcp_md5sig_info *md5sig;
>  
> -	key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&addr, AF_INET);
> +	key = tcp_md5_do_lookup(sk, addr, family);
>  	if (key) {
>  		/* Pre-existing entry - just update that one. */
>  		memcpy(key->key, newkey, newkeylen);
> @@ -1050,7 +1050,7 @@ int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, int family)
>  	struct tcp_md5sig_key *key;
>  	struct tcp_md5sig_info *md5sig;
>  
> -	key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&addr, AF_INET);
> +	key = tcp_md5_do_lookup(sk, addr, family);
>  	if (!key)
>  		return -ENOENT;
>  	hlist_del_rcu(&key->node);

Thanks !

Acked-by: Eric Dumazet <edumazet@google.com>

(No need for "[PATCH 1/1] " for a single patch)



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller June 20, 2013, 4:22 a.m. UTC | #2
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 14 Jun 2013 05:58:07 -0700

> On Fri, 2013-06-14 at 23:30 +1200, Aydin Arik wrote:
>> MD5 key lookups on a given TCP socket were being performed
>> incorrectly. This fix alters parameter inputs to the MD5
>> lookup function tcp_md5_do_lookup, which is called by functions
>> tcp_md5_do_add and tcp_md5_do_del. Specifically, the change now
>> inputs the correct address and address family required to make
>> a proper lookup.
>> 
>> Commit a915da9b69273815527ccb3789421cb7027b545b ("tcp: md5: rcu conversion")
>> is the source of the regression.
>> 
>> Signed-off-by: Aydin Arik <aydin.arik@alliedtelesis.co.nz>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index d09203c..da84cdb 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1005,7 +1005,7 @@  int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
 	struct tcp_sock *tp = tcp_sk(sk);
 	struct tcp_md5sig_info *md5sig;
 
-	key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&addr, AF_INET);
+	key = tcp_md5_do_lookup(sk, addr, family);
 	if (key) {
 		/* Pre-existing entry - just update that one. */
 		memcpy(key->key, newkey, newkeylen);
@@ -1050,7 +1050,7 @@  int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, int family)
 	struct tcp_md5sig_key *key;
 	struct tcp_md5sig_info *md5sig;
 
-	key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&addr, AF_INET);
+	key = tcp_md5_do_lookup(sk, addr, family);
 	if (!key)
 		return -ENOENT;
 	hlist_del_rcu(&key->node);