Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4879106pjb; Mon, 27 Jul 2020 07:27:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6jjLCUZFYAWeiGhZ0Uq+B/tfKC8zJS6IOKDnyyoL7WgPaS0VKN5biYOTmNh+d+fI2G19r X-Received: by 2002:a17:906:b2d2:: with SMTP id cf18mr9485608ejb.551.1595860025985; Mon, 27 Jul 2020 07:27:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860025; cv=none; d=google.com; s=arc-20160816; b=E3VbbHvVXnz/lmnqFDbjin5uORdEoCt8CKh866mo8wes4vS/H1E8OY234eS39HDaYH 6wqFxTtC4E3f3HwmSauVuh6WjSFtdc8AZuacDeUFumGdtqwjbl3yLw23oBTaMDpGIF9a 5alenWe85phmQ+KnH4g/kYM2tMOjXzp7dw4iLg+pCnL10jOj6PjXe+AEMAoOZiYXZRpd cyemnvOYIjcupasZBdYSCAsxPninPw1FmVRCA0tjfUouQGeF0kSiNb55PccKI/u4SD/J z3o8V2N8DVkxGPAwfwwqm5Lpr2xfpK/pxL0Iblu8kEdQ4jBV/BoJp2cres2rGN53UIW5 I3Lg== 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=TSYs0tkhV0XmWT4ImEJg7HizaPyMSh7R5K2xDTI6H3yKrP3kIg2EK9a05fBI6z2n3T rGZ75xDjuicqL1n1JtBF2ctyLflNN/zyBMVFzWo06+jYdHnUnJMKDkVp/CNw6h86ar8a gb1/AKx/Zj1hzVLPuEtV9yDc7ck5WRZ2TGSJhn1WmiogAzg+hAtZbI4CJnGVwBEqpGwG bkHKA4g0TeibRE5PQK0wspjHSAgO+UVA498LXaszLcwXZpe4nP4BdH6tecNNors4HCN+ EJ5+jUwsTC1QfPYF0htoDY3QttlNT9XfJGmYy5JEHC3z+3upTBAqwfszhBJkhXO4lkVb ajoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sWYfBCgV; 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 n1si5621601edy.409.2020.07.27.07.26.42; Mon, 27 Jul 2020 07:27:05 -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=sWYfBCgV; 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 S1732346AbgG0OZA (ORCPT + 99 others); Mon, 27 Jul 2020 10:25:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:54702 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732314AbgG0OY6 (ORCPT ); Mon, 27 Jul 2020 10:24:58 -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 CC21C2075A; Mon, 27 Jul 2020 14:24:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859897; bh=5MbtI0ihvkEoxI9SWcTbrLH2vIzaHkcSMuxKD1ckyRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sWYfBCgVKvvtDKfyvDn3j1yzX539D67dfnoG3QLxHljdl0CFkDn1rrby0VCocJ4GF d6lNBtqGmSUxUelgukc+4aRAeMlJxpvTAESlH+cChXSzd5r/ej9R9gZzEnv+nLD1sm pjEcyR3YZUmqYE4Pz5pmIAHl02TKA8aJlBOk5p/g= 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 5.7 146/179] staging: wlan-ng: properly check endpoint types Date: Mon, 27 Jul 2020 16:05:21 +0200 Message-Id: <20200727134939.777363116@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134932.659499757@linuxfoundation.org> References: <20200727134932.659499757@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) {