Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3730785ybv; Mon, 10 Feb 2020 05:28:04 -0800 (PST) X-Google-Smtp-Source: APXvYqxp2PHLemOYVVrprBd5X+/93Ne0OsrgKgiu7ffelO6p07ZVRqCMF9jerHVAKTuydA8B6Qau X-Received: by 2002:aca:1b17:: with SMTP id b23mr822978oib.95.1581341284564; Mon, 10 Feb 2020 05:28:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581341284; cv=none; d=google.com; s=arc-20160816; b=WA5fscNns9wtiJkauUPpjb8c1JV01GsRNVgKeut7zsdXIJohsOn+4lCZzD4HSYaVYV 9oLW8QkhzoLi3IcN432WFrXTjf4Wmbq1VQT37eSBSCn7AObAQJfIQdzASYAc+VBY3yp4 ivh5UG0IFVTNrOs7uyZrciI0hvM9RiQuMPW7dh0z+y0J5M1lNKC5ZJsrmaNIQ2cvPta4 kTgUHkGIuf2Fi4xxelpiriHu2S0PKGIbGINhP4aWo+c34uFQaVUd42burYECW659XS58 pghut5Gmp1sxl8AVM0KovwkqB4eThPzogZljEgsrD1uz1XHl4Lu6oDzQw9sm5bRjpDKs wwYA== 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=HsSQ6QPfDmDdRCYXfHZFMq8QWHXwm7fMJ5QwAbCzMNtg83jqLKUR/PYcyOD0n3UhgV glHiouhaTxOYb2sz3s91XHslYjLqKLtrRFFUnVj94XA7St5FNO5X/QNi10ySV1kNu+Nn 1Occd5HmfOicwoOEvcRev/gIkHFlugU+abg7EIYsXAs15wnL3Rn+qh+Z5uQxhgYtuPGI RVv6RV1fMnIjnS7whb0mXUbKDyc5o9sMKrTPBMNoghwaci/biuM6lb99+XFlzjcLrVEg gjwjFp7cfBb8cjNCdZUtXOHTV6DuLR1q25rloj0WiROuLSVd716p+aZUwFlwGN/bX7MB 9LkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qTzYObC7; 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 k19si179731otp.33.2020.02.10.05.27.52; Mon, 10 Feb 2020 05:28:04 -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=qTzYObC7; 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 S1731210AbgBJN0f (ORCPT + 99 others); Mon, 10 Feb 2020 08:26:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:56700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728503AbgBJMgp (ORCPT ); Mon, 10 Feb 2020 07:36:45 -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 9F9A42080C; Mon, 10 Feb 2020 12:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338204; bh=17MaOto3qGiNDsjCGWj6Y/lMgIC4o3kD41TiSnZ/HA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qTzYObC7270Nz58CMmMxUHk1o0Az1Mk0v7Vf5ZP4EBZ5pn6lzzHUSHcN4sH+ydGBg DpOpeNfIUCIzpdADNYFlTHn4ICNa+RUZAdgC6Js6gdF4NYN1Yf4GlY8BnpcFuji/gJ fkzZA4SaEYbsLkXdtvxNeaj8Yctd1olLjsTDnTHI= 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.4 023/309] mfd: dln2: More sanity checking for endpoints Date: Mon, 10 Feb 2020 04:29:39 -0800 Message-Id: <20200210122408.223606021@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122406.106356946@linuxfoundation.org> References: <20200210122406.106356946@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);