From patchwork Fri May 22 21:13:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 11566187 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F272390 for ; Fri, 22 May 2020 21:13:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E48E82073B for ; Fri, 22 May 2020 21:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731056AbgEVVNR (ORCPT ); Fri, 22 May 2020 17:13:17 -0400 Received: from mga14.intel.com ([192.55.52.115]:48185 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731041AbgEVVNQ (ORCPT ); Fri, 22 May 2020 17:13:16 -0400 IronPort-SDR: v9uLO1+6xSk0M/3AzNcPNpWhtI/QPCjjl+O6b7OdXA7SSW5v/lvarYkIHXcztRXWC4pvdQEBRR DEZYQIY+DFcQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2020 14:13:15 -0700 IronPort-SDR: R5EREKU611aelqhjOQoVvNNBUD/hIEjGCceS/9iCeqpp5/eT8KnDfhTj2JNysU3tCNy2OnY22M CY15SxT8QWQA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,423,1583222400"; d="scan'208";a="254372379" Received: from bgi1-mobl2.amr.corp.intel.com ([10.254.68.94]) by fmsmga007.fm.intel.com with ESMTP; 22 May 2020 14:13:15 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ v2 1/4] mesh: Fix using uninitialized bytes Date: Fri, 22 May 2020 14:13:06 -0700 Message-Id: <20200522211309.233824-2-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200522211309.233824-1-brian.gix@intel.com> References: <20200522211309.233824-1-brian.gix@intel.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Fixes two problems found with static analysis --- mesh/crypto.c | 1 + mesh/node.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/mesh/crypto.c b/mesh/crypto.c index 99536594b..70b96c51b 100644 --- a/mesh/crypto.c +++ b/mesh/crypto.c @@ -553,6 +553,7 @@ bool mesh_crypto_packet_build(bool ctl, uint8_t ttl, if (seq > SEQ_MASK) return false; + packet[0] = 0; l_put_be32(seq, packet + 1); packet[1] = (ctl ? CTL : 0) | (ttl & TTL_MASK); diff --git a/mesh/node.c b/mesh/node.c index dd28dfd77..49ba7c885 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -1596,6 +1596,8 @@ static void get_managed_objects_cb(struct l_dbus_message *msg, void *user_data) /* Generate device and primary network keys */ l_getrandom(dev_key, sizeof(dev_key)); l_getrandom(net_key.old_key, sizeof(net_key.old_key)); + memcpy(net_key.new_key, net_key.old_key, + sizeof(net_key.old_key)); net_key.net_idx = PRIMARY_NET_IDX; net_key.phase = KEY_REFRESH_PHASE_NONE; From patchwork Fri May 22 21:13:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 11566191 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 34D3A14C0 for ; Fri, 22 May 2020 21:13:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27A4C2078D for ; Fri, 22 May 2020 21:13:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731064AbgEVVNS (ORCPT ); Fri, 22 May 2020 17:13:18 -0400 Received: from mga14.intel.com ([192.55.52.115]:48185 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731021AbgEVVNR (ORCPT ); Fri, 22 May 2020 17:13:17 -0400 IronPort-SDR: duhiBFFNBM2jr4YqEqn4PsYVAQUUL/YX0nLWK2VUr/mgJAQDQQZrYf8/1cUhR84sCBq1F1JuSJ IkFhi1hedGEg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2020 14:13:15 -0700 IronPort-SDR: 8Bl5tcd3R2NnHSVQdW55YaRl/U/TRPM57q5k1G0Mp6mRU16pQ+dYsnoLHMu1FmjyeDw6WkYhUJ HbvU+jep6skw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,423,1583222400"; d="scan'208";a="254372384" Received: from bgi1-mobl2.amr.corp.intel.com ([10.254.68.94]) by fmsmga007.fm.intel.com with ESMTP; 22 May 2020 14:13:15 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ v2 2/4] mesh: Fix leaked mesh_net allocation Date: Fri, 22 May 2020 14:13:07 -0700 Message-Id: <20200522211309.233824-3-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200522211309.233824-1-brian.gix@intel.com> References: <20200522211309.233824-1-brian.gix@intel.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- mesh/node.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mesh/node.c b/mesh/node.c index 49ba7c885..db888d27c 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -1313,8 +1313,6 @@ static bool add_local_node(struct mesh_node *node, uint16_t unicast, bool kr, bool ivu, uint32_t iv_idx, uint8_t dev_key[16], uint16_t net_key_idx, uint8_t net_key[16]) { - node->net = mesh_net_new(node); - if (!nodes) nodes = l_queue_new(); From patchwork Fri May 22 21:13:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 11566189 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C404390 for ; Fri, 22 May 2020 21:13:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6B29207CB for ; Fri, 22 May 2020 21:13:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731061AbgEVVNR (ORCPT ); Fri, 22 May 2020 17:13:17 -0400 Received: from mga14.intel.com ([192.55.52.115]:48186 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731051AbgEVVNQ (ORCPT ); Fri, 22 May 2020 17:13:16 -0400 IronPort-SDR: UjIue3gpFNAFGGd/FTLfWiJCzDX8Pe2YlecQdExFOIih27fcECJq9SVldLj2iQsnArhyN7m3T/ 0s2lM9cpVoiQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2020 14:13:15 -0700 IronPort-SDR: NOTRywBAVDQDOsIWRClL/7dgguz8DEVD7UeTinzy2bOERZI+Spv88+tehcpQouAwACs1FvvRT3 kkjGxgAGGIvA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,423,1583222400"; d="scan'208";a="254372388" Received: from bgi1-mobl2.amr.corp.intel.com ([10.254.68.94]) by fmsmga007.fm.intel.com with ESMTP; 22 May 2020 14:13:15 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ v2 3/4] mesh: Fix leaked message reference Date: Fri, 22 May 2020 14:13:08 -0700 Message-Id: <20200522211309.233824-4-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200522211309.233824-1-brian.gix@intel.com> References: <20200522211309.233824-1-brian.gix@intel.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- mesh/manager.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mesh/manager.c b/mesh/manager.c index 0242bb9e9..a7383e4d5 100644 --- a/mesh/manager.c +++ b/mesh/manager.c @@ -228,6 +228,7 @@ static void add_start(void *user_data, int err) "Failed to start provisioning initiator"); l_dbus_send(dbus_get_bus(), reply); + l_dbus_message_unref(add_pending->msg); add_pending->msg = NULL; } @@ -264,7 +265,6 @@ static struct l_dbus_message *add_node_call(struct l_dbus *dbus, /* Invoke Prov Initiator */ add_pending = l_new(struct add_data, 1); - add_pending->msg = l_dbus_message_ref(msg); memcpy(add_pending->uuid, uuid, 16); add_pending->node = node; add_pending->agent = node_get_agent(node); @@ -277,6 +277,7 @@ static struct l_dbus_message *add_node_call(struct l_dbus *dbus, goto fail; } + add_pending->msg = l_dbus_message_ref(msg); initiator_start(PB_ADV, uuid, 99, 60, add_pending->agent, add_start, add_data_get, add_cmplt, node, add_pending); From patchwork Fri May 22 21:13:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 11566193 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F15B90 for ; Fri, 22 May 2020 21:13:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71EF820757 for ; Fri, 22 May 2020 21:13:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731067AbgEVVNS (ORCPT ); Fri, 22 May 2020 17:13:18 -0400 Received: from mga14.intel.com ([192.55.52.115]:48186 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731053AbgEVVNR (ORCPT ); Fri, 22 May 2020 17:13:17 -0400 IronPort-SDR: 8Xg32E05V9rQtoKWJtZGF87xsKnUZUzV6WpDjyQ7CcAfov2HPzLQL86eD7m3nppY8p/a1BeNHj YGKWqaNj/WuA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2020 14:13:15 -0700 IronPort-SDR: uFNmDn+kPhtD3o7cJV2IWZpSyHr3dxTQ3QRlIKJ5R1Novz5i8UeKZ3hU8VdF404erDF5qFVjJQ 2mGBKyit5FTQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,423,1583222400"; d="scan'208";a="254372391" Received: from bgi1-mobl2.amr.corp.intel.com ([10.254.68.94]) by fmsmga007.fm.intel.com with ESMTP; 22 May 2020 14:13:15 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ v2 4/4] mesh: Destroy PB-ADV queue when provisioning done Date: Fri, 22 May 2020 14:13:09 -0700 Message-Id: <20200522211309.233824-5-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200522211309.233824-1-brian.gix@intel.com> References: <20200522211309.233824-1-brian.gix@intel.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- mesh/pb-adv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mesh/pb-adv.c b/mesh/pb-adv.c index 291d92651..c1316ed1b 100644 --- a/mesh/pb-adv.c +++ b/mesh/pb-adv.c @@ -560,4 +560,9 @@ void pb_adv_unreg(void *user_data) send_close_ind(session, 0); l_queue_remove(pb_sessions, session); l_free(session); + + if (!l_queue_length(pb_sessions)) { + l_queue_destroy(pb_sessions, l_free); + pb_sessions = NULL; + } }