diff mbox series

[net-next] tcp: md5: Handle RCU dereference of md5sig_info

Message ID 20171221182910.4785-2-mathew.j.martineau@linux.intel.com
State Accepted, archived
Delegated to: David Miller
Headers show
Series [net-next] tcp: md5: Handle RCU dereference of md5sig_info | expand

Commit Message

Mat Martineau Dec. 21, 2017, 6:29 p.m. UTC
Dereference tp->md5sig_info in tcp_v4_destroy_sock() the same way it is
done in the adjacent call to tcp_clear_md5_list().

Resolves this sparse warning:

net/ipv4/tcp_ipv4.c:1914:17: warning: incorrect type in argument 1 (different address spaces)
net/ipv4/tcp_ipv4.c:1914:17:    expected struct callback_head *head
net/ipv4/tcp_ipv4.c:1914:17:    got struct callback_head [noderef] <asn:4>*<noident>

Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
 net/ipv4/tcp_ipv4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christoph Paasch Dec. 21, 2017, 10:13 p.m. UTC | #1
On Thu, Dec 21, 2017 at 10:29 AM, Mat Martineau
<mathew.j.martineau@linux.intel.com> wrote:
> Dereference tp->md5sig_info in tcp_v4_destroy_sock() the same way it is
> done in the adjacent call to tcp_clear_md5_list().
>
> Resolves this sparse warning:
>
> net/ipv4/tcp_ipv4.c:1914:17: warning: incorrect type in argument 1 (different address spaces)
> net/ipv4/tcp_ipv4.c:1914:17:    expected struct callback_head *head
> net/ipv4/tcp_ipv4.c:1914:17:    got struct callback_head [noderef] <asn:4>*<noident>
>
> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
> ---
>  net/ipv4/tcp_ipv4.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> index dd945b114215..5d203248123e 100644
> --- a/net/ipv4/tcp_ipv4.c
> +++ b/net/ipv4/tcp_ipv4.c
> @@ -1911,7 +1911,7 @@ void tcp_v4_destroy_sock(struct sock *sk)
>         /* Clean up the MD5 key list, if any */
>         if (tp->md5sig_info) {
>                 tcp_clear_md5_list(sk);
> -               kfree_rcu(tp->md5sig_info, rcu);
> +               kfree_rcu(rcu_dereference_protected(tp->md5sig_info, 1), rcu);

Acked-by: Christoph Paasch <cpaasch@apple.com>
David Miller Dec. 26, 2017, 10:24 p.m. UTC | #2
From: Mat Martineau <mathew.j.martineau@linux.intel.com>
Date: Thu, 21 Dec 2017 10:29:10 -0800

> Dereference tp->md5sig_info in tcp_v4_destroy_sock() the same way it is
> done in the adjacent call to tcp_clear_md5_list().
> 
> Resolves this sparse warning:
> 
> net/ipv4/tcp_ipv4.c:1914:17: warning: incorrect type in argument 1 (different address spaces)
> net/ipv4/tcp_ipv4.c:1914:17:    expected struct callback_head *head
> net/ipv4/tcp_ipv4.c:1914:17:    got struct callback_head [noderef] <asn:4>*<noident>
> 
> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>

Applied.
diff mbox series

Patch

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index dd945b114215..5d203248123e 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1911,7 +1911,7 @@  void tcp_v4_destroy_sock(struct sock *sk)
 	/* Clean up the MD5 key list, if any */
 	if (tp->md5sig_info) {
 		tcp_clear_md5_list(sk);
-		kfree_rcu(tp->md5sig_info, rcu);
+		kfree_rcu(rcu_dereference_protected(tp->md5sig_info, 1), rcu);
 		tp->md5sig_info = NULL;
 	}
 #endif