Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3550683ybf; Tue, 3 Mar 2020 08:00:15 -0800 (PST) X-Google-Smtp-Source: ADFU+vtnAfXA7ycv6Paar0Ubndc1vX4lv4SUm0F3nb9nDAHU0/fbOsyi0WiQVEypF+mBReAKGTSb X-Received: by 2002:a9d:21c5:: with SMTP id s63mr3743832otb.142.1583251215006; Tue, 03 Mar 2020 08:00:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583251214; cv=none; d=google.com; s=arc-20160816; b=KKKxIrLbfOCPKUePKU5SAOlxU6lDNCLnKbT+m+UiyowzecdlhEbw5oADW9qs4FWs4M 0Zs5aIbS+QJj54bQfUH644ZBiFvb0AWLiKzaGqlkac5TogDIRsPCjWk6wxsg1iPrX2L2 aLOXFd0Wcb0yqNZUI/uU+QZ2hpyzdrJnZtMbGHFX5sbELm1IrxVDLvvfnWQR1fGcQgBa CBwEeif01biuPN52rINrJkEvfR3VnaciP/d0hp9maZWOUb0dC+5TrG7x1/7enxz99k2f hYgzFQEr4SU5w7NxaSwcZ6zKCAtUcImsou14LHK47imyn+aGRx41Fivgv6Ykh/GuMEZ5 TzDA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=2DXAgA0BV232zHIduMsuc1xsDnUh5eMDqf5PhGpC/9A=; b=nIaCVk9uWbaN/i1jxjAVSqVhPbUk7qRO1pAeV0vzt4p/55VqrszP5RXw0GGAU6kr1q rCnXvZ4oAYEf9eu8tRVmcL2PdR49s+jIUTqSYL7wnIkJBpihT+UEZiC553gFyBTBtad9 xsuzkBrclN2NQiFQ6yawktSI1eyHiCjk6lhVqziEmMxOOgfAXrsDZLVB4exkFY2Mf5Xe SsWvHkd8Fi/a9Llo8+L4JYX0GO4y2eGUxm6OdkOfoKEz9HMZdo7Nc7Nt0hLT6RZGfjNA rEUQA0yziiKBWYoIkOQN4bt+KWoIjA/vdVw923/B3HUls19mz2h7C7vA8lNrrrS0u6CU VnlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jA3lbRTy; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si7708211oii.42.2020.03.03.07.59.49; Tue, 03 Mar 2020 08:00:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jA3lbRTy; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729976AbgCCPzm (ORCPT + 99 others); Tue, 3 Mar 2020 10:55:42 -0500 Received: from mail-vs1-f53.google.com ([209.85.217.53]:45525 "EHLO mail-vs1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729577AbgCCPzm (ORCPT ); Tue, 3 Mar 2020 10:55:42 -0500 Received: by mail-vs1-f53.google.com with SMTP id m4so2654522vsa.12 for ; Tue, 03 Mar 2020 07:55:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2DXAgA0BV232zHIduMsuc1xsDnUh5eMDqf5PhGpC/9A=; b=jA3lbRTy7cJKHa9xvLbON4NhLI2peCy/qc6y3k5kqmJfaaR+76IFHySznqozXG7EZr qd8ZSE/Lh9GEmOZ7OD6hO2axXLNMEGRPq361Iz+XPN/NVRDGcXAI6kUTIJc4ZWU22R+U SYOePYPgOIrlXzscUhbebcUYSFJYHQgQw/1Rw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2DXAgA0BV232zHIduMsuc1xsDnUh5eMDqf5PhGpC/9A=; b=ALCNB7uFYgDeHjetWyNYB94Dtv3jBEwdBB2KOG4xMt3XOOPx/UkU0+89xZk80uD90Y sTPUVj5h2HxZ3wkKMj8NuBL9IKl72YPWYDHKtUFJHAtjW47TV53zGX6ySaO6VzVdMAJu 2JpmPxGBse3XrbLQi4HGl45+I4U7Ll2SaajXjk4aEScJ3+NGo3fhlmxCgXM3QMYs4FMi uWWptq7lO9HHuoOwLPQkOLpm3oQNszAgndW58pnYtiigKFcxy09dxuijgwwGWNiEgVBZ dTvk8kqQx1z5h9w84H2vCdzd1L9LhEe5FPo1+tfa0tC7ukwAeXIqJQh6vWEtelxuF9Rq /4gw== X-Gm-Message-State: ANhLgQ0Y2qoIiGtcpnuZUblM0J7UMYiG3HxNHdxOme8yKn9rjJgThF1o gkZLE2BKfNfG8oFp4lZE/WRhS7h0OQw= X-Received: by 2002:a67:fe05:: with SMTP id l5mr2751338vsr.77.1583250939643; Tue, 03 Mar 2020 07:55:39 -0800 (PST) Received: from alain.c.googlers.com.com (39.119.74.34.bc.googleusercontent.com. [34.74.119.39]) by smtp.gmail.com with ESMTPSA id v65sm6549559vke.13.2020.03.03.07.55.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 07:55:38 -0800 (PST) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud Subject: [PATCH v3] bluetooth: guard against controllers sending zero'd events Date: Tue, 3 Mar 2020 15:55:34 +0000 Message-Id: <20200303155534.127645-1-alainm@chromium.org> X-Mailer: git-send-email 2.25.1.481.gfbce0eb801-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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 --- 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 591e7477e925..a40ed31f6eb8 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5868,6 +5868,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); @@ -6079,6 +6084,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++; -- 2.25.1.481.gfbce0eb801-goog