Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4420037pxa; Mon, 10 Aug 2020 08:40:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQZD+EtYN45wZPWrEFBorRwt/mq+De8oBTEbYEW53WQgry0SxL1AFxokXSxiRx27pLjuN/ X-Received: by 2002:a17:906:e0d:: with SMTP id l13mr23275816eji.434.1597074002416; Mon, 10 Aug 2020 08:40:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597074002; cv=none; d=google.com; s=arc-20160816; b=vu0+jWQHLrNdFemVhT5VrOLKW2q/FFPvr1CzBdASZsnt3HA+/AHp9+9da7B4BzrXJa 04zT4O4Px5nzh6T/9Rv4GUHxpATb5aE7fyCpF72Xt/3XXL/TSEdClTQp+dQtLexz+JAs pzapGD2skWz0EcSgUpu6AQ6xCvxbTcTFvl6BwouYbvUV8RJOlRgu0dQaG5x8CTMV+2QE 1E1CHM5a7gJTI7HSIj8BL89M3q08WWJbhJdJAvIX+boFyrw45EkUaLFH5BBoRlNmUTJY HQ5GKtC/zhZbTqRDOiMcR6BK8d7xZc8NnERBE9AbhoIoJCNZGAEn7AhOIe7/99q2+sS8 Y8PQ== 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=+OJkkF2EhywMvUOc8ndPK2cCYlJDg4ig9FO9w7imtqw=; b=WpARQQP7mQSpHOBk2Xojy5HyDRK0vb5XNVRX7WNflxTtd6Urjmaj8PX1vLBcfmFeTC AykdkfrbdXFHbUGqrKtRm9zCoX4icTLAw8Xdl0pbcrXJLKqn1qtvH97RW1wg8rYpUUwZ g8+aTjUVG5xIktS1EvkQ4ECFSR4Svcwxp6XkUK3vUcA1SNILP2F2p37K/rf6uPNjhlh3 yoK83Mg7oR/AV/84/tHqqsU6OrEaF5DADFv8JkZsaCXymvmcLxCPFbkOX33nfBBBOhEa 3B31iQnT2C/opuBEm/3INPxqDzk212HZxMwI1xcNucT0CUgA871xdbPMPQvUoW1s1ex7 HZGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O2uK+9jH; 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 x2si11040827ejj.386.2020.08.10.08.39.39; Mon, 10 Aug 2020 08:40:02 -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=O2uK+9jH; 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 S1728076AbgHJPhO (ORCPT + 99 others); Mon, 10 Aug 2020 11:37:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:60442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728640AbgHJP0c (ORCPT ); Mon, 10 Aug 2020 11:26:32 -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 8C09E20772; Mon, 10 Aug 2020 15:26:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597073192; bh=PsV4Wdex9Sq7veb+qcwLect4hPlK6NbXRYPPW/MCsLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O2uK+9jH2gejGmFeM0YodMh8lIbqBr22+lBkFdgs8Jx+s2MvWe79y0sEPPBGXIlo7 XHbrBAlHw7R5i1LXyVAiCtfn+iQx6E9of3AyUEAwOb5dWcXAf27rQlERfVUCXRrhRd yKSXTgyqyB4FdtfIa6t55wQMu3gJSVB3XaOVw1ZM= 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.4 19/67] Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_with_rssi_evt() Date: Mon, 10 Aug 2020 17:21:06 +0200 Message-Id: <20200810151810.372729922@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151809.438685785@linuxfoundation.org> References: <20200810151809.438685785@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 629b49c848ee71244203934347bd7730b0ddee8d upstream. Check `num_rsp` before using it as for-loop counter. Add `unlock` label. 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 | 7 +++++++ 1 file changed, 7 insertions(+) --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4067,6 +4067,9 @@ static void hci_inquiry_result_with_rssi struct inquiry_info_with_rssi_and_pscan_mode *info; info = (void *) (skb->data + 1); + if (skb->len < num_rsp * sizeof(*info) + 1) + goto unlock; + for (; num_rsp; num_rsp--, info++) { u32 flags; @@ -4088,6 +4091,9 @@ static void hci_inquiry_result_with_rssi } else { struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); + if (skb->len < num_rsp * sizeof(*info) + 1) + goto unlock; + for (; num_rsp; num_rsp--, info++) { u32 flags; @@ -4108,6 +4114,7 @@ static void hci_inquiry_result_with_rssi } } +unlock: hci_dev_unlock(hdev); }