Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2738994pxj; Mon, 31 May 2021 09:31:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHqUsnCYZQYEkUa+4LhRCYKD7+5SOu5yoEUqWVIBVfHZLJJ/A2ejJwvyRLJ9BHIn2A7FEx X-Received: by 2002:a6b:f60e:: with SMTP id n14mr17894488ioh.179.1622478662126; Mon, 31 May 2021 09:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622478662; cv=none; d=google.com; s=arc-20160816; b=YJQ8d1spHzUrdab90XjnQYGouSvwubUUZP6fFsnc3frNaG/YAtAV/kEcJepc2p2+eq ZKCIS3tn3UYpDtRApc2ZxMcXPfx1QvTOU/FvI1jY+tGYYjKQmVt5ihQCkiP+Xxt+TZJ4 qx8MLP+PA6AA/ZUQHgErLte74cDOTE8811QBqGJ1wriQwtwrMvEw1GLK2VE3udGKMHIa Ufo1tEWLyxDYi3yFjps2QJScghdgtmPBmjQ2INkyIn7VGB9Yxkjz81/fOk6P4uIKXxrs LqTsPQkW7IGUsduHer1PbXKwo+sc9xt9AmD5dWk11OU2V33+UvAesQXE5t55IscsYoL7 wVCg== 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=QT/NfYWlItrQYVneHCs5ID819XCU+8C008hICQBX6iI=; b=taLxrZ5fpXkV7RTO0YF+hELujo7CYeqUhL8l7CslFUsS/6ANSAHVzFlvA7d4fhjMOc gulN95GTZvuRtoV0amT/l2gLZlFWQNXqUx3NVmt8ekGtGM11LMFs7kBxTA1ycTBujMFZ r2mKfNdZip1g805bvPDw2Kp9e+I/+4qxWDcRfZixFlRdc8JUuqI9/JJFf9w1gkNWSrTU Z3q4VEFwm13DNxfeM1/TSL/mDhWXyu+0ZB/M36jBvJbu/SRvL6J5kLWAJ+h+wXvZTqID EQF6N48Wy3yDHXcfDt0dgNPaivhTv5xajCqwgS9xREH2nf7EXtMdAvVGDHe7nyoAIlPs DH6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PGBu9I1x; 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 b15si15879959jat.59.2021.05.31.09.30.44; Mon, 31 May 2021 09:31:02 -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=PGBu9I1x; 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 S232009AbhEaQaY (ORCPT + 99 others); Mon, 31 May 2021 12:30:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:40792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232115AbhEaOpj (ORCPT ); Mon, 31 May 2021 10:45:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 776AA61C7F; Mon, 31 May 2021 13:55:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469334; bh=qyfZOekgMxPGapE2Q5eCN20eauVYemqaHxjewy5Bmw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PGBu9I1x+O5sR3BkgA93KI39jH5MJER09ijWu6IyyMtcfE1QEmYIfgzmMTWbnfbuP THkCNSnUNef8apbnIH596rwu0T6llo/sfUEo9RFK3gH+M5BK3bhuaT9mz9podNvwTe URxYUMOFvzm32WDMSG7xgY9XLW7pro1mg4cLHB2w= 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.12 158/296] mptcp: fix data stream corruption Date: Mon, 31 May 2021 15:13:33 +0200 Message-Id: <20210531130709.172747728@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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 @@ -869,12 +869,18 @@ static bool mptcp_skb_can_collapse_to(u6 !mpext->frozen; } +/* 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->size - pfrag->offset > 0 && + pfrag->offset == (df->offset + df->data_len) && df->data_seq + df->data_len == msk->write_seq; }