From patchwork Fri Feb 12 21:42:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inga Stotland X-Patchwork-Id: 382503 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=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 A2A02C433E6 for ; Fri, 12 Feb 2021 21:43:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D77164E8A for ; Fri, 12 Feb 2021 21:43:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230263AbhBLVng (ORCPT ); Fri, 12 Feb 2021 16:43:36 -0500 Received: from mga06.intel.com ([134.134.136.31]:54931 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbhBLVnf (ORCPT ); Fri, 12 Feb 2021 16:43:35 -0500 IronPort-SDR: JfASMa0vvyaaPNCNx+ReoluMG+qo8k2+rblkTxjV3YqeRyVu3FKqA3Cx6NOR0ffxXua+3BDqWJ buzPtJ0vfWHA== X-IronPort-AV: E=McAfee;i="6000,8403,9893"; a="243967597" X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="243967597" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 13:42:54 -0800 IronPort-SDR: K859zjVwJfJRvFRxOFNhC+Wc+YooiTikUXEMog5BZN6FAdh4FfF2uTZXxV7JjfFdww43VupopC I2AgcdAwIdWQ== X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="416116341" Received: from dmoore1-mobl2.amr.corp.intel.com (HELO istotlan-desk.intel.com) ([10.209.2.150]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 13:42:53 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com, Inga Stotland Subject: [PATCH BlueZ v2 1/4] doc/mesh-api: Add notion of Device UUID compliance Date: Fri, 12 Feb 2021 13:42:41 -0800 Message-Id: <20210212214244.74995-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210212214244.74995-1-inga.stotland@intel.com> References: <20210212214244.74995-1-inga.stotland@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add requirement that the value of Device UUID supplied in CreateNetwork/Join/Import methods should be compliant with RFC 4122. --- doc/mesh-api.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/mesh-api.txt b/doc/mesh-api.txt index 254ccbd7f..f2c6b9e5c 100644 --- a/doc/mesh-api.txt +++ b/doc/mesh-api.txt @@ -27,7 +27,8 @@ Methods: The uuid parameter is a 16-byte array that contains Device UUID. This UUID must be unique (at least from the daemon perspective), therefore attempting to call this function using already - registered UUID results in an error. + registered UUID results in an error. The composition of the UUID + octets must be in compliance with RFC 4122. When provisioning finishes, the daemon will call either JoinComplete or JoinFailed method on object implementing @@ -149,7 +150,8 @@ Methods: The uuid parameter is a 16-byte array that contains Device UUID. This UUID must be unique (at least from the daemon perspective), therefore attempting to call this function using already - registered UUID results in an error. + registered UUID results in an error. The composition of the UUID + octets must be in compliance with RFC 4122. The other information the bluetooth-meshd daemon will preserve about the initial node, is to give it the initial primary @@ -179,7 +181,8 @@ Methods: The uuid parameter is a 16-byte array that contains Device UUID. This UUID must be unique (at least from the daemon perspective), therefore attempting to call this function using already - registered UUID results in an error. + registered UUID results in an error. The composition of the UUID + octets must be in compliance with RFC 4122. The dev_key parameter is the 16-byte value of the dev key of the imported mesh node. From patchwork Fri Feb 12 21:42:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inga Stotland X-Patchwork-Id: 381941 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=-11.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 B2D99C433E0 for ; Fri, 12 Feb 2021 21:43:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AA2E64E36 for ; Fri, 12 Feb 2021 21:43:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231273AbhBLVni (ORCPT ); Fri, 12 Feb 2021 16:43:38 -0500 Received: from mga06.intel.com ([134.134.136.31]:54934 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbhBLVnh (ORCPT ); Fri, 12 Feb 2021 16:43:37 -0500 IronPort-SDR: i+lfiDj45kL81G/e4m8HvMaKRwFwx3B0gqWitSF8o9AnVOqiQqW7eM1kfqH4p9OzbPXBdQT8qV tQb9+tD/foyg== X-IronPort-AV: E=McAfee;i="6000,8403,9893"; a="243967600" X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="243967600" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 13:42:54 -0800 IronPort-SDR: LA9pWhiVXV/LplR36mcgrrd02EAxua3hrBJXzISF8mrAQRZHyTESTKT+MXvuLTgN00xVZEtRhC 9U+y+XZqy9Cw== X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="416116345" Received: from dmoore1-mobl2.amr.corp.intel.com (HELO istotlan-desk.intel.com) ([10.209.2.150]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 13:42:54 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com, Inga Stotland Subject: [PATCH BlueZ v2 2/4] mesh: Add validation of Device UUID value Date: Fri, 12 Feb 2021 13:42:42 -0800 Message-Id: <20210212214244.74995-3-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210212214244.74995-1-inga.stotland@intel.com> References: <20210212214244.74995-1-inga.stotland@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Validate that the value of Device UUID supplied in CreateNetwork/Join/Import methods is compliant with RFC 4122. --- Makefile.am | 6 ++++-- mesh/mesh.c | 18 +++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index d0f979586..86f3409c3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -134,7 +134,8 @@ ell_headers = ell/util.h \ ell/base64.h \ ell/asn1-private.h \ ell/cert-private.h \ - ell/pem-private.h + ell/pem-private.h \ + ell/uuid.h ell_sources = ell/private.h ell/missing.h \ ell/util.c \ @@ -169,7 +170,8 @@ ell_sources = ell/private.h ell/missing.h \ ell/gvariant-private.h \ ell/gvariant-util.c \ ell/siphash-private.h \ - ell/siphash.c + ell/siphash.c \ + ell/uuid.c ell_libell_internal_la_SOURCES = $(ell_headers) $(ell_sources) endif diff --git a/mesh/mesh.c b/mesh/mesh.c index f29e8b6be..62d650328 100644 --- a/mesh/mesh.c +++ b/mesh/mesh.c @@ -533,7 +533,7 @@ static struct l_dbus_message *join_network_call(struct l_dbus *dbus, void *user_data) { const char *app_path, *sender; - struct l_dbus_message_iter iter_uuid; + struct l_dbus_message_iter iter; uint32_t n; l_debug("Join network request"); @@ -543,14 +543,13 @@ static struct l_dbus_message *join_network_call(struct l_dbus *dbus, "Provisioning in progress"); if (!l_dbus_message_get_arguments(msg, "oay", &app_path, - &iter_uuid)) + &iter)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); join_pending = l_new(struct join_data, 1); - if (!l_dbus_message_iter_get_fixed_array(&iter_uuid, - &join_pending->uuid, &n) - || n != 16) { + if (!l_dbus_message_iter_get_fixed_array(&iter, &join_pending->uuid, &n) + || n != 16 || !l_uuid_is_valid(join_pending->uuid)) { l_free(join_pending); join_pending = NULL; return dbus_error(msg, MESH_ERROR_INVALID_ARGS, @@ -785,8 +784,8 @@ static struct l_dbus_message *create_network_call(struct l_dbus *dbus, &iter_uuid)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); - if (!l_dbus_message_iter_get_fixed_array(&iter_uuid, &uuid, &n) - || n != 16) + if (!l_dbus_message_iter_get_fixed_array(&iter_uuid, &uuid, &n) || + n != 16 || !l_uuid_is_valid(uuid)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Bad device UUID"); @@ -835,8 +834,9 @@ static struct l_dbus_message *import_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); if (!l_dbus_message_iter_get_fixed_array(&iter_uuid, &uuid, &n) || - n != 16) - return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Bad dev UUID"); + n != 16 || !l_uuid_is_valid(uuid)) + return dbus_error(msg, MESH_ERROR_INVALID_ARGS, + "Bad device UUID"); if (node_find_by_uuid(uuid)) return dbus_error(msg, MESH_ERROR_ALREADY_EXISTS, From patchwork Fri Feb 12 21:42:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inga Stotland X-Patchwork-Id: 382502 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=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 AD953C433DB for ; Fri, 12 Feb 2021 21:43:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BAD064DD5 for ; Fri, 12 Feb 2021 21:43:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231501AbhBLVnu (ORCPT ); Fri, 12 Feb 2021 16:43:50 -0500 Received: from mga06.intel.com ([134.134.136.31]:54929 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbhBLVnt (ORCPT ); Fri, 12 Feb 2021 16:43:49 -0500 IronPort-SDR: PCXGTsw/ENZSp1R4VCPw9CCN6QDraRicWwdW5iz+gwTCLzGSKPlrolfMuowNEsJSc2lDwiDdzl GhxmnV3X5Kwg== X-IronPort-AV: E=McAfee;i="6000,8403,9893"; a="243967603" X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="243967603" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 13:42:55 -0800 IronPort-SDR: /FUt9pILhbRTxGoR+dIBvUZ+s+SBo/ZKYY+v0ye6p++XdKEAdJNDRA10lU7qWYJGJJ3F/I6kMi zvOxUswJHo1A== X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="416116350" Received: from dmoore1-mobl2.amr.corp.intel.com (HELO istotlan-desk.intel.com) ([10.209.2.150]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 13:42:55 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com, Inga Stotland Subject: [PATCH BlueZ v2 3/4] test/test-mesh: Generate correct value for Device UUID Date: Fri, 12 Feb 2021 13:42:43 -0800 Message-Id: <20210212214244.74995-4-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210212214244.74995-1-inga.stotland@intel.com> References: <20210212214244.74995-1-inga.stotland@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This ensures that the value of Device UUID when invoking Join method is compliant with RFC 4122. --- test/test-mesh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/test-mesh b/test/test-mesh index 9e4783734..fbf2476bf 100755 --- a/test/test-mesh +++ b/test/test-mesh @@ -887,12 +887,11 @@ class MainMenu(Menu): print(set_error('Provisioning agent not found')) return - uuid = bytearray.fromhex("0a0102030405060708090A0B0C0D0E0F") - random.shuffle(uuid) - uuid_str = array_to_string(uuid) + uuid_bytes = uuid.uuid4().bytes + uuid_str = array_to_string(uuid_bytes) print(set_yellow('Joining with UUID ') + set_green(uuid_str)) - mesh_net.Join(app.get_path(), uuid, + mesh_net.Join(app.get_path(), uuid_bytes, reply_handler=join_cb, error_handler=join_error_cb) From patchwork Fri Feb 12 21:42:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inga Stotland X-Patchwork-Id: 381940 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=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 D4A8FC433DB for ; Fri, 12 Feb 2021 21:43:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95B2B64E26 for ; Fri, 12 Feb 2021 21:43:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231551AbhBLVnw (ORCPT ); Fri, 12 Feb 2021 16:43:52 -0500 Received: from mga06.intel.com ([134.134.136.31]:54931 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbhBLVnv (ORCPT ); Fri, 12 Feb 2021 16:43:51 -0500 IronPort-SDR: /uOSKMuITm+C/kAKDCYqQkvL5ZgMPgiw023EIYBvmleRitpuLaAVqghbFlBzYFKOt00r4Q3hhM PH5e9FMpWb5Q== X-IronPort-AV: E=McAfee;i="6000,8403,9893"; a="243967606" X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="243967606" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 13:42:56 -0800 IronPort-SDR: NwLjTnredWlXWi9+NEH5rGhSgGHMEYyima0yKhQmdJ7nIuADVHAFK/kSdK84TeIwicCgI+ONLt jKGFIUb/MYLw== X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="416116354" Received: from dmoore1-mobl2.amr.corp.intel.com (HELO istotlan-desk.intel.com) ([10.209.2.150]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 13:42:56 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com, Inga Stotland Subject: [PATCH BlueZ v2 4/4] tools/mesh-cfg-client: Date: Fri, 12 Feb 2021 13:42:44 -0800 Message-Id: <20210212214244.74995-5-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210212214244.74995-1-inga.stotland@intel.com> References: <20210212214244.74995-1-inga.stotland@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Make sure that the values of Device UUID supplied in CreateNetwork and AddRemoteNode methods are compliant with RFC 4122. Also, use a compliant value for Mesh UUID. --- tools/mesh-cfgclient.c | 6 +++--- tools/mesh/mesh-db.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index 28465a679..1eeed2a1a 100644 --- a/tools/mesh-cfgclient.c +++ b/tools/mesh-cfgclient.c @@ -731,7 +731,7 @@ static void create_net_setup(struct l_dbus_message *msg, void *user_data) struct l_dbus_message_builder *builder; /* Generate random UUID */ - l_getrandom(app.uuid, sizeof(app.uuid)); + l_uuid_v4(app.uuid); builder = l_dbus_message_builder_new(msg); @@ -899,7 +899,7 @@ static void cmd_import_node(int argc, char *argv[]) /* Device UUID */ req->data1 = l_util_from_hexstring(argv[1], &sz); - if (!req->data1 || sz != 16) { + if (!req->data1 || sz != 16 || !l_uuid_is_valid(req->data1)) { l_error("Failed to generate UUID array from %s", argv[1]); goto fail; } @@ -1298,7 +1298,7 @@ static void add_node_setup(struct l_dbus_message *msg, void *user_data) struct l_dbus_message_builder *builder; uuid = l_util_from_hexstring(str, &sz); - if (!uuid || sz != 16) { + if (!uuid || sz != 16 || !l_uuid_is_valid(uuid)) { l_error("Failed to generate UUID array from %s", str); return; } diff --git a/tools/mesh/mesh-db.c b/tools/mesh/mesh-db.c index d86913006..46f0c6075 100644 --- a/tools/mesh/mesh-db.c +++ b/tools/mesh/mesh-db.c @@ -1407,7 +1407,7 @@ bool mesh_db_create(const char *fname, const uint8_t token[8], if (!add_u8_8(jcfg, "token", token)) goto fail; - l_getrandom(uuid, 16); + l_uuid_v4(uuid); if (!add_u8_16(jcfg, "uuid", uuid)) goto fail;