From patchwork Tue Sep 29 11:00:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 291210 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=ham 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 2AD07C47425 for ; Tue, 29 Sep 2020 11:10:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA00921D7F for ; Tue, 29 Sep 2020 11:10:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601377846; bh=8fLqQstoxhvoJyOdx8AsvgndDZfHBBtIglmws+g17sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Eqw6wZtbZsIc2hgzJSYUluzU9He+aTbnV9r0CTmurCHjrSuexo0jGI1FddqWrxhdN R/aGP/kVzdTtE3Spz4k5fMBli0e/EWPeEIq6tTK3v0PTZovLOHLAYD9j4r0SGJ3O+p jqlAZ6BWAB1Qdw/RJ7RPeKil1s6aCn2TNGUQWbW4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728318AbgI2LKq (ORCPT ); Tue, 29 Sep 2020 07:10:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:51242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729154AbgI2LKZ (ORCPT ); Tue, 29 Sep 2020 07:10:25 -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 4CDBC21D46; Tue, 29 Sep 2020 11:10:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601377824; bh=8fLqQstoxhvoJyOdx8AsvgndDZfHBBtIglmws+g17sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZEIOpVBSnmyLPuRiqhV4vDKNSo50NB01Bmrh+PcIV8dgpX01YzEY4eJJ1BuLfnYZM mwq7jEeggkvDcLcar3P/op35jwtYdrVhPUNuKgVTD5/yDikp4AaLgJbtOfR2MLVq0B mg7XYwiRNkrW6TU8UsQgRP+K4AtS5FYTHS6qB6OY= 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 4.9 056/121] Bluetooth: guard against controllers sending zerod events Date: Tue, 29 Sep 2020 13:00:00 +0200 Message-Id: <20200929105932.956003493@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105930.172747117@linuxfoundation.org> References: <20200929105930.172747117@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 757977c54d9ef..700a2eb161490 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5257,6 +5257,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); @@ -5468,6 +5473,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++;