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: 817349 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: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: 817348 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.