Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4422726pxa; Mon, 10 Aug 2020 08:43:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/O05wPZ4Ay2V80guJdIdgsh10C9HUri4eQKv06az+Yzc5GXynw4Alw1zN4BVwwojDn3Hq X-Received: by 2002:aa7:db0f:: with SMTP id t15mr21987272eds.359.1597074228499; Mon, 10 Aug 2020 08:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597074228; cv=none; d=google.com; s=arc-20160816; b=M3aTQWvFCl5QOD5Q3KVL20BAD2zfN1TvHNqHro5rxhYcshDClBP+WQ/4lwi2twmWI/ m5lWviItj37jWeWAN7+EE1afOZb75Pc2wYUHhbTGSN4G/k1BPMbCQrEavEC3GQKR/+xM QHrUfy0pX6u3WScL4YD6pgLq21xkZipUpkbQ9xz1oJUByuTVPcUz/YEe7ODNeJhlonkZ ants73zvma21cqjZn6+nYHA8ORlS9isy1JhK3d2EPGqwcOszms0WS7WpnR+ZiUkF0Tg1 ZgUhYE6V6eTllZfE+Xoto8Kqxa0ZFY2rGn04Zv7pLAsrZhoVApB7A3olfWcDCEwhKRy3 7jmg== 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=86tFO+Buq7Hm7PRSDYKxr3vkDE+ZdJvKuPgVAvk5VAI=; b=VbpCbcP4l1gwxJ7/K9LIHtcKOI3i5xM9OH7EdWsHHG4HZHFA+xx3XCwrV1HF1CFFBk eOdPtOUgOGJ3ZUZQ1z6Z+3byE6XJaQamglzuWnXfjmIXDi7TfitCduV0L7P+4APMWoiB Rp3abG4YpKMeBaCDoBVIcGQUS0r42jV9Z3xEKrpArLWDvRjvkkePozjM1B18qGmDPyCs QpufH/MOlq8bhgCJqJ7SXIrc3K+0CMheKI/J660NbUgcV39cqVkUNpSejqzu+i4BusN9 kJMHQ67aBC0bvf3bAZlew13qLxSKCkiFWr61UFjVE0FieiLIbFGBKuWZhYi9gtsjqvKs aLKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y2ibPtoI; 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 jp21si11107116ejb.136.2020.08.10.08.43.24; Mon, 10 Aug 2020 08:43:48 -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=y2ibPtoI; 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 S1727813AbgHJPTp (ORCPT + 99 others); Mon, 10 Aug 2020 11:19:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:49816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726888AbgHJPTn (ORCPT ); Mon, 10 Aug 2020 11:19:43 -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 3C0EF208B3; Mon, 10 Aug 2020 15:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597072782; bh=ObeMnJtvuTjudlZUs723OLhFqebQrx90QRCQCLjYZbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y2ibPtoIOysL12xO+XtV6nw70Q3Xt+OEGaezsulNDQiLQ7YRupr99brjBdW/hGMp8 bBl8b3e7cZ0351Q1J+ZgWC6+LmJI+ISA38Eicyd5/WsXJ0zfIzuF0TKZ0nZd+LSb+b OAIqnjJdT3IKpokHHs8VWttOrqyTWygREcPx8BxQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peilin Ye , Marcel Holtmann Subject: [PATCH 5.8 16/38] Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_evt() Date: Mon, 10 Aug 2020 17:19:06 +0200 Message-Id: <20200810151804.689831155@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151803.920113428@linuxfoundation.org> References: <20200810151803.920113428@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: Peilin Ye commit 75bbd2ea50ba1c5d9da878a17e92eac02fe0fd3a upstream. Check `num_rsp` before using it as for-loop counter. Cc: stable@vger.kernel.org Signed-off-by: Peilin Ye Signed-off-by: Marcel Holtmann Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/hci_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2520,7 +2520,7 @@ static void hci_inquiry_result_evt(struc BT_DBG("%s num_rsp %d", hdev->name, num_rsp); - if (!num_rsp) + if (!num_rsp || skb->len < num_rsp * sizeof(*info) + 1) return; if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ))