Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9042297pxu; Mon, 28 Dec 2020 05:13:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJycDoIHhw+9yjbyRZK/1KF7koapDJb2wp2CQ8/orPZeKueIWQUiwJ/vlnDH9XBpPsds0P1c X-Received: by 2002:a05:6402:a52:: with SMTP id bt18mr42549100edb.228.1609161198147; Mon, 28 Dec 2020 05:13:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161198; cv=none; d=google.com; s=arc-20160816; b=fx75UKn5BK0Lzp558WMC7PnAgCfO5AdA5sI33b/WG8Soads5rzzHUHZbnUIgHabxk4 NYTE3ltU8LUrtKCNmnRq52POFWwlCIQLSlcRlWvMGWZP8i+QKRI8B1PhAuH6mqHXufIp M3ospXngoSm1VLesfnZKr/FdNfASDe+mHRqoUFRa+UW/Ikm3iopJkouB863thoOHRHbJ gVgYwA/7oOTX8NsqRlU0V0sn3ME/OpCPBJIr2BeoVTroZ9Z5C8T6enI9cnINfMLfaAB0 R8diAIL/IziRoNXzkd4qhX2dAEJEMn/KMi7z2DUb7mVb4egzXYjxx2uf2v52eC3JCyEz 0/tg== 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=RbUSH2dthjWXNp/AAEFqvEXlV4hYeJ9mMki920+UeaY=; b=axedktbAF0osWLvVNXTSxFrQCSdOHmNe8Qf+1OoeEMbL9XxuZxIpjw+stC9D+z2a4N eVBZbts31jQz9Bxa/Si6ZlPWitZrwewlHY7i73AcM0oDtFh4o5S4lUg/wADzIR7ykKrl 1sEdfAQ8I+9rEyCes+XhrF9UtA1jafE5VabVObLKD7zZrytkHm+gncOMzkfhfzHqrSLW INw/aK49DvdMTP+4XPYYuI3c+sj+VCQKEDXRX9X3vUvRUcRSchO/EFjiKGBYibsi/NdD HjsA6O+hsspMdzskvrjhaM0s8X4HmBnbDF46uzH5Jfv9I0pqXGfwbo9gB/jUz7kK/SBr JeZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=alK+Bize; 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 g10si19220594edt.499.2020.12.28.05.12.55; Mon, 28 Dec 2020 05:13:18 -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=alK+Bize; 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 S1731313AbgL1NKL (ORCPT + 99 others); Mon, 28 Dec 2020 08:10:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:37674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731278AbgL1NKJ (ORCPT ); Mon, 28 Dec 2020 08:10:09 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BC451207F7; Mon, 28 Dec 2020 13:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160994; bh=jWWecCvtWSloin1KklTI0i6RRAy8XgIXFUC1cw82+x0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=alK+BizeUsCiVk0H2fVrc/uFnADhO9Ed2UJnF2hRj3199ny7vpIGOu8p/4E9iqieg 0eO8a1YaTuRv2NLW8tuIiWgjtkDjWccCshCzpQ1dLY5G4dnRea9JKWNtQw0TbZFggL fHgjw2ynWBDlEomwm64koFkRVsYs6xW87oXHYmf0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peilin Ye , Marcel Holtmann , syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com Subject: [PATCH 4.14 064/242] Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt() Date: Mon, 28 Dec 2020 13:47:49 +0100 Message-Id: <20201228124907.836326064@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@linuxfoundation.org> User-Agent: quilt/0.66 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: Peilin Ye commit f7e0e8b2f1b0a09b527885babda3e912ba820798 upstream. `num_reports` is not being properly checked. A malformed event packet with a large `num_reports` number makes hci_le_direct_adv_report_evt() read out of bounds. Fix it. Cc: stable@vger.kernel.org Fixes: 2f010b55884e ("Bluetooth: Add support for handling LE Direct Advertising Report events") Reported-and-tested-by: syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=24ebd650e20bd263ca01 Signed-off-by: Peilin Ye Signed-off-by: Marcel Holtmann Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/hci_event.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5141,20 +5141,18 @@ static void hci_le_direct_adv_report_evt struct sk_buff *skb) { u8 num_reports = skb->data[0]; - void *ptr = &skb->data[1]; + struct hci_ev_le_direct_adv_info *ev = (void *)&skb->data[1]; - hci_dev_lock(hdev); + if (!num_reports || skb->len < num_reports * sizeof(*ev) + 1) + return; - while (num_reports--) { - struct hci_ev_le_direct_adv_info *ev = ptr; + hci_dev_lock(hdev); + for (; num_reports; num_reports--, ev++) process_adv_report(hdev, ev->evt_type, &ev->bdaddr, ev->bdaddr_type, &ev->direct_addr, ev->direct_addr_type, ev->rssi, NULL, 0); - ptr += sizeof(*ev); - } - hci_dev_unlock(hdev); }