Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4414865pxa; Mon, 10 Aug 2020 08:33:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyGBU7h/w+itNG4V/hu1BEZSZPo5cdzdBKzWIgfckQEE/YOvsHxQmNf0BDQXWAopcMKRp1 X-Received: by 2002:a17:906:cc48:: with SMTP id mm8mr6363949ejb.292.1597073587667; Mon, 10 Aug 2020 08:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597073587; cv=none; d=google.com; s=arc-20160816; b=eVi5Oc6oCf0lEgwYxTK7FmTv4x6UHJA0xhVAQ7dERi8A7pYK0sKZfha5Jr7negzP9c KoD8S+Ef0bZ5XBk8q+i1woNfW7+giLG/7GYTIlNw5izM7NqO/QdpIz0/A7yE44E06+w3 +nJx0upC1DzcJrYcr+zqEvyYimzcya6OZM117+lqzm5Yx18L6lQWo2r0a8Up7XSGN3j1 oy1gkh+2k9l6GJwg2m5INGJSodwLITigYAT/pI58tPAjkDwqOJLFLt1g8nILXE7IHSpL kLMx7n0PX0lARVZ3TeIh7FktbcJq+pRh0ciyGzFyiPVD79MIUr/CgDlRO1tqYOurceI3 qE4A== 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=2wStpWCmF1nKo5jaMZ85xLvTGW31sB7rDImHgIMtkEo=; b=UCJKWGPcai4Xc35QpVpCY+LXv3s18fPbZvdunUfJLMi12X8ib8CdR0fNCyNU/ZojLp OJzxmnQUXlqiBIjZyRgbjHsP0d6iA92YDfXq6o1PtNFGCbnmxObwRuZdWv1b96vBAKaw WP1gfixYZjqhXBRVWnuoKF8kORNjvC6TadUEuL1g6OPvvIvgKvmr4xCFr0ipqyq8tZPk NWRaJgCujZTAhVZJQqsUgjcZVP3GaWMFMp8nV05Cg1jT27XHB8OFbpboZ68cAaUaOF9J HsXLvAFr9x34sLNdZd6UTUG7pd6F069KOaV09sC5IqC01qddgbwCGizWHhc5W8yq0fUD CF7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zIe6me2X; 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 y10si10783274edu.397.2020.08.10.08.32.44; Mon, 10 Aug 2020 08:33:07 -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=zIe6me2X; 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 S1728820AbgHJPaR (ORCPT + 99 others); Mon, 10 Aug 2020 11:30:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:36852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729057AbgHJPaI (ORCPT ); Mon, 10 Aug 2020 11:30:08 -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 515B422D02; Mon, 10 Aug 2020 15:30:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597073407; bh=fDdYFq/SQe2tJ7vYWkAx0BlXX8llaz1+AgIZh/1gISc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zIe6me2XlaAiUAcFWPB5+gykGIT//42FfXXcGT86GLgoNVjRfrEhCWFbB/Cy4Do8w Zh6VNOCdxni+ecHp6HkUgMNnkipWq0Y7QpDoRXee8KbjadIGsEfuLgYgnPIEEhWM/j 5D9sosqB9hfke3LWeJbXY2IRLmQXuQtWSb1EUzBA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peilin Ye , Marcel Holtmann Subject: [PATCH 4.19 09/48] Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_evt() Date: Mon, 10 Aug 2020 17:21:31 +0200 Message-Id: <20200810151804.669737314@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151804.199494191@linuxfoundation.org> References: <20200810151804.199494191@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 @@ -2360,7 +2360,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))