-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: ieee802154_nrf5: Add payload length check on TX #60528
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
drivers: ieee802154_nrf5: Add payload length check on TX #60528
Conversation
In case upper layer does not follow the convention, and the net_pkt provided to the nRF 15.4 driver had a payload larger than the maximum payload size of an individual 15.4 frame, the driver would end up with buffer overflow. Fix this by adding an extra payload_len check before attempting to copy the payload to the internal buffer. Signed-off-by: Robert Lubos <[email protected]>
drivers/ieee802154/ieee802154_nrf5.c
Outdated
| uint8_t *payload = frag->data; | ||
| bool ret = true; | ||
|
|
||
| if (payload_len > NRF5_PSDU_LENGTH) { |
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.
Maybe this is a good opportunity to switch to IEEE802154_MTU instead everywhere and remove that custom constant which seems to be redundant? (of course not required at all - just an idea)
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.
I've removed the redefined constants and switched to use symbols defined in ieee802154.h header, where applicable in the driver.
Use generic symbols defined in ieee802154.h for packet/FCS size instead of redefining them in the driver header. Signed-off-by: Robert Lubos <[email protected]>
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.
Nice, you found even more constants, that can be replaced. Looks good!
In case upper layer does not follow the convention, and the net_pkt provided to the nRF 15.4 driver had a payload larger than the maximum payload size of an individual 15.4 frame, the driver would end up with buffer overflow.
Fix this by adding an extra payload_len check before attempting to copy the payload to the internal buffer.