zephyr/subsys/net/ip
Robert Lubos 5af3c6ca90 net: tcp: Fix possible deadlock in tcp_in()
After introducing SO_SNDBUF socket option, a possible deadlock situation
slipped into the TCP implementation. The scenario for the deadlock:

  * application thread tries to send some data, it enters
    net_context_send() which locks the context mutex,
  * internal context_sendto() blocks on a TX packet allocation, if the
    TX pool is empty rescheduling takes place,
  * now, if at the same time some incoming packet has arrived (ACK for
    example), TCP stack enters tcp_in() function from a different
    thread. The function locks the TCP connection mutex, and tries to
    obtain the SNDBUF option value. net_context_get_option() tries to
    lock the context mutex, but it is already held by the transmitting
    thread, so the receiver thread blocks
  * when TX packet is available again, the transmitting thread unblocks
    and tries to pass the packet down to TCP stack. net_tcp_queue_data()
    is called which attempts to lock the TCP connection mutex, but it is
    already held by the receiving thread. Both threads are in a deadlock
    now with no chance to recover.

Fix this, by obtaining the SNDBUF option value in tcp_in() before
locking the TCP connection mutex.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-11 11:04:22 +02:00
..
6lo_private.h
6lo.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
6lo.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
canbus_socket.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
canbus_socket.h
CMakeLists.txt
connection.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
connection.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
dhcpv4.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
dhcpv4.h
icmpv4.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
icmpv4.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
icmpv6.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
icmpv6.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
igmp.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
ipv4_autoconf_internal.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
ipv4_autoconf.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
ipv4.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
ipv4.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
ipv6_fragment.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
ipv6_mld.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
ipv6_nbr.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
ipv6.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
ipv6.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
Kconfig
Kconfig.debug
Kconfig.ipv4
Kconfig.ipv6
Kconfig.mgmt
Kconfig.stack
Kconfig.stats
nbr.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
nbr.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
net_context.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
net_core.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
net_if.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
net_mgmt.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
net_pkt.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
net_private.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
net_shell.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
net_shell.h
net_stats.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
net_stats.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
net_tc_mapping.h
net_tc.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
net_timeout.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
packet_socket.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
packet_socket.h
promiscuous.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
route.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
route.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
tcp_internal.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
tcp_private.h
tcp.c net: tcp: Fix possible deadlock in tcp_in() 2022-05-11 11:04:22 +02:00
tcp.h
tp_priv.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
tp.c
tp.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
trickle.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
udp_internal.h subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
udp.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00
utils.c subsystems: migrate includes to <zephyr/...> 2022-05-09 12:07:35 +02:00