2021-02-11 22:26:31

by Stotland, Inga

[permalink] [raw]
Subject: [PATCH BlueZ 0/4] Use compliant UUID for mesh

Mesh profile spec states that the values use for Device UUIDs
folow format and generation procedures outlined in RFC 4122.
This patch set addresses this requirement.

Inga Stotland (4):
doc/mesh-api: Add notion of Device UUID compliance
mesh: Add validation of Device UUID value
test/test-mesh: Generate correct value for Device UUID
tools/mesh-cfg-client:

Makefile.am | 6 ++++--
doc/mesh-api.txt | 9 ++++++---
mesh/mesh.c | 18 +++++++++---------
test/test-mesh | 5 +++++
tools/mesh-cfgclient.c | 6 +++---
tools/mesh/mesh-db.c | 2 +-
6 files changed, 28 insertions(+), 18 deletions(-)

--
2.26.2


2021-02-11 22:26:31

by Stotland, Inga

[permalink] [raw]
Subject: [PATCH BlueZ 4/4] tools/mesh-cfg-client:

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;
--
2.26.2

2021-02-11 22:26:31

by Stotland, Inga

[permalink] [raw]
Subject: [PATCH BlueZ 1/4] doc/mesh-api: Add notion of Device UUID compliance

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.
--
2.26.2

2021-02-11 22:26:31

by Stotland, Inga

[permalink] [raw]
Subject: [PATCH BlueZ 2/4] mesh: Add validation of Device UUID value

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,
--
2.26.2

2021-02-11 22:29:23

by Stotland, Inga

[permalink] [raw]
Subject: [PATCH BlueZ 3/4] test/test-mesh: Generate correct value for Device UUID

This ensures that the value of Device UUID when invoking
Join method is compliant with RFC 4122.
---
test/test-mesh | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/test/test-mesh b/test/test-mesh
index 9e4783734..a478843a3 100755
--- a/test/test-mesh
+++ b/test/test-mesh
@@ -889,6 +889,11 @@ class MainMenu(Menu):

uuid = bytearray.fromhex("0a0102030405060708090A0B0C0D0E0F")
random.shuffle(uuid)
+ uuid[6] &= 0x0f;
+ uuid[6] |= 4 << 4;
+ uuid[8] &= 0x3f;
+ uuid[8] |= 0x80;
+
uuid_str = array_to_string(uuid)

print(set_yellow('Joining with UUID ') + set_green(uuid_str))
--
2.26.2

2021-02-11 22:41:00

by bluez.test.bot

[permalink] [raw]
Subject: RE: Use compliant UUID for mesh

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=432455

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - FAIL
Output:
tools/mesh-cfg-client:
1: T3 Title has trailing punctuation (:): "tools/mesh-cfg-client:"


##############################
Test: CheckBuild - PASS

##############################
Test: MakeCheck - PASS



---
Regards,
Linux Bluetooth

2021-02-12 10:57:55

by Michał Lowas-Rzechonek

[permalink] [raw]
Subject: Re: [PATCH BlueZ 3/4] test/test-mesh: Generate correct value for Device UUID

On 02/11, Inga Stotland wrote:
> This ensures that the value of Device UUID when invoking
> Join method is compliant with RFC 4122.
> ---
> test/test-mesh | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/test/test-mesh b/test/test-mesh
> index 9e4783734..a478843a3 100755
> --- a/test/test-mesh
> +++ b/test/test-mesh
> @@ -889,6 +889,11 @@ class MainMenu(Menu):
>
> uuid = bytearray.fromhex("0a0102030405060708090A0B0C0D0E0F")
> random.shuffle(uuid)
> + uuid[6] &= 0x0f;
> + uuid[6] |= 4 << 4;
> + uuid[8] &= 0x3f;
> + uuid[8] |= 0x80;
> +

https://docs.python.org/3/library/uuid.html


> uuid_str = array_to_string(uuid)
>
> print(set_yellow('Joining with UUID ') + set_green(uuid_str))
> --
> 2.26.2
>

--
Michał Lowas-Rzechonek <[email protected]>
Silvair http://silvair.com
Jasnogórska 44, 31-358 Krakow, POLAND