Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp883028lqe; Sun, 7 Apr 2024 08:05:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbyGdZio1z7hj1w///dstpw0JeLkLVwMXezqnRYELad241FhLgdR97X6Ia4wFiQ3SGzOl+JXTFAKO6s76rwIv6LoBQrGjk67L4WtT2Rw== X-Google-Smtp-Source: AGHT+IGKkqzF5NcQSJrk5uJSteAI7As4skV6gfaHFSAfN6V3ny3vrdh4cAL8vu7EA92COSHhztsv X-Received: by 2002:a17:907:72c4:b0:a46:dd30:7cb5 with SMTP id du4-20020a17090772c400b00a46dd307cb5mr6142117ejc.76.1712502350482; Sun, 07 Apr 2024 08:05:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712502350; cv=pass; d=google.com; s=arc-20160816; b=wV4TBAjRV6cNZVTVekQoqobPdZZa2nSsvJVp0gPehSSAgoemBPw1MsQhJGQ+bUZ8lA t6ZPVzFxEdAMt6RDNuXDBKwQPxKAGVCD9YDzbOuGTsrYDbBVx46CbpLQuHwmRtCWcGau DjjJ/MfWydglbXP+fFXSgfVJ0CdliWIFKyAmvvOKwfS+ZCC5cycxm50Tsy6QVSqfRCYm MixAdqh5eXdhmNIzwdiRgWRg9c55xG7rmZBQBO5H7DE2vtJBVM5aKiMj3HKMZcLfDREw HzFjN/X+M1P5oRbAQ1P2Ai5ppFRtVdLPyFyudsuBb33b8C0WV69B1HSdO2GrA48tymGg 7bWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=3sBkxi3wTFHbQw86LYJrX78ERuXxplarn6YDXT3cVkI=; fh=yzBCkXhDFCqTdH+WHecR02QID38oz+/bYZzfpcJ7vvQ=; b=G6pKjnS6IXNNAsLFlMV0R3PJov7shVncLXiCXC2BOlWBUBuZkZ0sfXk3Ij2WOiHUCx JrK6TRoO+q+JRhM2QbDxY61L3A7mOpyeVY5Phgj00WVXhwgtbvbwVUCVvdl5L9kkZGQN 5vMHJHqAKNq+KyINmuRkrInPd1yrzFMCVwq+8DiRGToSR2FmxF70xnDKO/r/AWXig0fh sVNYqLAvg3Wd9SBPR47YJeh+mxQC6tE0wQmcyNDNCkeBCXPnf4vey+s9qw2yhCflANg8 Nn1N/pp4G5AK9Pzg/1eMlpam5UfuliDgedxC43kmSZgSzkwL+6vkbC5Y9e1TL2VINozZ 3owg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=fintech.ru); spf=pass (google.com: domain of linux-wireless+bounces-5957-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5957-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ov10-20020a170906fc0a00b00a4e70eec860si2736692ejb.451.2024.04.07.08.05.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 08:05:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-5957-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=fintech.ru); spf=pass (google.com: domain of linux-wireless+bounces-5957-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5957-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DAE101F21C89 for ; Sun, 7 Apr 2024 15:05:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C0C539AEC; Sun, 7 Apr 2024 15:05:45 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52082381BA; Sun, 7 Apr 2024 15:05:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.54.195.159 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712502345; cv=none; b=uqRTjsQ10qaZ8s6CM8gw1FIM39V/mDdDJpruCG3RO9sskHlXPAhbfbgWijCjCKGIjIwe/nnS8ewra7dv6uI8DwyXOAonqEZVMFN2W4B23CGrxCB8f6LFAkVXNC+fNsZYjVd6nLKplsOo27t0/MEWPFCBpFtt7ty7gWWZHKC8ces= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712502345; c=relaxed/simple; bh=LpwZ1iJe3PCZnokbYNZ30ihAT81Wpg3ltK08JbNfQUQ=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ntF9TxDkyJRegC/S9fihnakPB5ZhxhpOjP9ZFYcfFZyt2VGTHa0MODQKSRt/wlCvw4tA83FomUKTk78+i3+u19LRhChNhRahCSQNrmvqu/JyecEcYzXKdzvAaUTLSJvugtPej95+Tfv+s53pW/2XQnN/xCZ/8rQAG7dycjGQmNI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fintech.ru; spf=pass smtp.mailfrom=fintech.ru; arc=none smtp.client-ip=195.54.195.159 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fintech.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fintech.ru Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.159) with Microsoft SMTP Server (TLS) id 14.3.498.0; Sun, 7 Apr 2024 18:05:38 +0300 Received: from localhost (10.0.253.138) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Sun, 7 Apr 2024 18:05:38 +0300 From: Nikita Zhandarovich To: Kalle Valo CC: Nikita Zhandarovich , Wu Yunchuan , Johannes Berg , "Breno Leitao" , , , , Subject: [PATCH] wifi: ar5523: enable proper endpoint verification Date: Sun, 7 Apr 2024 08:05:34 -0700 Message-ID: <20240407150534.26737-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) Syzkaller reports [1] hitting a warning about an endpoint in use not having an expected type to it. Fix the issue by checking for the existence of all proper endpoints with their according types intact. Sadly, this patch has not been tested on real hardware. [1] Syzkaller report: ------------[ cut here ]------------ usb 1-1: BOGUS urb xfer, pipe 3 != type 1 WARNING: CPU: 0 PID: 3643 at drivers/usb/core/urb.c:504 usb_submit_urb+0xed6/0x1880 drivers/usb/core/urb.c:504 ... Call Trace: ar5523_cmd+0x41b/0x780 drivers/net/wireless/ath/ar5523/ar5523.c:275 ar5523_cmd_read drivers/net/wireless/ath/ar5523/ar5523.c:302 [inline] ar5523_host_available drivers/net/wireless/ath/ar5523/ar5523.c:1376 [inline] ar5523_probe+0x14b0/0x1d10 drivers/net/wireless/ath/ar5523/ar5523.c:1655 usb_probe_interface+0x30f/0x7f0 drivers/usb/core/driver.c:396 call_driver_probe drivers/base/dd.c:560 [inline] really_probe+0x249/0xb90 drivers/base/dd.c:639 __driver_probe_device+0x1df/0x4d0 drivers/base/dd.c:778 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:808 __device_attach_driver+0x1d4/0x2e0 drivers/base/dd.c:936 bus_for_each_drv+0x163/0x1e0 drivers/base/bus.c:427 __device_attach+0x1e4/0x530 drivers/base/dd.c:1008 bus_probe_device+0x1e8/0x2a0 drivers/base/bus.c:487 device_add+0xbd9/0x1e90 drivers/base/core.c:3517 usb_set_configuration+0x101d/0x1900 drivers/usb/core/message.c:2170 usb_generic_driver_probe+0xbe/0x100 drivers/usb/core/generic.c:238 usb_probe_device+0xd8/0x2c0 drivers/usb/core/driver.c:293 call_driver_probe drivers/base/dd.c:560 [inline] really_probe+0x249/0xb90 drivers/base/dd.c:639 __driver_probe_device+0x1df/0x4d0 drivers/base/dd.c:778 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:808 __device_attach_driver+0x1d4/0x2e0 drivers/base/dd.c:936 bus_for_each_drv+0x163/0x1e0 drivers/base/bus.c:427 __device_attach+0x1e4/0x530 drivers/base/dd.c:1008 bus_probe_device+0x1e8/0x2a0 drivers/base/bus.c:487 device_add+0xbd9/0x1e90 drivers/base/core.c:3517 usb_new_device.cold+0x685/0x10ad drivers/usb/core/hub.c:2573 hub_port_connect drivers/usb/core/hub.c:5353 [inline] hub_port_connect_change drivers/usb/core/hub.c:5497 [inline] port_event drivers/usb/core/hub.c:5653 [inline] hub_event+0x26cb/0x45d0 drivers/usb/core/hub.c:5735 process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289 worker_thread+0x669/0x1090 kernel/workqueue.c:2436 kthread+0x2e8/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 Reported-and-tested-by: syzbot+1bc2c2afd44f820a669f@syzkaller.appspotmail.com Fixes: b7d572e1871d ("ar5523: Add new driver") Signed-off-by: Nikita Zhandarovich --- drivers/net/wireless/ath/ar5523/ar5523.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/wireless/ath/ar5523/ar5523.c b/drivers/net/wireless/ath/ar5523/ar5523.c index 815f8f599f5d..5cac4a6452db 100644 --- a/drivers/net/wireless/ath/ar5523/ar5523.c +++ b/drivers/net/wireless/ath/ar5523/ar5523.c @@ -1594,6 +1594,20 @@ static int ar5523_probe(struct usb_interface *intf, struct ar5523 *ar; int error = -ENOMEM; + static u8 bulk_ep_addr[] = { + AR5523_CMD_TX_PIPE | USB_DIR_OUT, + AR5523_DATA_TX_PIPE | USB_DIR_OUT, + AR5523_CMD_RX_PIPE | USB_DIR_IN, + AR5523_DATA_RX_PIPE | USB_DIR_IN, + 0}; + + if (!usb_check_bulk_endpoints(intf, bulk_ep_addr)) { + dev_err(&dev->dev, + "Could not find all expected endpoints\n"); + error = -ENODEV; + goto out; + } + /* * Load firmware if the device requires it. This will return * -ENXIO on success and we'll get called back afer the usb