From patchwork Tue Sep 29 10:59:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 291179 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 EE83BC4727C for ; Tue, 29 Sep 2020 11:15:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B1AAB20848 for ; Tue, 29 Sep 2020 11:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378141; bh=lFCzPiwrwZi+2I/qPpv079tYMk9JTossO09i+z/sBqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=S9gUOFSKhGexkJ/4lVj5bjzPlF1O70zAfbe2RF8jXjO5lG9TDGXAPYj6HK3N2I8kO DB5Bwy21xl1QGBOKM/OFDrAkNI96AmswlpF2GzOiY76EekcjwRKtzvYsFVq8Lj8D2l nV6CXR26yTZ4/az0hAq1OaJBcaeY/2H8LgIsq0Hc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729529AbgI2LPh (ORCPT ); Tue, 29 Sep 2020 07:15:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:60062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728958AbgI2LPf (ORCPT ); Tue, 29 Sep 2020 07:15:35 -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 6BFD7206DB; Tue, 29 Sep 2020 11:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378135; bh=lFCzPiwrwZi+2I/qPpv079tYMk9JTossO09i+z/sBqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zp6JANwnW6mlKKErI1FikGxaZFZH81GGrFRfCVJKw7QOYt2ctbKuVJI7u4Lp6Lrqf IQTfBKlnCRS0BZ6kKPCon9+PIiHlQSR8/0JSkQigI0HCa5JErZIcumA2oBCAepiyKA l/uDvvvvizibY91GRdhD/+JCUoVJu6jOPfEFhjRM= 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.14 073/166] Bluetooth: guard against controllers sending zerod events Date: Tue, 29 Sep 2020 12:59:45 +0200 Message-Id: <20200929105938.865682425@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105935.184737111@linuxfoundation.org> References: <20200929105935.184737111@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 70b8e2de40cf4..1d2f439043669 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++;