forked from Minki/linux
mptcp: fix locking in mptcp_nl_cmd_sf_destroy()
The user-space PM subflow removal path uses a couple of helpers
that must be called under the msk socket lock and the current
code lacks such requirement.
Change the existing lock scope so that the relevant code is under
its protection.
Fixes: 702c2f646d
("mptcp: netlink: allow userspace-driven subflow establishment")
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/287
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
44d632d5dd
commit
5ccecaec5c
@ -306,15 +306,11 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk,
|
||||
const struct mptcp_addr_info *local,
|
||||
const struct mptcp_addr_info *remote)
|
||||
{
|
||||
struct sock *sk = &msk->sk.icsk_inet.sk;
|
||||
struct mptcp_subflow_context *subflow;
|
||||
struct sock *found = NULL;
|
||||
|
||||
if (local->family != remote->family)
|
||||
return NULL;
|
||||
|
||||
lock_sock(sk);
|
||||
|
||||
mptcp_for_each_subflow(msk, subflow) {
|
||||
const struct inet_sock *issk;
|
||||
struct sock *ssk;
|
||||
@ -347,16 +343,11 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk,
|
||||
}
|
||||
|
||||
if (issk->inet_sport == local->port &&
|
||||
issk->inet_dport == remote->port) {
|
||||
found = ssk;
|
||||
goto found;
|
||||
}
|
||||
issk->inet_dport == remote->port)
|
||||
return ssk;
|
||||
}
|
||||
|
||||
found:
|
||||
release_sock(sk);
|
||||
|
||||
return found;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
|
||||
@ -412,6 +403,7 @@ int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
|
||||
}
|
||||
|
||||
sk = &msk->sk.icsk_inet.sk;
|
||||
lock_sock(sk);
|
||||
ssk = mptcp_nl_find_ssk(msk, &addr_l, &addr_r);
|
||||
if (ssk) {
|
||||
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
|
||||
@ -422,8 +414,9 @@ int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
|
||||
} else {
|
||||
err = -ESRCH;
|
||||
}
|
||||
release_sock(sk);
|
||||
|
||||
destroy_err:
|
||||
destroy_err:
|
||||
sock_put((struct sock *)msk);
|
||||
return err;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user