mesh: Tighten IO and fix out-of-bounds array access
PATCH v2 1/1 mesh: Tighten IO and fix out-of-bounds array access
This fixes the out-of-bounds array access in mesh-io-mgmt.c caught by address sanitizer. Similar fixes were applied earlier to generic and unit IOs. With this patch, the common code is factored into a centralized location.
--- mesh/mesh-io-api.h | 7 +++++ mesh/mesh-io-generic.c | 70 ++++++------------------------------------ mesh/mesh-io-mgmt.c | 56 ++++----------------------------- mesh/mesh-io-unit.c | 30 ------------------ mesh/mesh-io.c | 45 ++++++++++++++++----------- mesh/mesh-io.h | 2 -- 6 files changed, 50 insertions(+), 160 deletions(-)
mesh/mesh-io-api.h +7 -0
@@ -34,6 +34,13 @@ struct mesh_io_api {mesh_io_tx_cancel_t cancel; }; +struct mesh_io_reg { +mesh_io_recv_func_t cb; +void *user_data; +uint8_t len; +uint8_t filter[]; +}; +struct mesh_io {int index;int favored_index;
mesh/mesh-io-generic.c +10 -60
153 lines not on this page · raw message
mesh/mesh-io-mgmt.c +6 -50
130 lines not on this page · raw message
mesh/mesh-io-unit.c +0 -30
@@ -485,39 +485,9 @@ static bool tx_cancel(struct mesh_io *io, const uint8_t *data, uint8_t len)return true; } -static bool find_by_filter (const void *a,const void *b) -{ -const struct pvt_rx_reg *rx_reg_old = a; -const struct pvt_rx_reg *rx_reg = b; - -if (rx_reg_old->len != rx_reg->len) -return false; - -return !memcmp (rx_reg_old->filter, rx_reg->filter, rx_reg->len); -} -static bool recv_register (struct mesh_io *io,const uint8_t *filter,uint8_t len,mesh_io_recv_func_t cb,void *user_data) { -struct mesh_io_private *pvt = io->pvt; -struct pvt_rx_reg *rx_reg, *rx_reg_old; - -if (!cb || !filter || !len) -return false; - - rx_reg =l_malloc (sizeof (*rx_reg) + len); - -memcpy (rx_reg->filter, filter, len); - rx_reg->len = len; - rx_reg->cb = cb; - rx_reg->user_data = user_data; - - rx_reg_old =l_queue_remove_if (pvt->rx_regs, find_by_filter, rx_reg); - -l_free (rx_reg_old); - -l_queue_push_head (pvt->rx_regs, rx_reg); -return true; }
mesh/mesh-io.c +27 -18
88 lines not on this page · raw message
mesh/mesh-io.h +0 -2
@@ -8,8 +8,6 @@* */ -struct mesh_io ; -#define MESH_IO_TX_COUNT_UNLIMITED 0enum mesh_io_type {
Signature · 1 line
2.39.2
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=736008
---Test result---
Test Summary:
CheckPatch PASS 0.57 seconds GitLint PASS 0.32 seconds BuildEll PASS 32.36 seconds BluezMake PASS 1087.84 seconds MakeCheck PASS 11.80 seconds MakeDistcheck PASS 174.57 seconds CheckValgrind PASS 280.45 seconds CheckSmatch WARNING 387.23 seconds bluezmakeextell PASS 113.54 seconds IncrementalBuild PASS 892.63 seconds ScanBuild PASS 1250.51 seconds
Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:mesh/mesh-io-mgmt.c:523:67: warning: Variable length array is used.
---
Regards,
Linux Bluetooth
This patch was applied to bluetooth/bluez.git (master) by Brian Gix <[email protected]>:
Hello:
This patch was applied to bluetooth/bluez.git (master) by Brian Gix <[email protected]>:
Quoted 4 lines · On Fri, 31 Mar 2023 17:16:02 -0700 you wrote:
This fixes the out-of-bounds array access in
mesh-io-mgmt.ccaught by address sanitizer. Similar fixes were applied earlier to generic and unit IOs. With this patch, the common code is factored into a centralized location.
Quoted 8 lines
--- mesh/mesh-io-api.h | 7 +++++ mesh/mesh-io-generic.c | 70 ++++++------------------------------------ mesh/mesh-io-mgmt.c | 56 ++++----------------------------- mesh/mesh-io-unit.c | 30 ------------------ mesh/mesh-io.c | 45 ++++++++++++++++----------- mesh/mesh-io.h | 2 -- 6 files changed, 50 insertions(+), 160 deletions(-)
Here is the summary with links:
- [BlueZ,v2] mesh: Tighten IO and fix out-of-bounds array access
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=cffd5832a52c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html