]> git.baikalelectronics.ru Git - kernel.git/commit
mptcp: fix possible divide by zero
authorPaolo Abeni <pabeni@redhat.com>
Wed, 1 Sep 2021 17:15:36 +0000 (10:15 -0700)
committerJakub Kicinski <kuba@kernel.org>
Wed, 1 Sep 2021 17:55:49 +0000 (10:55 -0700)
commit2668d5738ac791769ba6ba325d9a39f99a4ce71d
tree8ab0fde4a5fc6bd3782ec08b7d0dc2cef6ba1949
parent41ab2048b46894358ea545390f62cd81382a399e
mptcp: fix possible divide by zero

Florian noted that if mptcp_alloc_tx_skb() allocation fails
in __mptcp_push_pending(), we can end-up invoking
mptcp_push_release()/tcp_push() with a zero mss, causing
a divide by 0 error.

This change addresses the issue refactoring the skb allocation
code checking if skb collapsing will happen for sure and doing
the skb allocation only after such check. Skb allocation will
now happen only after the call to tcp_send_mss() which
correctly initializes mss_now.

As side bonuses we now fill the skb tx cache only when needed,
and this also clean-up a bit the output path.

v1 -> v2:
 - use lockdep_assert_held_once() - Jakub
 - fix indentation - Jakub

Reported-by: Florian Westphal <fw@strlen.de>
Fixes: 34b5fd1b9a92 ("mptcp: allocate TX skbs in msk context")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/mptcp/protocol.c