Skip to contentSkip to conversation

l2tpv3: fix cookie decoding

PATCH Applied Alexis Dambricourt 2 participants 2 messages Jan 4, 2016 – Jan 6, 2016 Networking

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 l2tpv3: fix cookie decoding

If a 32 bits l2tpv3 frame cookie MSB if set to 1, the cast to uint64_t cookie will spread 1 to the four most significant bytes. Then the condition (cookie != s->rx_cookie) becomes false.

---
 net/l2tpv3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/l2tpv3.c +1 -1
index 8e68e54..21d6119 100644
@@ -325,7 +325,7 @@ static int l2tpv3_verify_header(NetL2TPV3State *s, uint8_t *buf)
         if (s->cookie_is_64) {
             cookie = ldq_be_p(buf + s->cookie_offset);
         } else {
-            cookie = ldl_be_p(buf + s->cookie_offset);
+            cookie = ldl_be_p(buf + s->cookie_offset) & 0xffffffffULL;
         }
         if (cookie != s->rx_cookie) {
             if (!s->header_mismatch) {
Signature · 1 line
2.6.4
Applied
#1 lore raw
Quoted 14 lines · Alexis Dambricourt

If a 32 bits l2tpv3 frame cookie MSB if set to 1, the cast to uint64_t cookie will spread 1 to the four most significant bytes. Then the condition (cookie != s->rx_cookie) becomes false.

---
 net/l2tpv3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/l2tpv3.c +0 -0
index 8e68e54..21d6119 100644

net/l2tpv3.c static int l2tpv3_verify_header(NetL2TPV3State *s, uint8_t *buf) · line 331

Quoted 8 lines
net/l2tpv3.c +1 -1
@@ -325,7 +325,7 @@ static int l2tpv3_verify_header(NetL2TPV3State *s, uint8_t *buf)
         if (s->cookie_is_64) {
             cookie = ldq_be_p(buf + s->cookie_offset);
         } else {
-            cookie = ldl_be_p(buf + s->cookie_offset);
+            cookie = ldl_be_p(buf + s->cookie_offset) & 0xffffffffULL;
         }
         if (cookie != s->rx_cookie) {
             if (!s->header_mismatch) {

Applied to my -net.

Thanks