Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2663681pxj; Mon, 31 May 2021 07:43:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhpqDSjB/xNSEV4h8R1Ak8PNuucCQ+MOUH+yu+UuXJRqDNfb3a/QH6EwLZ8JC6zds1B6mq X-Received: by 2002:a17:907:96a4:: with SMTP id hd36mr23415830ejc.519.1622472238247; Mon, 31 May 2021 07:43:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622472238; cv=none; d=google.com; s=arc-20160816; b=GcVDBp6Bar/0aUelGfu3qJ+snaoE1iPxwh4C0ma495cGMEh1LgK1S1w4/kYh6oyz+O o0PyAggOELJNf5wfNS2r2mZ0DXEzf0f2cZ2Jrev3TN+NQwRIZKc1sX9b9Sp2SHatfaWN BwdXSJjsTPgTnSeLeKFOD1PdZiaqkKWGYPptA/HJfF20gj0Ac8/9IDrahNM/L9JV7NLp CLnWNULleZHmOuLZQxylD35BrgBEgJZHgg1D8bwJTs6BXnPNWV8UrtlMrG9K5EdOwRQT l06rDFMcdngvFGMYGCh8/ZLEvb55bxzmtnbztIHewTW+WsMJ4/lKtAx3PrYw0vRdvAlO k24w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UxZnvOUt8+PaAbGYvu+0vlk0aMbceg5vQd7pZzdjVWs=; b=cPxrwlefTHb5U3r1YqelAVVsO3ICbzy2s0bAXGfWoawZ5w4TI58Mnrl5tngYPy5Skl Ojb4LQhZ1xLSqDjkamxJsu7a+fK+uW8ZCB1uTEUsaVbnasJqfhZp+yCFDMi8wqKCZWKm M3XdzjK4REkBOJ2T+9F5iq0dZspuWNBzbUqY2BqLUF6D86rp1mQox5gIGXoQ6ynclQfU SyaxXcqPJT6jiIwo7nrwrMz++2+c9jyPLKKLb449qA//A9/XFEmYiY9IuP9MohrzSQeA v/qsxg0BZcyGWNXZnOkuZ47hvnEndJaKblj5xPtxbAPEftwq729aMW4M8LTSVydImD0o 6HGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WuZd6YcO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp6si16913040ejc.567.2021.05.31.07.43.34; Mon, 31 May 2021 07:43:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WuZd6YcO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233407AbhEaOls (ORCPT + 99 others); Mon, 31 May 2021 10:41:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:60806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232977AbhEaN62 (ORCPT ); Mon, 31 May 2021 09:58:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 96598613F5; Mon, 31 May 2021 13:35:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468132; bh=3aIgDmPsqoOhDLuQaV1yi37v5raac+mgycOPE1w4/+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WuZd6YcOfiJxxkOMQ6b1xupRXzoeX605EtuI5yXAGMZ96/xlld1+2nulymWmQXnwz zbkmQ9skrabMEIW9c4TLDTAJ3am6lzHAaBNx/MH9gbydZ1l6GyopGpaViwCSg1xC3p arwDNds0pLlFWxAWjqrEuHw2LiMXBFHNsnIKcc38= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , "David S. Miller" , Maxim Galaganov Subject: [PATCH 5.10 129/252] mptcp: fix data stream corruption Date: Mon, 31 May 2021 15:13:14 +0200 Message-Id: <20210531130702.399802167@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Abeni commit 29249eac5225429b898f278230a6ca2baa1ae154 upstream. Maxim reported several issues when forcing a TCP transparent proxy to use the MPTCP protocol for the inbound connections. He also provided a clean reproducer. The problem boils down to 'mptcp_frag_can_collapse_to()' assuming that only MPTCP will use the given page_frag. If others - e.g. the plain TCP protocol - allocate page fragments, we can end-up re-using already allocated memory for mptcp_data_frag. Fix the issue ensuring that the to-be-expanded data fragment is located at the current page frag end. v1 -> v2: - added missing fixes tag (Mat) Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/178 Reported-and-tested-by: Maxim Galaganov Fixes: 18b683bff89d ("mptcp: queue data for mptcp level retransmission") Signed-off-by: Paolo Abeni Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/mptcp/protocol.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -758,11 +758,17 @@ static bool mptcp_skb_can_collapse_to(u6 return mpext && mpext->data_seq + mpext->data_len == write_seq; } +/* we can append data to the given data frag if: + * - there is space available in the backing page_frag + * - the data frag tail matches the current page_frag free offset + * - the data frag end sequence number matches the current write seq + */ static bool mptcp_frag_can_collapse_to(const struct mptcp_sock *msk, const struct page_frag *pfrag, const struct mptcp_data_frag *df) { return df && pfrag->page == df->page && + pfrag->offset == (df->offset + df->data_len) && df->data_seq + df->data_len == msk->write_seq; }