Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3564702pxb; Mon, 24 Jan 2022 12:19:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsI3fLVM2WFyn31JtLq0h5B3dFvpZRHg6QgJH6s94AiPrfO3plu6T+aWCQrUVHT2Q1FRlv X-Received: by 2002:a17:903:2443:b0:14b:2af0:a1d3 with SMTP id l3-20020a170903244300b0014b2af0a1d3mr12448176pls.134.1643055473645; Mon, 24 Jan 2022 12:17:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055473; cv=none; d=google.com; s=arc-20160816; b=Eb7mMfvMFW9FGW2GJchB0ctDbg6hDwMuCXAa4UG0pCCwrBHHxhjV58EROXIX3Sq1os p5yFUCSOruooq7Jk728hyB4xYisDh9O5rIlm2um9D2lzmiOClE4NS/GehTALheHmKCfE vIAZJ9dI4vtfMcSFjdrkgw+/bd82NPYDn3yFQFv2kOGKVEYxHr/oFMiSUMK5pm2hkDZr 6slwsNLaRxoCecSy2oefhuEbmWi42IFNdwvOERwmXEbCjj8GTM0Emi1NtciUOK0fc9xW +qp8Z2hRz5/bDveYp879eo1+QzRdsCHsr7YkmL3WY7jo2oYX0SjhqDHp6esjT6wN+dpO RwIA== 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=IwMw26/LDnsc1kjbN0hNnT4a8ER80JRZuOz7vd/ZKMY=; b=I+CrWWAWLxbsgY4FZAyAnSDAelStUKGxsjWQEN1WVUDzzPZb4VirAiYvTnaUO2a9K3 MicNn02IcZt3lAjAg6JoPqhN2B5BRB4Qz04PpRKUCz5icidTywlAEXI69IRmntpLuOly hySjLempc9flTKJ/1VOKEtUDQDvXDZWOiCgoOqQG75d8OC9l1yYaszf8DjytYrjhoFYK z1l1gi9RSwoTKBkUoWQmgBBDYUiMcTijQQPVj2CGqFnASECaLeeKe4cJjFDnbv+QOXR3 uTJVTGbWjUD0PJ5MLNeUPBWE5UhCp+Me+HoZq2JBrTODZ5//GX0nU7bs2x5sHOSEXVgG TakA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z+qlmu2O; 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=pass (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 b20si310156pjp.15.2022.01.24.12.17.41; Mon, 24 Jan 2022 12:17:53 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=Z+qlmu2O; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349078AbiAXTUM (ORCPT + 99 others); Mon, 24 Jan 2022 14:20:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347772AbiAXTLI (ORCPT ); Mon, 24 Jan 2022 14:11:08 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5569AC08E877; Mon, 24 Jan 2022 11:02:39 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EE363B8119D; Mon, 24 Jan 2022 19:02:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A227C340E5; Mon, 24 Jan 2022 19:02:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050957; bh=CBPENbkco7iWTiGBptNuAshMijpXyfLZVEct9/ZpMIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z+qlmu2OIvbUmYBk9+ewZdVqnUV/bpbkWt1M4BODtxeJCSifctJJpZs6mbA0CoLRh 3WEGTJcblWkrxdMXyYBv4X4+QK676wyySMVRSygJHQfMI+RnAwbHE/R3hvEJ5ro2QC 70YutqK/d28dIcs9JAMexXIJMTvdBXQbins818Ws= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Marcel Holtmann Subject: [PATCH 4.14 001/186] Bluetooth: bfusb: fix division by zero in send path Date: Mon, 24 Jan 2022 19:41:16 +0100 Message-Id: <20220124183937.153147463@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore 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: Johan Hovold commit b5e6fa7a12572c82f1e7f2f51fbb02a322291291 upstream. Add the missing bulk-out endpoint sanity check to probe() to avoid division by zero in bfusb_send_frame() in case a malicious device has broken descriptors (or when doing descriptor fuzz testing). Note that USB core will reject URBs submitted for endpoints with zero wMaxPacketSize but that drivers doing packet-size calculations still need to handle this (cf. commit 2548288b4fb0 ("USB: Fix: Don't skip endpoint descriptors with maxpacket=0")). Cc: stable@vger.kernel.org Signed-off-by: Johan Hovold Signed-off-by: Marcel Holtmann Signed-off-by: Greg Kroah-Hartman --- drivers/bluetooth/bfusb.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c @@ -644,6 +644,9 @@ static int bfusb_probe(struct usb_interf data->bulk_out_ep = bulk_out_ep->desc.bEndpointAddress; data->bulk_pkt_size = le16_to_cpu(bulk_out_ep->desc.wMaxPacketSize); + if (!data->bulk_pkt_size) + goto done; + rwlock_init(&data->lock); data->reassembly = NULL;