]> git.baikalelectronics.ru Git - kernel.git/commit
inet_connection_sock: clear inet_num out of destroy helper
authorPaolo Abeni <pabeni@redhat.com>
Thu, 4 Jun 2020 16:55:45 +0000 (18:55 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Jun 2020 22:59:56 +0000 (15:59 -0700)
commit42cb0c6f6470c5bbce60e5b2054e2b291cf74859
tree0d6333f058a73299b197c90c3362c51f1bf75e69
parentfff4f089dec45f5b68c35abec81be3d210289ffc
inet_connection_sock: clear inet_num out of destroy helper

Clearing the 'inet_num' field is necessary and safe if and
only if the socket is not bound. The MPTCP protocol calls
the destroy helper on bound sockets, as tcp_v{4,6}_syn_recv_sock
completed successfully.

Move the clearing of such field out of the common code, otherwise
the MPTCP MP_JOIN error path will find the wrong 'inet_num' value
on socket disposal, __inet_put_port() will acquire the wrong lock
and bind_node removal could race with other modifiers possibly
corrupting the bind hash table.

Reported-and-tested-by: Christoph Paasch <cpaasch@apple.com>
Fixes: 74f69891c81d ("mptcp: cope better with MP_JOIN failure")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/inet_connection_sock.h
net/ipv4/inet_connection_sock.c