Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4888174pjb; Mon, 27 Jul 2020 07:38:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMHbdH6agq+JK3QKTNEtVX2ZK7NUX8jprdLxfrVTK/Zp1Bmw1hvIixWjQ2jTgvJKyJwmGH X-Received: by 2002:a17:906:af51:: with SMTP id ly17mr9365987ejb.81.1595860738936; Mon, 27 Jul 2020 07:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860738; cv=none; d=google.com; s=arc-20160816; b=xxe6pxcMBmO5sDR0Cz4bwZaf9VyCyWc0Q2Ykc9/DZAVbyuJLPlwHDIlSEy4j/kyxIj /+bB37gzMa4YZusJsy9jL4upbsGBDJoCFe+B93kv8T8Jx5BX1umaTlWKNq0JzfLUUwI9 K5sDykBbfdBUp4lkUmPoRc8lYWbQHMw2GYt/B+lDLuw+AuW5IQl2zx6f6CMLJUa3UhLf ZsaOTdHib6KDMjBsMz1iABDwlX+mkJv+Y9XgY8CMzMwDL6xgZG9OkX9T147GBJPyvX/Q OxJwZaFDofyrK+xW/ARBzhOh1QEAsR1YYElqusWPPA2ZurVvUQqedIIBCGDjnAId2jfK 58DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AGlHmEKNRzpWYjPuh60hJgwN49RM0xXwIGX1/88Dogo=; b=oVqE37DCKVhr3NPALULwXOyx/OGz7SgyAo1ool4SgzkKP8EfxLn4l4lPC/QpPhGC9/ l2czd6Yc5v8x8ahvAWhUnFQLeb/7hjQt/cLqC+VhN3qfIUasBhlPZFfTQYh0UqPBhBYQ kwQc1UqJqM/hZM0Ce8acw73lObbHgtfWAmmqB9+UpvT7FhBqdscOzP4r/chQI0Dj9DRn 2HiAkfvOLQncW2jcb8ChssmpS+CwWqrV/TmVIBS8UAvIaeWZC/OmrEslQAXCqWURfw5y 47O7785eybsYns0j+/hPnAT8OCoOUfsDgVt4cffxwyjRGBtLcrijBGw5BwLKJHprx9X/ KRig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y2oCgmDB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di16si5562948edb.397.2020.07.27.07.38.36; Mon, 27 Jul 2020 07:38:58 -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=Y2oCgmDB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732947AbgG0Ohc (ORCPT + 99 others); Mon, 27 Jul 2020 10:37:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:36820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730207AbgG0OMa (ORCPT ); Mon, 27 Jul 2020 10:12:30 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 C4E472083E; Mon, 27 Jul 2020 14:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859150; bh=5MbtI0ihvkEoxI9SWcTbrLH2vIzaHkcSMuxKD1ckyRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y2oCgmDBuruF3efKtxjRZuLaM0VzEEigoN07TioAXvwipStmSN5WU2GBPzBa5bWNs FuCzyfooVupvcPnDz6FBhBX8OqLv6jSjaVrFrHoijTYd3b3ypxlEy+Y/yTyYVxh6eF wW3HDaCZZeyuAfnsdPFzRsvFcxAzjq7JcZZlDfb8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rustam Kovhaev , syzbot+c2a1fa67c02faa0de723@syzkaller.appspotmail.com Subject: [PATCH 4.19 65/86] staging: wlan-ng: properly check endpoint types Date: Mon, 27 Jul 2020 16:04:39 +0200 Message-Id: <20200727134917.687322916@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134914.312934924@linuxfoundation.org> References: <20200727134914.312934924@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rustam Kovhaev commit faaff9765664009c1c7c65551d32e9ed3b1dda8f upstream. As syzkaller detected, wlan-ng driver does not do sanity check of endpoints in prism2sta_probe_usb(), add check for xfer direction and type Reported-and-tested-by: syzbot+c2a1fa67c02faa0de723@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=c2a1fa67c02faa0de723 Signed-off-by: Rustam Kovhaev Cc: stable Link: https://lore.kernel.org/r/20200722161052.999754-1-rkovhaev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2usb.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) --- a/drivers/staging/wlan-ng/prism2usb.c +++ b/drivers/staging/wlan-ng/prism2usb.c @@ -61,11 +61,25 @@ static int prism2sta_probe_usb(struct us const struct usb_device_id *id) { struct usb_device *dev; - + const struct usb_endpoint_descriptor *epd; + const struct usb_host_interface *iface_desc = interface->cur_altsetting; struct wlandevice *wlandev = NULL; struct hfa384x *hw = NULL; int result = 0; + if (iface_desc->desc.bNumEndpoints != 2) { + result = -ENODEV; + goto failed; + } + + result = -EINVAL; + epd = &iface_desc->endpoint[1].desc; + if (!usb_endpoint_is_bulk_in(epd)) + goto failed; + epd = &iface_desc->endpoint[2].desc; + if (!usb_endpoint_is_bulk_out(epd)) + goto failed; + dev = interface_to_usbdev(interface); wlandev = create_wlan(); if (!wlandev) {