From: Jakub Kicinski <kuba@kernel.org>
To: Mat Martineau <mathew.j.martineau@linux.intel.com>
Cc: netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
davem@davemloft.net, matthieu.baerts@tessares.net,
mptcp@lists.linux.dev, Florian Westphal <fw@strlen.de>
Subject: Re: [PATCH net 1/2] mptcp: fix possible divide by zero
Date: Mon, 30 Aug 2021 16:57:05 -0700 [thread overview]
Message-ID: <20210830165705.1f0dbafc@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <20210828001731.67757-2-mathew.j.martineau@linux.intel.com>
On Fri, 27 Aug 2021 17:17:30 -0700 Mat Martineau wrote:
> From: Paolo Abeni <pabeni@redhat.com>
>
> 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.
>
> Reported-by: Florian Westphal <fw@strlen.de>
> Fixes: 724cfd2ee8aa ("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>
> ---
> net/mptcp/protocol.c | 78 +++++++++++++++++++++-----------------------
> 1 file changed, 37 insertions(+), 41 deletions(-)
>
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index a88924947815..0d5c1ec28508 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -994,6 +994,15 @@ static void mptcp_wmem_uncharge(struct sock *sk, int size)
> msk->wmem_reserved += size;
> }
>
> +static void __mptcp_mem_reclaim_partial(struct sock *sk)
> +{
> +#ifdef CONFIG_LOCKDEP
> + WARN_ON_ONCE(!lockdep_is_held(&sk->sk_lock.slock));
> +#endif
lockdep_assert_held_once() ? No ifdef should be needed?
> + __mptcp_update_wmem(sk);
> + sk_mem_reclaim_partial(sk);
> +}
> +
> static void mptcp_mem_reclaim_partial(struct sock *sk)
> {
> struct mptcp_sock *msk = mptcp_sk(sk);
> @@ -1512,7 +1516,9 @@ static void __mptcp_push_pending(struct sock *sk, unsigned int flags)
> static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk)
> {
> struct mptcp_sock *msk = mptcp_sk(sk);
> - struct mptcp_sendmsg_info info;
> + struct mptcp_sendmsg_info info = {
> + .data_lock_held = true,
indentation looks off
> + };
next prev parent reply other threads:[~2021-08-30 23:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-28 0:17 [PATCH net 0/2] mptcp: Prevent tcp_push() crash and selftest temp file buildup Mat Martineau
2021-08-28 0:17 ` [PATCH net 1/2] mptcp: fix possible divide by zero Mat Martineau
2021-08-30 23:57 ` Jakub Kicinski [this message]
2021-08-28 0:17 ` [PATCH net 2/2] selftests: mptcp: clean tmp files in simult_flows Mat Martineau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210830165705.1f0dbafc@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=fw@strlen.de \
--cc=mathew.j.martineau@linux.intel.com \
--cc=matthieu.baerts@tessares.net \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).