Skip to content

shared/gatt: Use util_iov helpers for PDU handling

Luiz Augusto von Dentz linux-bluetooth 1 version Applied

Status from this message: This series was applied to bluetooth/bluez.git (master)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest10 patches 1 replyApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/10shared/att: Use util_iov helpers to build and parse PDUssrc/shared/att.c+20 -81 reply
2/10shared/gatt-server: Use util_iov helpers to build and parse PDUssrc/shared/gatt-server.c+185 -1880 replies
3/10shared/gatt-helpers: Use util_iov helpers to build and parse PDUssrc/shared/gatt-helpers.c+296 -1560 replies
4/10shared/gatt-client: Use util_iov helpers to build and parse PDUssrc/shared/gatt-client.c+94 -1090 replies
5/10unit/test-gatt: Add malformed PDU testsunit/test-gatt.c+175 -00 replies
6/10shared/gatt-server: Fix authorize callback getting handle 0 on writesrc/shared/gatt-server.c unit/test-gatt.c+39 -40 replies
7/10shared/gatt-server: Fix double response on prepare write failuresrc/shared/gatt-server.c+7 -20 replies
8/10shared/gatt-server: Fix return value of handler registrationsrc/shared/gatt-server.c+1 -10 replies
9/10shared/att: Fix reference leak on signature verification failuresrc/shared/att.c+3 -10 replies
10/10shared/att: Fix signature length subtracted once per handlersrc/shared/att.c+5 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH BlueZ v1 00/10] shared/gatt: Use util_iov helpers for PDU handling

From: Luiz Augusto von Dentz <[email protected]>

This converts src/shared/{att,gatt-server,gatt-client,gatt-helpers} to build and parse PDUs with the util_iov_pull_* and util_iov_push_* helpers rather than pointer arithmetic on the PDU, so that the bounds check is part of the access.

The conversion is meant to be behavior preserving, the existing unit/test-gatt tests pass unchanged. It is followed by tests for malformed PDUs, which the original code already rejected, so these are regression coverage for the converted paths, and by fixes for bugs found while reading the code:

- the authorize callback was called with handle 0 for writes (reproduced by a new test)
- a failure to store prepared write data sent two responses
- the Execute Write registration failure returned NULL for a bool
- handle_notify leaked a bt_att reference when the signature of a Signed Write Command could not be verified
- handle_notify subtracted the signature length once per handler

The last four have no unit test: the prepare write failure is only reachable by an allocation failure, and the signature paths need a signing key and crypto setup that unit/test-gatt does not have.

Note that "make check" runs the tests under valgrind, which reports uninitialised bytes in bt_log_open() for unit/test-gatt both before and after this series in the environment used.

Luiz Augusto von Dentz (10):
shared/att: Use util_iov helpers to build and parse PDUs shared/gatt-server: Use util_iov helpers to build and parse PDUs shared/gatt-helpers: Use util_iov helpers to build and parse PDUs shared/gatt-client: Use util_iov helpers to build and parse PDUs unit/test-gatt: Add malformed PDU tests shared/gatt-server: Fix authorize callback getting handle 0 on write shared/gatt-server: Fix double response on prepare write failure shared/gatt-server: Fix return value of handler registration shared/att: Fix reference leak on signature verification failure shared/att: Fix signature length subtracted once per handler

 src/shared/att.c          |  38 +++-
 src/shared/gatt-client.c  | 203 ++++++++---------
 src/shared/gatt-helpers.c | 452 +++++++++++++++++++++++++-------------
 src/shared/gatt-server.c  | 380 ++++++++++++++++----------------
 unit/test-gatt.c          | 214 +++++++++++++++++-
 5 files changed, 821 insertions(+), 466 deletions(-)
Signature · 1 line
2.56.0