Skip to content

Conversation

ceolin
Copy link
Member

@ceolin ceolin commented Oct 10, 2025

Invalid header length and cause an integer overflow in bt_br_acl_recv leading to undesired behavior.

@ceolin
Copy link
Member Author

ceolin commented Oct 10, 2025

sample.mcumgr.smp_svr.udp.802154.subg on beagleconnect_freedom/cc1352p7 error (CMake build failure - CMake Error at /__w/zephyr/zephyr/cmake/modules/kconfig.cmake:306 (message): File not found:)

build failure is not related with the change.

Comment on lines 158 to 161
if (sys_le16_to_cpu(hdr->len) > (UINT16_MAX - sizeof(*hdr))) {
LOG_ERR("L2CAP PDU length overflow");
break;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be simpler to just change acl_total_len to be uint32_t? That'll likely generate a bit more efficient code to since it's the native word size on most Zephyr platforms.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that works. I hadn't seen hdr->len type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally we have the host endianness type sizes match the protocol type size, but in this case using a larger host endian type seems like a reasonable option to avoid pitfalls with the subsequent arithmetic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern with changing the type here is that if that structure changes its type hdr->len we will silently end up with the same problem again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which structure? The type of hdr? That's based on a standard protocol specification, so it will never change.

Invalid header length and cause an integer overflow in
bt_br_acl_recv leading to undesired behavior.

Signed-off-by: Flavio Ceolin <[email protected]>
Copy link

@cfriedt cfriedt merged commit dabe815 into zephyrproject-rtos:main Oct 15, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants