public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tcp: ipv4: Pass lockdep expression to RCU lists
@ 2020-02-21 15:21 Amol Grover
  2020-02-21 16:19 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Amol Grover @ 2020-02-21 15:21 UTC (permalink / raw)
  To: Eric Dumazet, David S . Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Jakub Kicinski
  Cc: linux-kernel, linux-kernel-mentees, Joel Fernandes,
	Madhuparna Bhowmik, Paul E . McKenney, Amol Grover

md5sig->head maybe traversed using hlist_for_each_entry_rcu
outside an RCU read-side critical section but under the protection
of socket lock.

Hence, add corresponding lockdep expression to silence false-positive
warnings, and harden RCU lists.

Signed-off-by: Amol Grover <frextrite@gmail.com>
---
 net/ipv4/tcp_ipv4.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 1c7326e04f9b..6519429f32cd 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1000,7 +1000,8 @@ struct tcp_md5sig_key *__tcp_md5_do_lookup(const struct sock *sk,
 	if (!md5sig)
 		return NULL;
 
-	hlist_for_each_entry_rcu(key, &md5sig->head, node) {
+	hlist_for_each_entry_rcu(key, &md5sig->head, node,
+				 lockdep_sock_is_held(sk)) {
 		if (key->family != family)
 			continue;
 
@@ -1043,7 +1044,8 @@ static struct tcp_md5sig_key *tcp_md5_do_lookup_exact(const struct sock *sk,
 	if (family == AF_INET6)
 		size = sizeof(struct in6_addr);
 #endif
-	hlist_for_each_entry_rcu(key, &md5sig->head, node) {
+	hlist_for_each_entry_rcu(key, &md5sig->head, node,
+				 lockdep_sock_is_held(sk)) {
 		if (key->family != family)
 			continue;
 		if (!memcmp(&key->addr, addr, size) &&
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] tcp: ipv4: Pass lockdep expression to RCU lists
@ 2020-02-21 17:57 Amol Grover
  2020-02-24 21:07 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Amol Grover @ 2020-02-21 17:57 UTC (permalink / raw)
  To: Eric Dumazet, David S . Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Jakub Kicinski
  Cc: linux-kernel, linux-kernel-mentees, Joel Fernandes,
	Madhuparna Bhowmik, Paul E . McKenney, netdev, Amol Grover

md5sig->head maybe traversed using hlist_for_each_entry_rcu
outside an RCU read-side critical section but under the protection
of socket lock.

Hence, add corresponding lockdep expression to silence false-positive
warnings, and harden RCU lists.

Signed-off-by: Amol Grover <frextrite@gmail.com>
---
 net/ipv4/tcp_ipv4.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 1c7326e04f9b..6519429f32cd 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1000,7 +1000,8 @@ struct tcp_md5sig_key *__tcp_md5_do_lookup(const struct sock *sk,
 	if (!md5sig)
 		return NULL;
 
-	hlist_for_each_entry_rcu(key, &md5sig->head, node) {
+	hlist_for_each_entry_rcu(key, &md5sig->head, node,
+				 lockdep_sock_is_held(sk)) {
 		if (key->family != family)
 			continue;
 
@@ -1043,7 +1044,8 @@ static struct tcp_md5sig_key *tcp_md5_do_lookup_exact(const struct sock *sk,
 	if (family == AF_INET6)
 		size = sizeof(struct in6_addr);
 #endif
-	hlist_for_each_entry_rcu(key, &md5sig->head, node) {
+	hlist_for_each_entry_rcu(key, &md5sig->head, node,
+				 lockdep_sock_is_held(sk)) {
 		if (key->family != family)
 			continue;
 		if (!memcmp(&key->addr, addr, size) &&
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-02-24 21:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-21 15:21 [PATCH] tcp: ipv4: Pass lockdep expression to RCU lists Amol Grover
2020-02-21 16:19 ` David Miller
2020-02-21 18:05   ` Amol Grover
  -- strict thread matches above, loose matches on Subject: below --
2020-02-21 17:57 Amol Grover
2020-02-24 21:07 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox