-
Notifications
You must be signed in to change notification settings - Fork 2k
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
gnrc_ipv6: validates payload size #5033
Conversation
I'll wait with my review for #4654 to be merged. |
Needs rebase. |
a56949a
to
d0a7b9d
Compare
Rebased. |
Will test at today's Hack'n'ACK |
Is not working with NHC (without fragmentation) activated. Strong guess (that's why I tested it with NHC): the decompression marks the UDP header already, making |
Fixed. Your advice to promote |
Now I have a failed assertion :/ |
Could you try yourself? USEMODULE=gnrc_sixlowpan_iphc_nhc make -C examples/gnrc_networking/ and using the |
I forgot to subtract IPv6 header size. Fixed. BTW, I met an assertion failure in |
Yes, I'm running into it, too. |
lldb shows it is the assertion below: if (!interested) {
assert(current == pkt);
/* IPv6 is not interested anymore so `- 1` */
receiver_num--;
} where GNRC_NETTYPE_UDP←pkt When I wrote that assertion, I assumed that the function receives only IPv6 headers, extension headers, and unparsed payload but it was wrong. BTW, below line is also wrong:
this should be |
Are you working on a fix for that or should I look into it? |
No. Could you look into it? Especially, I'm not sure how to broadcast the packet. |
Fixed in #5281. The receiver isn't crashing anymore with both PRs merged, but its still not received properly. |
#5281 was merged, please rebase. |
88b424d
to
bf0c9e0
Compare
Rebased. |
|
Wait, does not work, when payload size is >99 (fragmentation threshold). |
(I merged current master) |
Could you provide some details? |
I used |
bf0c9e0
to
db09c1c
Compare
Fixed. I also made a 6LoWPAN test with header compression and fragmentation: #5502. |
@@ -885,6 +886,14 @@ static void _receive(gnrc_pktsnip_t *pkt) | |||
if (byteorder_ntohs(hdr->len) < pkt->size) { | |||
gnrc_pktbuf_realloc_data(pkt, byteorder_ntohs(hdr->len)); | |||
} | |||
else if (byteorder_ntohs(hdr->len) > | |||
(gnrc_pkt_len_upto(pkt, GNRC_NETTYPE_IPV6) - sizeof(ipv6_hdr_t))) { | |||
DEBUG("ipv6: invalid payload length: %d, acutal: %d, dropping packet\n", |
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.
"actual"
Apart from the typo: ACK, please squash. |
db09c1c
to
0de34c9
Compare
Fixed typo, squashed. |
This PR adds validation of
This PR will protect RIOT from malicious packet trying to access outside of the buffer.
This PR depends on
#4654(merged). I will rebase as soon as #4654 is merged.