Skip to content

Commit cee4034

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: fix lockdep false positive in mptcp_pm_nl_create_listen_socket()
Christoph reports a lockdep splat in the mptcp_subflow_create_socket() error path, when such function is invoked by mptcp_pm_nl_create_listen_socket(). Such code path acquires two separates, nested socket lock, with the internal lock operation lacking the "nested" annotation. Adding that in sock_release() for mptcp's sake only could be confusing. Instead just add a new lockclass to the in-kernel msk socket, re-initializing the lockdep infra after the socket creation. Fixes: ad21710 ("mptcp: fix locking for in-kernel listener creation") Cc: stable@vger.kernel.org Reported-by: Christoph Paasch <cpaasch@apple.com> Closes: multipath-tcp/mptcp_net-next#354 Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net> Tested-by: Christoph Paasch <cpaasch@apple.com> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 3ba1452 commit cee4034

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

net/mptcp/pm_netlink.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,9 +997,13 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
997997
return ret;
998998
}
999999

1000+
static struct lock_class_key mptcp_slock_keys[2];
1001+
static struct lock_class_key mptcp_keys[2];
1002+
10001003
static int mptcp_pm_nl_create_listen_socket(struct sock *sk,
10011004
struct mptcp_pm_addr_entry *entry)
10021005
{
1006+
bool is_ipv6 = sk->sk_family == AF_INET6;
10031007
int addrlen = sizeof(struct sockaddr_in);
10041008
struct sockaddr_storage addr;
10051009
struct socket *ssock;
@@ -1016,6 +1020,18 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk,
10161020
if (!newsk)
10171021
return -EINVAL;
10181022

1023+
/* The subflow socket lock is acquired in a nested to the msk one
1024+
* in several places, even by the TCP stack, and this msk is a kernel
1025+
* socket: lockdep complains. Instead of propagating the _nested
1026+
* modifiers in several places, re-init the lock class for the msk
1027+
* socket to an mptcp specific one.
1028+
*/
1029+
sock_lock_init_class_and_name(newsk,
1030+
is_ipv6 ? "mlock-AF_INET6" : "mlock-AF_INET",
1031+
&mptcp_slock_keys[is_ipv6],
1032+
is_ipv6 ? "msk_lock-AF_INET6" : "msk_lock-AF_INET",
1033+
&mptcp_keys[is_ipv6]);
1034+
10191035
lock_sock(newsk);
10201036
ssock = __mptcp_nmpc_socket(mptcp_sk(newsk));
10211037
release_sock(newsk);

0 commit comments

Comments
 (0)