-
Notifications
You must be signed in to change notification settings - Fork 8.1k
bt: host/classic: Fix possible integer overflow #97370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
build failure is not related with the change. |
if (sys_le16_to_cpu(hdr->len) > (UINT16_MAX - sizeof(*hdr))) { | ||
LOG_ERR("L2CAP PDU length overflow"); | ||
break; | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]>
|
Invalid header length and cause an integer overflow in bt_br_acl_recv leading to undesired behavior.