]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
sctp: move sk_route_caps check and set into sctp_outq_flush_transports
authorXin Long <lucien.xin@gmail.com>
Fri, 19 Mar 2021 03:52:41 +0000 (11:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 Mar 2021 12:30:24 +0000 (14:30 +0200)
commit4147dffc53b3fb91ea5cfb670695f3bf026526c2
treef6fb12344c450a8f2e535f14430ca7357cd81fd0
parent8fdd62c52a17c5744eb19cb3e15dd8f2d23fd7a3
sctp: move sk_route_caps check and set into sctp_outq_flush_transports

[ Upstream commit 8ff0b1f08ea73e5c08f5addd23481e76a60e741c ]

The sk's sk_route_caps is set in sctp_packet_config, and later it
only needs to change when traversing the transport_list in a loop,
as the dst might be changed in the tx path.

So move sk_route_caps check and set into sctp_outq_flush_transports
from sctp_packet_transmit. This also fixes a dst leak reported by
Chen Yi:

  https://bugzilla.kernel.org/show_bug.cgi?id=212227

As calling sk_setup_caps() in sctp_packet_transmit may also set the
sk_route_caps for the ctrl sock in a netns. When the netns is being
deleted, the ctrl sock's releasing is later than dst dev's deleting,
which will cause this dev's deleting to hang and dmesg error occurs:

  unregister_netdevice: waiting for xxx to become free. Usage count = 1

Reported-by: Chen Yi <yiche@redhat.com>
Fixes: bcd623d8e9fa ("sctp: call sk_setup_caps in sctp_packet_transmit instead")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sctp/output.c
net/sctp/outqueue.c