Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3687337ybv; Mon, 10 Feb 2020 04:43:13 -0800 (PST) X-Google-Smtp-Source: APXvYqwvsVS3xVnwJSEO2bw1XQBmzjKlRvcR7qkGDkSfkOXeJLQb+ljk9y9EGMV/hN8+cHYvtPfQ X-Received: by 2002:a05:6830:1db3:: with SMTP id z19mr936009oti.292.1581338593248; Mon, 10 Feb 2020 04:43:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581338593; cv=none; d=google.com; s=arc-20160816; b=F85t6Njvw4fWY+nF91w+rbJZHUpNSm8KQwQN1R8Nt8m7ws/5y0pYvuvG+7h4wWl3Z5 JE4ELsI8sBnNYhmr3lekr8PJCqOtBVb5u1aZwPr11trQ406AvCN1/h1bPVAhOWQeFPRR OptEs8FAuvogA4jwgfVsdIFZrTWrOH5jlCKVCLs08/afw0I6URGygZQvXxtqJcP8mV7u Q9NEqAmCYo6Lpi3Ct/8KoED3YgG3YzB11UHLlamQ3DFCG5a24klX7lu6tcMw6NtmnpkZ JrqXGKWdgSeGdHoi6l9G+GWWI/7Or4T81+caSF6YFoVM5LH20QR6AAiQHax4EDVQbtre 77nA== 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=fquSTwIJ1ke3+N3A4lZZwrufjTooYBxS/b4jWY5x60Y=; b=IxAvj256oAFX/bu7XO/Px3eu30pv0S7sM7upVDyM24UKzz/cEtaKYjmJBL1NxJondC 7wyJ2q2vzjgSirF2TD04ep90Viq2+UL5D/XemrNZlwKd5CXHsBmgIedWrUh6cn1j1Yhi QBAH4hJtELkbeHVa+iIMogX+ZhR5nlJU3/rSC5ZWWFP12c6bWgG2WkoIVkuo4yq0fwwB ZS6TW6YI1lF0pZHUCiI08VLZsO+hpxfv++DvcboPob4RJyoGozJQy3nW2KO3tJOZceSD AaiA80L5Goo/TVA1Qbksl+GxsUrsFa36JaraeCD9XpzCbTzv4UWr70s0BmCEO8Bm3UCK yNRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GU79WdWN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w29si136924oth.313.2020.02.10.04.43.01; Mon, 10 Feb 2020 04:43:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GU79WdWN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730361AbgBJMm5 (ORCPT + 99 others); Mon, 10 Feb 2020 07:42:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:38162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729060AbgBJMjn (ORCPT ); Mon, 10 Feb 2020 07:39:43 -0500 Received: from localhost (unknown [209.37.97.194]) (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 EE07724682; Mon, 10 Feb 2020 12:39:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338383; bh=17MaOto3qGiNDsjCGWj6Y/lMgIC4o3kD41TiSnZ/HA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GU79WdWNvNMxVoCoAkaB22oTxGS28JEiXelAJcCDttlb32m+YLlfxViV1lWON3CZK wfiFtvFxz+iCoUcSIPFCllZutqTWXJyJlcngYRa//2WQfK5zWisIzLGwrUQsm5aeTB 0HcP5/oZMjeQRJ0+tNEhiksHOmgBvF966LtZX9T0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Neukum , Lee Jones , syzbot+48a2851be24583b864dc@syzkaller.appspotmail.com Subject: [PATCH 5.5 028/367] mfd: dln2: More sanity checking for endpoints Date: Mon, 10 Feb 2020 04:29:01 -0800 Message-Id: <20200210122426.499313249@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@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: Oliver Neukum commit 2b8bd606b1e60ca28c765f69c1eedd7d2a2e9dca upstream. It is not enough to check for the number of endpoints. The types must also be correct. Reported-and-tested-by: syzbot+48a2851be24583b864dc@syzkaller.appspotmail.com Signed-off-by: Oliver Neukum Reviewed-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Signed-off-by: Greg Kroah-Hartman --- drivers/mfd/dln2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) --- a/drivers/mfd/dln2.c +++ b/drivers/mfd/dln2.c @@ -722,6 +722,8 @@ static int dln2_probe(struct usb_interfa const struct usb_device_id *usb_id) { struct usb_host_interface *hostif = interface->cur_altsetting; + struct usb_endpoint_descriptor *epin; + struct usb_endpoint_descriptor *epout; struct device *dev = &interface->dev; struct dln2_dev *dln2; int ret; @@ -731,12 +733,19 @@ static int dln2_probe(struct usb_interfa hostif->desc.bNumEndpoints < 2) return -ENODEV; + epin = &hostif->endpoint[0].desc; + epout = &hostif->endpoint[1].desc; + if (!usb_endpoint_is_bulk_out(epout)) + return -ENODEV; + if (!usb_endpoint_is_bulk_in(epin)) + return -ENODEV; + dln2 = kzalloc(sizeof(*dln2), GFP_KERNEL); if (!dln2) return -ENOMEM; - dln2->ep_out = hostif->endpoint[0].desc.bEndpointAddress; - dln2->ep_in = hostif->endpoint[1].desc.bEndpointAddress; + dln2->ep_out = epout->bEndpointAddress; + dln2->ep_in = epin->bEndpointAddress; dln2->usb_dev = usb_get_dev(interface_to_usbdev(interface)); dln2->interface = interface; usb_set_intfdata(interface, dln2);