Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3300891pxk; Mon, 21 Sep 2020 10:04:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh8xoSQt1bN1+N69YR/7tYc36rhUNDzvg0O8sYJvXqv2ldXlvcnTVMHrZVxzF7Ww8WoW+z X-Received: by 2002:a17:906:a293:: with SMTP id i19mr426560ejz.428.1600707843476; Mon, 21 Sep 2020 10:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600707843; cv=none; d=google.com; s=arc-20160816; b=i38NzXc7hHeerJr8SGtzPzADVSFtRRi/9pmhV/XNApT4cuNdVD8JMdvnB+FsLh529c NdOcKIAdl+hiQDfWl3JazR/gUNKD7XiOdP148wmjLFZ+wafaK5P8z+AjRUr4Chn8Jcp5 umy1K7RAA1WJMyFH/kqKsV3O+ijdDvzlhgw3+s93oVs7Mgh7UN13vj4ODtNRGHvSxbke vdIsjejhw4Tb6mWeQoGqvwGNzo92G6EjvHvZPtYIcYPggjCGbNIabf4rJ8ttfxmfm1SQ WvxW6jsxLjSqdmd9uopSzaQgF85jxLgsYFGqE8bFbCbEOKcZ/H+4moxeTclIM3CoVNf8 E0ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Fe9v0GGf5lNqBMUXUQMuJ88DX76knSEor9Ve+vsOG8Y=; b=wKCEE51BAaPFvwhVLy15zAKfzMq4/cKY+SI+SjEf3WbIMKGKrL+lMt/XiWBXjx/fpI I5DWxQ6nj/CjdEdb+tk7SMgzJ+iGjWxLy/dihVdZoXWFW9Uafix+2fKk6i1jNIYzvgzr xcrRPel0RUg4hYVLFHr8y9zilNe0a/xbmlCcYNrABztENjHhH5FMoZHxflRHXwqcVCoW jawsZTTiJ15a9AR+kbj8QtMEowno2HNXcp1Jy4JK69CqCvkm8AdXrsouIX03k3v0iuvP SB9W77+blXi6Ok2SZG9Ddscp6Pr3hzmyPB23iJeq6coO+4PtSVOHO8p1632YGxYBP9aa xvGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g2X374Ll; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk26si8653500edb.60.2020.09.21.10.03.39; Mon, 21 Sep 2020 10:04:03 -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=g2X374Ll; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730066AbgIURCm (ORCPT + 99 others); Mon, 21 Sep 2020 13:02:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:38898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729079AbgIUQiC (ORCPT ); Mon, 21 Sep 2020 12:38:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 4F8EC23998; Mon, 21 Sep 2020 16:38:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706281; bh=z+NouoqugXH7OWzLCOseSUx2VX5kkjXvjD5EupAtSow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g2X374Lld6C109XPC+6qIEWKomrQAVkE27ULCCTwoPa6GA4S6WPRy2yrnuxbCU0kO WuvxRRQSUtoWYNprFmpGP1c2yHbV0Qahhe3DCRVprIhqpXqyAKkv3w+M6vbX2gBiXQ 4/fl8E+tpX9IydqXuWKv4JQOZonEibETdY7oTnIk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rustam Kovhaev , syzbot+22794221ab96b0bab53a@syzkaller.appspotmail.com Subject: [PATCH 4.14 38/94] staging: wlan-ng: fix out of bounds read in prism2sta_probe_usb() Date: Mon, 21 Sep 2020 18:27:25 +0200 Message-Id: <20200921162037.292736558@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162035.541285330@linuxfoundation.org> References: <20200921162035.541285330@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rustam Kovhaev commit fea22e159d51c766ba70473f473a0ec914cc7e92 upstream. let's use usb_find_common_endpoints() to discover endpoints, it does all necessary checks for type and xfer direction remove memset() in hfa384x_create(), because we now assign endpoints in prism2sta_probe_usb() and because create_wlan() uses kzalloc() to allocate hfa384x struct before calling hfa384x_create() Fixes: faaff9765664 ("staging: wlan-ng: properly check endpoint types") Reported-and-tested-by: syzbot+22794221ab96b0bab53a@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=22794221ab96b0bab53a Signed-off-by: Rustam Kovhaev Cc: stable Link: https://lore.kernel.org/r/20200804145614.104320-1-rkovhaev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 5 ----- drivers/staging/wlan-ng/prism2usb.c | 19 ++++++------------- 2 files changed, 6 insertions(+), 18 deletions(-) --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -531,13 +531,8 @@ static void hfa384x_usb_defer(struct wor */ void hfa384x_create(struct hfa384x *hw, struct usb_device *usb) { - memset(hw, 0, sizeof(*hw)); hw->usb = usb; - /* set up the endpoints */ - hw->endp_in = usb_rcvbulkpipe(usb, 1); - hw->endp_out = usb_sndbulkpipe(usb, 2); - /* Set up the waitq */ init_waitqueue_head(&hw->cmdq); --- a/drivers/staging/wlan-ng/prism2usb.c +++ b/drivers/staging/wlan-ng/prism2usb.c @@ -61,23 +61,14 @@ 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 usb_endpoint_descriptor *bulk_in, *bulk_out; + 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)) + result = usb_find_common_endpoints(iface_desc, &bulk_in, &bulk_out, NULL, NULL); + if (result) goto failed; dev = interface_to_usbdev(interface); @@ -96,6 +87,8 @@ static int prism2sta_probe_usb(struct us } /* Initialize the hw data */ + hw->endp_in = usb_rcvbulkpipe(dev, bulk_in->bEndpointAddress); + hw->endp_out = usb_sndbulkpipe(dev, bulk_out->bEndpointAddress); hfa384x_create(hw, dev); hw->wlandev = wlandev;