Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3288929pxk; Mon, 21 Sep 2020 09:47:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0cI61AHfCBCsD1+nVph22g/bjdbWOWfobX/kGXlyIGiAhiU/ghsdYDR/v0LUORvDxdEUS X-Received: by 2002:a17:906:f0cb:: with SMTP id dk11mr305491ejb.457.1600706834228; Mon, 21 Sep 2020 09:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600706834; cv=none; d=google.com; s=arc-20160816; b=y3sIw7mJnhlWDUw/u5y8KeJ5w65kAGlZHMcnPt9Fuelti0qxLe62DX+8DjDrp68Xgx eZYDX7b4pz54Cqcx8GvjYea8LxYek0GBesU3bEKR0dHfVl0A33eBpiiiMrLEmW2Tzf4w 6OfRG5HqbA4AbitcCUMSciZ1YoncrO13X/6sxOiqysSA/DEUR21kWVpGSSPVC2tfCa4M vvqw50EwuV4GakNYppPwNeSWRIkAqq4EqkJlWtgwRtHx1U07cu9hhEqWF5WV2kuFCSbo ff9CLwc1r5r8WzgFWcq6Ey2w6M9ft7zJAasQs9bzINgUBbaUHwiWNig62UWqVU3RuE4/ xshQ== 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=Wqfwh8xvlUDVXeX+SHvtDceU4eWmXy+rVVEhdnhT3Pk=; b=jplQ2VkCWB0WtnNScLfj1D9XSSuSQwHoGDHWVaxXimrg5cKKsysHUhFHv5MkDiAWaR puguqyG3yq6svJI1moeMQ9F++cmC2I3vnZshjX+RydwThrHQZlRl7XfvoYhpwmyHn/cL vW8XNc44eFztl0e81O91dksMts0KotDYKdGSoCl/ptTxOYRcRHAHa/cYN5OQezGoAWU+ 8XZoOdyUiZQs/4sU4PryGRbSxjAlfUrYVgnLmBfqU3/urfCab7+BLH46ls+geNtSjKsj UD2ca83EZck1pdD2at4x8a9coRzZEYpCs05s/Qwtk2c8sAU0vkxjW4hwug3GgRaRWSfa f6Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BW0tqI9R; 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=fail (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 b6si9155914eja.565.2020.09.21.09.46.50; Mon, 21 Sep 2020 09:47:14 -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=@kernel.org header.s=default header.b=BW0tqI9R; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729633AbgIUQnn (ORCPT + 99 others); Mon, 21 Sep 2020 12:43:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:48210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729617AbgIUQnd (ORCPT ); Mon, 21 Sep 2020 12:43:33 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 41C4B23A1E; Mon, 21 Sep 2020 16:43:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706612; bh=DopP0TXFS0MBEU+sZLrZgDrgeACAe7ZZZdRuOn1hAGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BW0tqI9R91nI2swdLdep9V1p8LhEhhQjr5c1cuBXuGQ5X5a1k+iZGHemqdofJ7aO3 BVNeAHwfeXqZzYCuJ/byxBOsM1TkPlg7RyR8hys/+CazXx0Jl/JSYjtnQQ9YnByjLr yFosKdhObpZFArb3ROo0ySiXjEALr5QqUzrquv+w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Mat Martineau , "David S. Miller" Subject: [PATCH 5.8 003/118] mptcp: sendmsg: reset iter on error Date: Mon, 21 Sep 2020 18:26:55 +0200 Message-Id: <20200921162036.501567458@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162036.324813383@linuxfoundation.org> References: <20200921162036.324813383@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: Florian Westphal commit 35759383133f64d90eba120a0d3efe8f71241650 upstream. Once we've copied data from the iterator we need to revert in case we end up not sending any data. This bug doesn't trigger with normal 'poll' based tests, because we only feed a small chunk of data to kernel after poll indicated POLLOUT. With blocking IO and large writes this triggers. Receiver ends up with less data than it should get. Fixes: 72511aab95c94d ("mptcp: avoid blocking in tcp_sendpages") Signed-off-by: Florian Westphal Reviewed-by: Mat Martineau Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/mptcp/protocol.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -605,8 +605,10 @@ static int mptcp_sendmsg_frag(struct soc if (!psize) return -EINVAL; - if (!sk_wmem_schedule(sk, psize + dfrag->overhead)) + if (!sk_wmem_schedule(sk, psize + dfrag->overhead)) { + iov_iter_revert(&msg->msg_iter, psize); return -ENOMEM; + } } else { offset = dfrag->offset; psize = min_t(size_t, dfrag->data_len, avail_size); @@ -617,8 +619,10 @@ static int mptcp_sendmsg_frag(struct soc */ ret = do_tcp_sendpages(ssk, page, offset, psize, msg->msg_flags | MSG_SENDPAGE_NOTLAST | MSG_DONTWAIT); - if (ret <= 0) + if (ret <= 0) { + iov_iter_revert(&msg->msg_iter, psize); return ret; + } frag_truesize += ret; if (!retransmission) {