Skip to contentSkip to conversation

net: rpl: fix rpl header size calculation

PATCH Superseded Alexander Aring 2 participants 3 messages Apr 15, 2023 – Apr 16, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: rpl: fix rpl header size calculation

This patch fixes a missing 8 byte for the header size calculation. The ipv6_rpl_srh_size() is used to check a skb_pull() on skb->data which points to skb_transport_header(). Currently we only check on the calculated addresses fields using CmprI and CmprE fields, see:

https://www.rfc-editor.org/rfc/rfc6554#section-3

there is however a missing 8 byte inside the calculation which stands for the fields before the addresses field.

Fixes 8610c7c6e3bd ("net: ipv6: add support for rpl sr exthdr")
---
 net/ipv6/rpl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/rpl.c +1 -1
index 488aec9e1a74..16e19fec18a4 100644
@@ -32,7 +32,7 @@ static void *ipv6_rpl_segdata_pos(const struct ipv6_rpl_sr_hdr *hdr, int i)
 size_t ipv6_rpl_srh_size(unsigned char n, unsigned char cmpri,
 			 unsigned char cmpre)
 {
-	return (n * IPV6_PFXTAIL_LEN(cmpri)) + IPV6_PFXTAIL_LEN(cmpre);
+	return 8 + (n * IPV6_PFXTAIL_LEN(cmpri)) + IPV6_PFXTAIL_LEN(cmpre);
 }
 
 void ipv6_rpl_srh_decompress(struct ipv6_rpl_sr_hdr *outhdr,
Signature · 1 line
2.31.1
#1 lore raw

net/ipv6/rpl.c static void *ipv6_rpl_segdata_pos(const struct ipv6_rpl_sr_hdr *hdr, int i) · line 35

Quoted 10 lines · Alexander Aring
net/ipv6/rpl.c +1 -1
index 488aec9e1a74..16e19fec18a4 100644
@@ -32,7 +32,7 @@ static void *ipv6_rpl_segdata_pos(const struct ipv6_rpl_sr_hdr *hdr, int i)
 size_t ipv6_rpl_srh_size(unsigned char n, unsigned char cmpri,
 			 unsigned char cmpre)
 {
-	return (n * IPV6_PFXTAIL_LEN(cmpri)) + IPV6_PFXTAIL_LEN(cmpre);
+	return 8 + (n * IPV6_PFXTAIL_LEN(cmpri)) + IPV6_PFXTAIL_LEN(cmpre);

no magic numbers; there should be a macro for that size.

#2 lore raw

Hi,

Quoted 17 lines · David Ahern

net/ipv6/rpl.c static void *ipv6_rpl_segdata_pos(const struct ipv6_rpl_sr_hdr *hdr, int i) · line 35

Quoted 10 lines · Alexander Aring
net/ipv6/rpl.c +1 -1
index 488aec9e1a74..16e19fec18a4 100644
@@ -32,7 +32,7 @@ static void *ipv6_rpl_segdata_pos(const struct ipv6_rpl_sr_hdr *hdr, int i)
 size_t ipv6_rpl_srh_size(unsigned char n, unsigned char cmpri,
                       unsigned char cmpre)
 {
-     return (n * IPV6_PFXTAIL_LEN(cmpri)) + IPV6_PFXTAIL_LEN(cmpre);
+     return 8 + (n * IPV6_PFXTAIL_LEN(cmpri)) + IPV6_PFXTAIL_LEN(cmpre);

no magic numbers; there should be a macro for that size.

ok. We can actually use sizeof(*hdr) here. Which is actually the header size without the "addresses" payload.

Thanks.

- Alex