Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4420038pxa; Mon, 10 Aug 2020 08:40:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwy2j489odpGLDBwDUABZyw/CKszSpTPGsQQU1hAHvqjEqklmV2PoXP1VVpyK8WRHsqK3JY X-Received: by 2002:a17:906:819:: with SMTP id e25mr23254795ejd.95.1597074002427; 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=dLLVWMGfGmDXpeIwydKCZtQzBOwnu58wlrdMr0eA67M4f6GucALLVCsrXrfMptoY/Q DpSXbJPxBuxPOeWYwgCyXjCs1sGqymVA/qF65/SL0cw83kK47KogBJy3k4xkGHaex0V0 UfWrjZHHW0lglfBx/zYhfVf9RozecjCwehcTQVM4rV4AK6QhW5qhEfHd1FDgFwmzJfOr 0bnTzaN5+zCN2QIiqB8JFbjRqCRnQKy1UI30qvZdouiLggy2oD7oRwzRrwrdZEegE90W gF8zATw5ZyT1i/oyp3vqnsc+wohQXDlIVXPJ+NVxlzPAnrUokB2aq/dyaOmxxOsbQ/WP KUQA== 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=LEk1bN7rJjxhquqVUuu3UeK+8OTn7EbVPXYxH7qmB2g=; b=v/VToR3TRUTzOtl6AoZmxWI4nRPSK5nk4jR6e4KbGyOmZNeY3DKibFEPvYKyn5dNm1 6yotkZ+jdh92sMEufuCmXi02rbn7+7KeuQt0ps876fUzajNOjs6BPfc0zp7PRK2h0iY1 zJaicAaHzXnTqrB12KRiEg2dfJq1pnWsPfqS117/roNzKPjpHI9wgNN0i8xjyElF/b4J W/H20hWLjdC3CvQ1SIYN5/Mn6kQzHP+Fh2qJs7mcmTst57hWBrHF9d5FomeDxRsbew1B j2KYozcfUq0MDBqOhdqnlodZTdgZsgiEh+bJiSV581wlIFdIQRWV+3mdXcgPU6O89Fd2 /4Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="CXs/fUOT"; 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 c5si3026429ejx.479.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="CXs/fUOT"; 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 S1728628AbgHJP03 (ORCPT + 99 others); Mon, 10 Aug 2020 11:26:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:60338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728620AbgHJP01 (ORCPT ); Mon, 10 Aug 2020 11:26:27 -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 0223C208A9; Mon, 10 Aug 2020 15:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597073186; bh=UR5mSMewWWWw1SvC11XybK398YV1JJXR5fyUAC5KFf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CXs/fUOT2lAj63n5bjdaRVvfDBUZ1cOkU94KeFgxCdO3KlTwFjHsuhcgO8UUpxTPW JgU6/CGYuxWxBWSNgz/XQxyDOmCizczJ6FcN/FnKLbJKwSoN5kARinIkCvFp4cMEhU NkZOJYuUpu/rsqpRKqhfEShRABKwBP6n2yjPrr6U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+d8489a79b781849b9c46@syzkaller.appspotmail.com, Peilin Ye , Marcel Holtmann Subject: [PATCH 5.4 17/67] Bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt() Date: Mon, 10 Aug 2020 17:21:04 +0200 Message-Id: <20200810151810.275895877@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 51c19bf3d5cfaa66571e4b88ba2a6f6295311101 upstream. Check upon `num_rsp` is insufficient. A malformed event packet with a large `num_rsp` number makes hci_extended_inquiry_result_evt() go out of bounds. Fix it. This patch fixes the following syzbot bug: https://syzkaller.appspot.com/bug?id=4bf11aa05c4ca51ce0df86e500fce486552dc8d2 Reported-by: syzbot+d8489a79b781849b9c46@syzkaller.appspotmail.com Cc: stable@vger.kernel.org Signed-off-by: Peilin Ye Acked-by: Greg Kroah-Hartman 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 @@ -4270,7 +4270,7 @@ static void hci_extended_inquiry_result_ 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))