Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9445313pxu; Mon, 28 Dec 2020 16:49:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxsZPZahN6b+IIn7OC4fxufW5sVpw/J/iiK08bNcVgJdj0U5vpKL/ah/RZWgSrPO11+TNX X-Received: by 2002:a50:9b58:: with SMTP id a24mr43369513edj.22.1609202984646; Mon, 28 Dec 2020 16:49:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609202984; cv=none; d=google.com; s=arc-20160816; b=PBjs6sy6zK4+0jHz4Ul2TFxXX1Mk4C/8NU0CfGKZz1nTL16DcPjHrhyTFfRhnEfrpJ at14Hz5/GeS1Z3084j2DwVY0LIUbW1qQLQVICZJnPdcaZNhVTWE3cEvFjHlBE8NnKxPZ aMcPF9+A+dHWJ01SHmCQaVGiyTTk2xhH5fB+wcdG23TR0ZDQqe0X/uHzvUGyLMUXFZXH BWre7X3n0z1/pp+HB862qiltZ5m6Mh3h2hzjAdwEdnNPnCzwcO8s50i/C2dKIEgDGYqk zAOyLAbEDjUqjrp9VXNn2wjirNC2x87L8ZjbX9tU+xxC74YggzT5DgZ3Pa0HLx1CILvC 8Giw== 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=Oe22WQ+OTctE55E4Hvlmo6u46YQ/nca+noUrLIEpzL8=; b=eXkp6Nz6DxAiq+sAXxWOdwsWY72NSpKOjTg/GW4se4mA1uo7x5Atu0f2UfMWOOif5k 3qiJEGob4RntoLMJrjLz1v9HkUI9Oz8aBcju6rLLnjGD7DFxLnhZZGHqdh2EElJpI1Mz IZdKH05tdkzPLNJd0oN25zob8RoZdrzBk+dfZTrinUkl+1TM9sgfBZGuDf7kcTy6+M7p +f6KFbTCxl1D57FzH/mLw6DeQuNcGLCwlEhm5W02DK0upXE1B9Cr6qHsHYSkUHSGdQkG mmRUQUuuOWSwOE+bikEWvSKDVzoyeBfIufr4T97XMhjvHz+yvBtioGEvvwrR72RXzpH9 vRYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="V/Rh9eBc"; 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 di28si17988416edb.383.2020.12.28.16.49.22; Mon, 28 Dec 2020 16:49:44 -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="V/Rh9eBc"; 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 S2393395AbgL1QIH (ORCPT + 99 others); Mon, 28 Dec 2020 11:08:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:54420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388888AbgL1NZn (ORCPT ); Mon, 28 Dec 2020 08:25:43 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 920EF20728; Mon, 28 Dec 2020 13:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161903; bh=YLxJs9jlFvIrfdpRGceJ1gxYrYoW359VBzcWHuQ2/YI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V/Rh9eBcUY/dhbRWfSWEQazm0T4GPW/VSvnGUC8ihm+KR4Czbd1MDjPaqxlda9R7u SBslQ2mZegWyUmimaz7FZ1SXbOYNJp7r2QLW5yWSoWAwQ3zKpk+FnRpmrs4T/qgXyX GhJ4wcqBH/EzEeDFpmsRSHQth/3XJyzAtqf+5iww= 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.19 091/346] Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt() Date: Mon, 28 Dec 2020 13:46:50 +0100 Message-Id: <20201228124924.200468197@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124919.745526410@linuxfoundation.org> References: <20201228124919.745526410@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 @@ -5596,21 +5596,19 @@ 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, false); - ptr += sizeof(*ev); - } - hci_dev_unlock(hdev); }