From patchwork Tue Sep 29 10:57:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 290954 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30BC7C4727C for ; Tue, 29 Sep 2020 12:07:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D457820684 for ; Tue, 29 Sep 2020 12:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601381245; bh=4Q7mw5KAqcmnZ9t/lXxKuMpRFZq7oX7lNAzl9x/GlCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=PRAKVomAJffdunLXPK2jp4PvlXJbT3FUGBXGU4sXz3nNPIR1F+4Cn9//wkzaOJ0ok SexywQd+7sbYVctF4uJLqrc4hOn1a6uLu/BH2H8oMKt1J217+PhzmPcnM/Nq1vvvui X7iwDd5uv/YrhdBnkWR1qAQ93cc1MDVNrheA/UfE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730680AbgI2MHO (ORCPT ); Tue, 29 Sep 2020 08:07:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:58102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730244AbgI2Lhg (ORCPT ); Tue, 29 Sep 2020 07:37:36 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 C8BEE23A9D; Tue, 29 Sep 2020 11:36:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379399; bh=4Q7mw5KAqcmnZ9t/lXxKuMpRFZq7oX7lNAzl9x/GlCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sfdtx+Sx8y9ZbyfwJcaOXq1Cs93bff4Cm6OUuqsywuyLdTHdydv3lVnBt6IxGPVIX GmCdkWTeU2yfyn45uPMIi9iAw1q+RFcUxr4wHM4O9HKiR1ck8whmxwFLNto5T6sF/I 4ONGCksJDMxYbOmwoggFDTZvu07ZDzSnlMV8Lzys= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alain Michaud , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.4 145/388] Bluetooth: guard against controllers sending zerod events Date: Tue, 29 Sep 2020 12:57:56 +0200 Message-Id: <20200929110017.493975439@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Alain Michaud [ Upstream commit 08bb4da90150e2a225f35e0f642cdc463958d696 ] Some controllers have been observed to send zero'd events under some conditions. This change guards against this condition as well as adding a trace to facilitate diagnosability of this condition. Signed-off-by: Alain Michaud Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/bluetooth/hci_event.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 7bf6860fed783..1bbeb14b8b64e 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5853,6 +5853,11 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) u8 status = 0, event = hdr->evt, req_evt = 0; u16 opcode = HCI_OP_NOP; + if (!event) { + bt_dev_warn(hdev, "Received unexpected HCI Event 00000000"); + goto done; + } + if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->hci.req_event == event) { struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data; opcode = __le16_to_cpu(cmd_hdr->opcode); @@ -6064,6 +6069,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) req_complete_skb(hdev, status, opcode, orig_skb); } +done: kfree_skb(orig_skb); kfree_skb(skb); hdev->stat.evt_rx++;