From patchwork Tue Aug 6 17:28:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Foster Snowhill X-Patchwork-Id: 13755048 Received: from qs51p00im-qukt01072501.me.com (qs51p00im-qukt01072501.me.com [17.57.155.14]) (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 3DC4576035 for ; Tue, 6 Aug 2024 17:28:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.57.155.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722965329; cv=none; b=lFECi2gToPeYda0+gYOziT9OYYBMDMZ0dDDug+AkBhnpfg6EPpMoGwGOEE/3720P67Tu8n9xGghPf/cgfXf8JEobaY+nH/MJhpSQr0Bp9k0Z1FdYQASrioCBd5SF7ADPZxD++78xDU1cNkfrdcXdmBkfJak6/aYx9EX/0QyoSI8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722965329; c=relaxed/simple; bh=8EnOfnQc5awRMnkFtVV217X1/jCf5ygnJDCReCt8/BY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=aGCBjpkF39cLtssSrh8lszFBsOKtsFn2Q3HNasCmsGFbkxU/Dr3ZURCQJQvbIQKno1bKuAjYYvmrfOCCcmBZY+TQfAMqY4hO10Z+tgOOQGU+lRsmmFdZJ30DsRtLo82VpdyEhvm6KE2Yn9KzMZKQOzo4xRz4/LYeMLP8HHI21kE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pen.gy; spf=pass smtp.mailfrom=pen.gy; dkim=pass (2048-bit key) header.d=pen.gy header.i=@pen.gy header.b=eQx3WLkf; arc=none smtp.client-ip=17.57.155.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pen.gy Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pen.gy Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pen.gy header.i=@pen.gy header.b="eQx3WLkf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pen.gy; s=sig1; t=1722965326; bh=I54BpuHlFXJ14PzdceLKFzF/ikAKzgpc8iyj+Ds8T8Y=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=eQx3WLkf6F+07Ojqz3zk3dmHGdgRIezrIDpxO9QtQpSWJ8P7KADfhgA+nE0xDFq2B VjgVa9G8jQBnGxbnUzLFIlW+v7O/802JRW2H0RPbja5Indhj777RrNQ0M+lPd1TGYT O+iyxj1NlmvEZolyI34a5yflxPTuybuvmGXvlEC46BQotoecUYmJgvMJUoB1WB6t4q F50Cf8XLITx4s+eO+0kDYIPQMITYK8q3YosYOCdJ2q/Vpp/+5Hx4jvA8rlPlqLo1Qt ZBfDYtVO5686kQksi1G9hm15UWb/w42rf0w0Q5whvuJqa1+FOy7MOWj22bLiLeiP9S A6tDQJ3gHFoHQ== Received: from fossa.se1.pen.gy (qs51p00im-dlb-asmtp-mailmevip.me.com [17.57.155.28]) by qs51p00im-qukt01072501.me.com (Postfix) with ESMTPSA id 88716440429; Tue, 6 Aug 2024 17:28:43 +0000 (UTC) From: Foster Snowhill To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Georgi Valkov , Oliver Neukum , netdev@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH net-next 1/5] usbnet: ipheth: race between ipheth_close and error handling Date: Tue, 6 Aug 2024 19:28:05 +0200 Message-ID: <20240806172809.675044-1-forst@pen.gy> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: xKZZWHYtk5nDuCNqkQSujrzv2VdPu78K X-Proofpoint-ORIG-GUID: xKZZWHYtk5nDuCNqkQSujrzv2VdPu78K X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-06_14,2024-08-06_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 mlxscore=0 suspectscore=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2408060123 From: Oliver Neukum ipheth_sndbulk_callback() can submit carrier_work as a part of its error handling. That means that the driver must make sure that the work is cancelled after it has made sure that no more URB can terminate with an error condition. Hence the order of actions in ipheth_close() needs to be inverted. Signed-off-by: Oliver Neukum Signed-off-by: Foster Snowhill Tested-by: Georgi Valkov --- v1: No code changes. Fixed two "ipeth" -> "ipheth" typos in commit msg. RFC: https://lore.kernel.org/netdev/20231121144330.3990-1-oneukum@suse.com/ --- drivers/net/usb/ipheth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index 687d70cfc556..6eeef10edada 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c @@ -475,8 +475,8 @@ static int ipheth_close(struct net_device *net) { struct ipheth_device *dev = netdev_priv(net); - cancel_delayed_work_sync(&dev->carrier_work); netif_stop_queue(net); + cancel_delayed_work_sync(&dev->carrier_work); return 0; } From patchwork Tue Aug 6 17:28:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Foster Snowhill X-Patchwork-Id: 13755049 Received: from qs51p00im-qukt01072501.me.com (qs51p00im-qukt01072501.me.com [17.57.155.14]) (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 802A662A02 for ; Tue, 6 Aug 2024 17:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.57.155.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722965332; cv=none; b=KAfj69IZgs33iaTtju21gXGulXjM8WBtOFwKUR2uBa+97BWaM23xv9Ox/b6vnZOaN7sJ6D5ZIBXrefTPCEpgQ8Bp//pJhFT3e12oJuNE01pwYLkgBajHovTKoBTWW9JZ/ODoqQAv2jqR9y77R+oXJu78fj7jiVV/xy2vaNwblDg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722965332; c=relaxed/simple; bh=KxjFJ439U5Uqr++yvMpYfMvkYLK6KAI8Z1y6rGxbyCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dRxGi5OT4qASWYUe1m6sGm1DOcALWSDtz1MZQ05bnVwHeCEfd1puzFFunni14EIcrjYUEYHpak34E3eHH08UdZ5F5JFSigz7t2z4pgSd/Z+32CefV8UNc0qoduyvF+S6cRD05iDl+VWw1rrAqgbkIp7/6CTFE57LRFXSiQkJqso= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pen.gy; spf=pass smtp.mailfrom=pen.gy; dkim=pass (2048-bit key) header.d=pen.gy header.i=@pen.gy header.b=VflxrJZB; arc=none smtp.client-ip=17.57.155.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pen.gy Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pen.gy Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pen.gy header.i=@pen.gy header.b="VflxrJZB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pen.gy; s=sig1; t=1722965329; bh=Uo+aXk6YogbsVi8I+aNJDJsTpJ8HfpCSJvx3xAXPcm0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=VflxrJZB46adtHidkAft7qb3+nI5lhZJ+35CGfr+MIpDD+SixAQ0kdsaDdgEfHsoZ mEibU8+gDdpeUsDCrmGW4XLA2SephK4LGjI/xd5cKkN6CZqyFRbYiCFVU3+aOmFJA7 +0QRNEhAZsl5SVCJe4JrIN6TRPWLVxJCvCLVKj1mHLTmcbGi1eQ7ee33Cq2PObGAWJ wz0oWIHgt9bBfqDAVO4oP5Se4X5rfK3FYxAfbS7LFK1Eej0N2DuvhRzkExQP+3dFQt gdNkuDvUfWKghEbK9tGBQGtC/PmsQMP3OlZRa5/1ozVTlCeydyZ6Ssgi7In3Oz/uDk LRyfc8KikHpSw== Received: from fossa.se1.pen.gy (qs51p00im-dlb-asmtp-mailmevip.me.com [17.57.155.28]) by qs51p00im-qukt01072501.me.com (Postfix) with ESMTPSA id D6CDA440249; Tue, 6 Aug 2024 17:28:46 +0000 (UTC) From: Foster Snowhill To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Georgi Valkov , Oliver Neukum , netdev@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH net-next 2/5] usbnet: ipheth: remove extraneous rx URB length check Date: Tue, 6 Aug 2024 19:28:06 +0200 Message-ID: <20240806172809.675044-2-forst@pen.gy> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240806172809.675044-1-forst@pen.gy> References: <20240806172809.675044-1-forst@pen.gy> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: KAo4SPFZVPe8yg9ihCvIBLFODIVc-d3I X-Proofpoint-ORIG-GUID: KAo4SPFZVPe8yg9ihCvIBLFODIVc-d3I X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-06_14,2024-08-06_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 mlxscore=0 suspectscore=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=724 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2408060123 Rx URB length was already checked in ipheth_rcvbulk_callback_legacy() and ipheth_rcvbulk_callback_ncm(), depending on the current mode. The check in ipheth_rcvbulk_callback() was thus mostly a duplicate. The only place in ipheth_rcvbulk_callback() where we care about the URB length is for the initial control frame. These frames are always 4 bytes long. This has been checked as far back as iOS 4.2.1 on iPhone 3G. Remove the extraneous URB length check. For control frames, check for the specific 4-byte length instead. Signed-off-by: Foster Snowhill Tested-by: Georgi Valkov --- drivers/net/usb/ipheth.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index 6eeef10edada..017255615508 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c @@ -286,11 +286,6 @@ static void ipheth_rcvbulk_callback(struct urb *urb) return; } - if (urb->actual_length <= IPHETH_IP_ALIGN) { - dev->net->stats.rx_length_errors++; - return; - } - /* RX URBs starting with 0x00 0x01 do not encapsulate Ethernet frames, * but rather are control frames. Their purpose is not documented, and * they don't affect driver functionality, okay to drop them. @@ -298,7 +293,8 @@ static void ipheth_rcvbulk_callback(struct urb *urb) * URB received from the bulk IN endpoint. */ if (unlikely - (((char *)urb->transfer_buffer)[0] == 0 && + (urb->actual_length == 4 && + ((char *)urb->transfer_buffer)[0] == 0 && ((char *)urb->transfer_buffer)[1] == 1)) goto rx_submit; From patchwork Tue Aug 6 17:28:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Foster Snowhill X-Patchwork-Id: 13755050 Received: from qs51p00im-qukt01072501.me.com (qs51p00im-qukt01072501.me.com [17.57.155.14]) (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 E006A78C8B for ; Tue, 6 Aug 2024 17:28:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.57.155.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722965335; cv=none; b=oAH2H2usqtYnjD0XXZqARNjP5UycNClnzKMGETffJirHKo1kg0AgeWU2gZob3+ezCa+fLdYZKXtK8hQdZBG2LVcS0qNICC5iQtqfOuSKkZ9RS0zuBwlx9sxW3MrFAklAo0b5z1Ek/oZd/StrvnYmW6f5ZXSot1Di868RdUkURec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722965335; c=relaxed/simple; bh=ubdVxvBRHK4prX4q7OyKXte/DltU0dS/J02go08lMhM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gIORWlgwsAkdi/pp+feRkMVUTO43Set5GsC5ISfJsxkgISsedOodbE2zDVy00Q2j0q03KTP/bjGQDGuxRBFZEmoqHCU/HdtanEoYNyjgrQqjMhundH6NdTOmmqqalJv++BVJOpADV25LTvhqTTb2qfvyhtuup1HsfNYneSpFIzc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pen.gy; spf=pass smtp.mailfrom=pen.gy; dkim=pass (2048-bit key) header.d=pen.gy header.i=@pen.gy header.b=Hk3tL4ex; arc=none smtp.client-ip=17.57.155.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pen.gy Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pen.gy Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pen.gy header.i=@pen.gy header.b="Hk3tL4ex" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pen.gy; s=sig1; t=1722965333; bh=UxeYWQSz4iOwxX9retJ70LoYdSG2m+FccOYF6P9/oL4=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Hk3tL4expbi8Jy4Iu9fvDvIloQn/jIUVaAslSk8ehMLFW0EptlyPhAa1+KkfWlSx0 O2KAV5TfOVaKdeJwcqrEN/8JTLigkGOp1k7Ro60418QoVqseFhdls/JFNpIzLu93VR OqKzK/2hzGDbTD3mRl3AKclPti+hMb7VdWIWn3cMK8EskF7iVc2jghBoYzfNyr9eau 9vAoErCwJwh3NKv4UbzVolA5eVxWw57v0beNaBuZflE4kufFSEIHvDFjmeXLgHr9zO EnxR9tFMWgCEDAh8IYYjEBjfmt47tfUW+CRn0OWu6OGAkeZhaXw9cV3AGSmio8/7zd nrJJgsEP2ImAQ== Received: from fossa.se1.pen.gy (qs51p00im-dlb-asmtp-mailmevip.me.com [17.57.155.28]) by qs51p00im-qukt01072501.me.com (Postfix) with ESMTPSA id 3ACA9440246; Tue, 6 Aug 2024 17:28:49 +0000 (UTC) From: Foster Snowhill To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Georgi Valkov , Oliver Neukum , netdev@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH net-next 3/5] usbnet: ipheth: drop RX URBs with no payload Date: Tue, 6 Aug 2024 19:28:07 +0200 Message-ID: <20240806172809.675044-3-forst@pen.gy> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240806172809.675044-1-forst@pen.gy> References: <20240806172809.675044-1-forst@pen.gy> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: gz1XCD9jyqy-1Bkt9juS1LWuYCyzDpYe X-Proofpoint-ORIG-GUID: gz1XCD9jyqy-1Bkt9juS1LWuYCyzDpYe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-06_14,2024-08-06_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 mlxscore=0 suspectscore=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=584 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2408060123 On iPhone 15 Pro Max one can observe periodic URBs with no payload on the "bulk in" (RX) endpoint. These don't seem to do anything meaningful. Reproduced on iOS 17.5.1 and 17.6. This behaviour isn't observed on iPhone 11 on the same iOS version. The nature of these zero-length URBs is so far unknown. Drop RX URBs with no payload. Signed-off-by: Foster Snowhill --- drivers/net/usb/ipheth.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index 017255615508..f04c7bf79665 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c @@ -286,6 +286,12 @@ static void ipheth_rcvbulk_callback(struct urb *urb) return; } + /* iPhone may periodically send URBs with no payload + * on the "bulk in" endpoint. It is safe to ignore them. + */ + if (urb->actual_length == 0) + goto rx_submit; + /* RX URBs starting with 0x00 0x01 do not encapsulate Ethernet frames, * but rather are control frames. Their purpose is not documented, and * they don't affect driver functionality, okay to drop them. From patchwork Tue Aug 6 17:28:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Foster Snowhill X-Patchwork-Id: 13755051 Received: from qs51p00im-qukt01072501.me.com (qs51p00im-qukt01072501.me.com [17.57.155.14]) (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 81C786CDAB for ; Tue, 6 Aug 2024 17:28:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.57.155.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722965339; cv=none; b=LOpb4uR3cYjjaz9/qaf0k6a4cO9IN2OuIVsKRY7FZ4oim2wb7Ds/SR6R3+8BlEftJ3b8IekRcCDNmAm1EdIpecXpaeaFO6sPH7qJvGFU9L1DtmScwghH4TgjIOwKW2It7K71mv4n7BG/nGkLuqINal0fV3TG6QwBp9LMdLQebRQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722965339; c=relaxed/simple; bh=r4jM7/1IkEKgY0ungXA8jhjmM/hIg/PFpvVBx8rVmvU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S22t0a4PHepKT+fcwoUE6N/TAJB0ClF6gus6JRUK7P6dMqhOhk9mLQm/hxSvMFZJb7gmnNFjjmRNc0nkPaGzAbl1MUyap/b/wCpnlqfN3Ind7Zx2u+VsBKTfvKqAasnvVF24QhssJbAVmZBgiOjQq7P2/zupH9VUf2S6Uu0ztno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pen.gy; spf=pass smtp.mailfrom=pen.gy; dkim=pass (2048-bit key) header.d=pen.gy header.i=@pen.gy header.b=Td7vNzJJ; arc=none smtp.client-ip=17.57.155.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pen.gy Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pen.gy Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pen.gy header.i=@pen.gy header.b="Td7vNzJJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pen.gy; s=sig1; t=1722965336; bh=VYwjQRXhlxuRj7b+rabVq90p4y0SQRs2I21vJahw3z0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Td7vNzJJRabIU3z0E3fdgtaMGaboeWSTGO/8x5gat6n09AggZTEgd3+QPapD7opKL HdwF/F8dS5Glqrcg3YFjvq47wL3zVkUtoaCPOGkO5R667aav2s4DCpPMpYKKIKFtHL fySZ/LIgSG2Y739LARbPK/tV/R5yhVejaRtcN9UuP/+oq55676RxZBbFdlx2U11JQr dYbYWCgNnMj7H5+dN0QO/Bw5H3x208Y5Ge+XE6gz7MLyHGlA1Pfei8Zr1W2GyC3Pir pMZP2K4JajA2OJvs/WELvnQ4pNgMT6Uv9IO2xuRlsIN3YJO/vU4bMwoc6sAjnlvqkw aK7BI9t2rWycg== Received: from fossa.se1.pen.gy (qs51p00im-dlb-asmtp-mailmevip.me.com [17.57.155.28]) by qs51p00im-qukt01072501.me.com (Postfix) with ESMTPSA id 9A9524404E2; Tue, 6 Aug 2024 17:28:53 +0000 (UTC) From: Foster Snowhill To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Georgi Valkov , Oliver Neukum , netdev@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH net-next 4/5] usbnet: ipheth: do not stop RX on failing RX callback Date: Tue, 6 Aug 2024 19:28:08 +0200 Message-ID: <20240806172809.675044-4-forst@pen.gy> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240806172809.675044-1-forst@pen.gy> References: <20240806172809.675044-1-forst@pen.gy> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: irkqZg7NrJqhCrB9s7yj9Ymb6A6RzsT_ X-Proofpoint-ORIG-GUID: irkqZg7NrJqhCrB9s7yj9Ymb6A6RzsT_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-06_14,2024-08-06_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 mlxscore=0 suspectscore=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=380 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2408060123 RX callbacks can fail for multiple reasons: * Payload too short * Payload formatted incorrecly (e.g. bad NCM framing) * Lack of memory None of these should cause the driver to seize up. Make such failures non-critical and continue processing further incoming URBs. Signed-off-by: Foster Snowhill --- drivers/net/usb/ipheth.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index f04c7bf79665..cdc72559790a 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c @@ -308,7 +308,6 @@ static void ipheth_rcvbulk_callback(struct urb *urb) if (retval != 0) { dev_err(&dev->intf->dev, "%s: callback retval: %d\n", __func__, retval); - return; } rx_submit: From patchwork Tue Aug 6 17:28:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Foster Snowhill X-Patchwork-Id: 13755052 Received: from qs51p00im-qukt01072501.me.com (qs51p00im-qukt01072501.me.com [17.57.155.14]) (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 9AC1A6F076 for ; Tue, 6 Aug 2024 17:29:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.57.155.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722965342; cv=none; b=OIwZV1acZiriAYkatKjDAsuzj0mabXbmF21KUucgrazZWJUh3/TvFsEO7bFXZXXQe4a3k43ujUvad/9eDC5fF8K3fZlubptlsBGfWrARDZJbSegrikxq+igeuxxiFM4ofVBfKi9PWarp+Q7LlFSVGV6qN4GXG9eya137OQjXWaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722965342; c=relaxed/simple; bh=HyXhN5Oq9+XkjKdLjBy4TdzJZ6j/ftELzMKQNXAsgMo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LoJejr1gm84LRup/E6MeLToCiy6SdzX/k0+UXnsCJW5N4Z96S9T9EHQlpmE2gBKKVjDdj8wy7+1Uy7vUMVfymx4/xZsY2PBeX2rHxd71c2k2ntqqSDGHjA7qj26v+aJIFgjY7HWkVe3D7ZEbBZAOthQsd5cHrBxzUFCW86kIcKY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pen.gy; spf=pass smtp.mailfrom=pen.gy; dkim=pass (2048-bit key) header.d=pen.gy header.i=@pen.gy header.b=GgLoChU3; arc=none smtp.client-ip=17.57.155.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pen.gy Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pen.gy Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pen.gy header.i=@pen.gy header.b="GgLoChU3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pen.gy; s=sig1; t=1722965339; bh=LQj4fNq3AjfFWvm1KyFJr4g623c+mzg/R005U5xgbCQ=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=GgLoChU35++XkkN3GrbT/kFEPqn0+lF1348CnCZKB3Eykr9KXn/sFabZsAPv1dvWi B3HaGziTQsnMKWOlGgwyJ+poXf1KIdF4OKt/Xwd6bAs3of4CHUKywGenIlkB9aUaGu z4L+sPGZxtR0nSQjtzw0atHUFKa2/jhabv9cUuX/gbUTOuTMwz/zgHTJ7zSv6w0ZJk QntofCX8B97QpiEFdUZyvKFybkIm+j3p6mFrAFgQyMmBFkyo5PJrMJjHsCW1bVryp3 IHrR3h9TJMSVFG8aIweC8XFXmHfs8yk+dBk77N7/tOK7oZBdetLHfur3RfPrCPFGbI jSPLgYy7Ow+Gw== Received: from fossa.se1.pen.gy (qs51p00im-dlb-asmtp-mailmevip.me.com [17.57.155.28]) by qs51p00im-qukt01072501.me.com (Postfix) with ESMTPSA id E8EDD440377; Tue, 6 Aug 2024 17:28:56 +0000 (UTC) From: Foster Snowhill To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Georgi Valkov , Oliver Neukum , netdev@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH net-next 5/5] usbnet: ipheth: fix carrier detection in modes 1 and 4 Date: Tue, 6 Aug 2024 19:28:09 +0200 Message-ID: <20240806172809.675044-5-forst@pen.gy> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240806172809.675044-1-forst@pen.gy> References: <20240806172809.675044-1-forst@pen.gy> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: 9ZlTGVy62X3C_iXbE3MKDXxwY5igPsOQ X-Proofpoint-ORIG-GUID: 9ZlTGVy62X3C_iXbE3MKDXxwY5igPsOQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-06_14,2024-08-06_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 mlxscore=0 suspectscore=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2408060123 Apart from the standard "configurations", "interfaces" and "alternate interface settings" in USB, iOS devices also have a notion of "modes". In different modes, the device exposes a different set of available configurations. Depending on the iOS version, and depending on the current mode, the length and contents of the carrier state control message differs: * 1 byte (seen on iOS 4.2.1, 8.4): * 03: carrier off (mode 0) * 04: carrier on (mode 0) * 3 bytes (seen on iOS 10.3.4, 15.7.6): * 03 03 03: carrier off (mode 0) * 04 04 03: carrier on (mode 0) * 4 bytes (seen on iOS 16.5, 17.6): * 03 03 03 00: carrier off (mode 0) * 04 03 03 00: carrier off (mode 1) * 06 03 03 00: carrier off (mode 4) * 04 04 03 04: carrier on (mode 0 and 1) * 06 04 03 04: carrier on (mode 4) Before this change, the driver always used the first byte of the response to determine carrier state. From this larger sample, the first byte seems to indicate the number of available USB configurations in the current mode (with the exception of the default mode 0), and in some cases (namely mode 1 and 4) does not correlate with the carrier state. Previous logic erroneously counted `04 03 03 00` as "carrier on" and `06 04 03 04` as "carrier off" on iOS versions that support mode 1 and mode 4 respectively. Only modes 0, 1 and 4 expose the USB Ethernet interfaces necessary for the ipheth driver. Check the second byte of the control message where possible, and fall back to checking the first byte on older iOS versions. Signed-off-by: Foster Snowhill Tested-by: Georgi Valkov --- drivers/net/usb/ipheth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index cdc72559790a..46afb95ffabe 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c @@ -355,13 +355,14 @@ static int ipheth_carrier_set(struct ipheth_device *dev) 0x02, /* index */ dev->ctrl_buf, IPHETH_CTRL_BUF_SIZE, IPHETH_CTRL_TIMEOUT); - if (retval < 0) { + if (retval <= 0) { dev_err(&dev->intf->dev, "%s: usb_control_msg: %d\n", __func__, retval); return retval; } - if (dev->ctrl_buf[0] == IPHETH_CARRIER_ON) { + if ((retval == 1 && dev->ctrl_buf[0] == IPHETH_CARRIER_ON) || + (retval >= 2 && dev->ctrl_buf[1] == IPHETH_CARRIER_ON)) { netif_carrier_on(dev->net); if (dev->tx_urb->status != -EINPROGRESS) netif_wake_queue(dev->net);