mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-27 13:05:03 +08:00
mptcp: fix locking for in-kernel listener creation
[ Upstream commitad2171009d
] For consistency, in mptcp_pm_nl_create_listen_socket(), we need to call the __mptcp_nmpc_socket() under the msk socket lock. Note that as a side effect, mptcp_subflow_create_socket() needs a 'nested' lockdep annotation, as it will acquire the subflow (kernel) socket lock under the in-kernel listener msk socket lock. The current lack of locking is almost harmless, because the relevant socket is not exposed to the user space, but in future we will add more complexity to the mentioned helper, let's play safe. Fixes:1729cf186d
("mptcp: create the listening socket for new port") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
e2c1a934fd
commit
2a6853c0ea
@ -891,8 +891,8 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk,
|
||||
{
|
||||
int addrlen = sizeof(struct sockaddr_in);
|
||||
struct sockaddr_storage addr;
|
||||
struct mptcp_sock *msk;
|
||||
struct socket *ssock;
|
||||
struct sock *newsk;
|
||||
int backlog = 1024;
|
||||
int err;
|
||||
|
||||
@ -901,13 +901,15 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
msk = mptcp_sk(entry->lsk->sk);
|
||||
if (!msk) {
|
||||
newsk = entry->lsk->sk;
|
||||
if (!newsk) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ssock = __mptcp_nmpc_socket(msk);
|
||||
lock_sock(newsk);
|
||||
ssock = __mptcp_nmpc_socket(mptcp_sk(newsk));
|
||||
release_sock(newsk);
|
||||
if (!ssock) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
|
@ -1570,7 +1570,7 @@ int mptcp_subflow_create_socket(struct sock *sk, struct socket **new_sock)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
lock_sock(sf->sk);
|
||||
lock_sock_nested(sf->sk, SINGLE_DEPTH_NESTING);
|
||||
|
||||
/* the newly created socket has to be in the same cgroup as its parent */
|
||||
mptcp_attach_cgroup(sk, sf->sk);
|
||||
|
Loading…
Reference in New Issue
Block a user