From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C98482871; Wed, 19 Jun 2024 13:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718802214; cv=none; b=Si6I/KXqN7hwi8pVlLInxLrolc4fzdy8QVb17wsqKXGrtl4mNFFRD3YVKorvn1y4KM2IV24dEmrj3LH/Dmnin92GQuMm9Ss/+ssJ1jf4WlWsHZiERHLmSUfEevkpTpDpGsggeerZ6NPjOOSuDx/Jg/wBLijiPoYxjgxaq7SmLkE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718802214; c=relaxed/simple; bh=c3Y9W8t/OV5gJUdpnFxh/V83CVXj5W1fttoXvf4xEd0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MIIOI10nE5wvJZ9af7NED40P15WGiqSoCvP3NsHx3JDz87HX0/wP3a1xteWv5Iv+/iCGY6OAuM9Su0F1LZi5zPygG0pQTjoc02IDQC/a5JvJ63+tQKEwd4d8ukk9KnqhsNpind9/BgFG4L9H+Q2S9ET5kMOgNKR29qHuDI9hGgw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=w9JrRkPL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="w9JrRkPL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85221C2BBFC; Wed, 19 Jun 2024 13:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718802213; bh=c3Y9W8t/OV5gJUdpnFxh/V83CVXj5W1fttoXvf4xEd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w9JrRkPLoJ5Agg4SySUlB48LMCEK/rXxfi6hhttvLPxsk2ydTNMMNhYeyViEh1zGg zk+u/dPHycsS+DfLQgC36RBanIiy3yYbVA9cFpIdW8x6tq6gvgmsO8c2SnNk/0tm37 0nLx6V7uWV4RT/vEpKWynLSDCuwc+FHtcHRl0qsM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pierre Tomon , Alan Stern , Mathias Nyman Subject: [PATCH 6.6 089/267] xhci: Set correct transferred length for cancelled bulk transfers Date: Wed, 19 Jun 2024 14:54:00 +0200 Message-ID: <20240619125609.766237070@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240619125606.345939659@linuxfoundation.org> References: <20240619125606.345939659@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mathias Nyman commit f0260589b439e2637ad54a2b25f00a516ef28a57 upstream. The transferred length is set incorrectly for cancelled bulk transfer TDs in case the bulk transfer ring stops on the last transfer block with a 'Stop - Length Invalid' completion code. length essentially ends up being set to the requested length: urb->actual_length = urb->transfer_buffer_length Length for 'Stop - Length Invalid' cases should be the sum of all TRB transfer block lengths up to the one the ring stopped on, _excluding_ the one stopped on. Fix this by always summing up TRB lengths for 'Stop - Length Invalid' bulk cases. This issue was discovered by Alan Stern while debugging https://bugzilla.kernel.org/show_bug.cgi?id=218890, but does not solve that bug. Issue is older than 4.10 kernel but fix won't apply to those due to major reworks in that area. Tested-by: Pierre Tomon Cc: stable@vger.kernel.org # v4.10+ Cc: Alan Stern Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20240611120610.3264502-2-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-ring.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2525,9 +2525,8 @@ static int process_bulk_intr_td(struct x goto finish_td; case COMP_STOPPED_LENGTH_INVALID: /* stopped on ep trb with invalid length, exclude it */ - ep_trb_len = 0; - remaining = 0; - break; + td->urb->actual_length = sum_trb_lengths(xhci, ep_ring, ep_trb); + goto finish_td; case COMP_USB_TRANSACTION_ERROR: if (xhci->quirks & XHCI_NO_SOFT_RETRY || (ep->err_count++ > MAX_SOFT_RETRY) ||