Skip to content

Commit 4114d55

Browse files
committed
IPv6 mobility: Add a check on the payload protocol type
RFC 3775 (and RFC 6275) section 6.1.1 states: Implementations conforming to this specification SHOULD set the payload protocol type to IPPROTO_NONE (59 decimal). Fix an indentation. Update 10 test outputs.
1 parent 2abf6a8 commit 4114d55

11 files changed

+22
-17
lines changed

print-mobility.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,18 @@ mobility_print(netdissect_options *ndo,
205205
const struct ip6_mobility *mh;
206206
const u_char *ep;
207207
unsigned mhlen, hlen;
208-
uint8_t type;
208+
uint8_t pproto, type;
209209

210210
ndo->ndo_protocol = "mobility";
211211
nd_print_protocol(ndo);
212212
ND_PRINT(": ");
213213
mh = (const struct ip6_mobility *)bp;
214214

215+
pproto = GET_U_1(mh->ip6m_pproto);
216+
if (pproto != IPPROTO_NONE)
217+
ND_PRINT("(payload protocol %u should be %u) ", pproto,
218+
IPPROTO_NONE);
219+
215220
/* 'ep' points to the end of available data. */
216221
ep = ndo->ndo_snapend;
217222

@@ -326,7 +331,7 @@ mobility_print(netdissect_options *ndo,
326331

327332
return(mhlen);
328333

329-
trunc:
334+
trunc:
330335
nd_print_trunc(ndo);
331336
return(-1);
332337
}

tests/cve2015-0261-ipv6.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1 2002-12-31 13:55:31.300000 IP6 [header+payload length 26510 > length 185] (invalid) (class 0x76, flowlabel 0x76767, hlim 103, next-header Mobility (135), payload length 26470) 6767:6767:6767:6767:6767:6767:6767:6767 > 6767:6767:6767:6767:6767:6767:6767:6705: mobility: BU seq#=26471 HL lifetime=105884(type-0x67: len=103) [|mobility]
2-
2 2003-03-06 15:21:11.300000 IP6 [header+payload length 26510 > length 185] (invalid) (class 0x76, flowlabel 0x76767, hlim 103, next-header Mobility (135), payload length 26470) 6767:6767:6767:6767:6767:6767:6767:6767 > 6767:6767:4f67:6767:6767:6767:6767:6767: mobility: (header length 8 is too small for type 6) [|mobility]
1+
1 2002-12-31 13:55:31.300000 IP6 [header+payload length 26510 > length 185] (invalid) (class 0x76, flowlabel 0x76767, hlim 103, next-header Mobility (135), payload length 26470) 6767:6767:6767:6767:6767:6767:6767:6767 > 6767:6767:6767:6767:6767:6767:6767:6705: mobility: (payload protocol 255 should be 59) BU seq#=26471 HL lifetime=105884(type-0x67: len=103) [|mobility]
2+
2 2003-03-06 15:21:11.300000 IP6 [header+payload length 26510 > length 185] (invalid) (class 0x76, flowlabel 0x76767, hlim 103, next-header Mobility (135), payload length 26470) 6767:6767:6767:6767:6767:6767:6767:6767 > 6767:6767:4f67:6767:6767:6767:6767:6767: mobility: (payload protocol 0 should be 59) (header length 8 is too small for type 6) [|mobility]

tests/ipv6-mobility-header-oobr.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1 1995-08-15 05:27:12.999999 IP6 3030:3030:3030:3030:3030:3030:3030:3030 > 3030:3030:3030:3030:3030:3030:3030:3030: mobility: BA status=48 [|mobility]
1+
1 1995-08-15 05:27:12.999999 IP6 3030:3030:3030:3030:3030:3030:3030:3030 > 3030:3030:3030:3030:3030:3030:3030:3030: mobility: (payload protocol 48 should be 59) BA status=48 [|mobility]

tests/mobility_opt_asan.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1 1975-04-27 07:53:17.131862 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) d400:7fa1:0:400::6238:2949 > 9675:86dd:7300:2c:1c7f:ffff:ffc3:b2a1: mobility: BU seq#=116 A lifetime=15872(pad1) [|mobility]
2-
2 2017-12-27 14:32:13.999999 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) d4c3:b2a1:200:400::6238:2949 > 9675:86dd:73f0:2c:1c7f:ffff:ebc3:b291: mobility: BU seq#=116 A lifetime=15360 [|mobility]
1+
1 1975-04-27 07:53:17.131862 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) d400:7fa1:0:400::6238:2949 > 9675:86dd:7300:2c:1c7f:ffff:ffc3:b2a1: mobility: (payload protocol 2 should be 59) BU seq#=116 A lifetime=15872(pad1) [|mobility]
2+
2 2017-12-27 14:32:13.999999 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) d4c3:b2a1:200:400::6238:2949 > 9675:86dd:73f0:2c:1c7f:ffff:ebc3:b291: mobility: (payload protocol 2 should be 59) BU seq#=116 A lifetime=15360 [|mobility]

tests/mobility_opt_asan_2.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1 1975-06-23 00:41:36.999999 IP6 (class 0x50, flowlabel 0x0002c, hlim 0, next-header Mobile IP (old) (62), payload length 7168) ff:7f0f:40:0:ee00:0:b658:5203 > 205:20:1:b00:0:2200:af01:e000: mobility: BRR(type-0x06: len=0) [|mobility]
1+
1 1975-06-23 00:41:36.999999 IP6 (class 0x50, flowlabel 0x0002c, hlim 0, next-header Mobile IP (old) (62), payload length 7168) ff:7f0f:40:0:ee00:0:b658:5203 > 205:20:1:b00:0:2200:af01:e000: mobility: (payload protocol 6 should be 59) BRR(type-0x06: len=0) [|mobility]

tests/mobility_opt_asan_3.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1 1975-04-27 07:53:17.131862 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) d400:7fa1:200:400::6238:2949 > 9675:86dd:7300:2c:1c7f:ffff:ffc3:b2a1: mobility: CoT nonce id=0x74 Care-of Init Cookie=80570f80:00000004 [|mobility]
2-
2 2017-12-27 14:32:13.999999 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) ffc3:b2a1:200:400::6238:2949 > 9675:86dd:73f0:2c:1c7f:ffff:ebc3:b2a1: mobility: BU seq#=39837 lifetime=261452 [|mobility]
1+
1 1975-04-27 07:53:17.131862 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) d400:7fa1:200:400::6238:2949 > 9675:86dd:7300:2c:1c7f:ffff:ffc3:b2a1: mobility: (payload protocol 2 should be 59) CoT nonce id=0x74 Care-of Init Cookie=80570f80:00000004 [|mobility]
2+
2 2017-12-27 14:32:13.999999 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) ffc3:b2a1:200:400::6238:2949 > 9675:86dd:73f0:2c:1c7f:ffff:ebc3:b2a1: mobility: (payload protocol 2 should be 59) BU seq#=39837 lifetime=261452 [|mobility]

tests/mobility_opt_asan_4.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1 2018-01-12 12:49:44.999999 IP6 (class 0x50, flowlabel 0x00004, hlim 237, next-header Mobile IP (old) (62), payload length 7168) d3c3:b2a9:200:400::6238:2949 > 9675:86dd:7300:2c:1c7f:ffff:ffc3:b2a1: mobility: BU seq#=116 A lifetime=15360(pad1)(pad1)(type-0x3c: len=19)(ni: ho=0x0400 co=0x0012) [|mobility]
1+
1 2018-01-12 12:49:44.999999 IP6 (class 0x50, flowlabel 0x00004, hlim 237, next-header Mobile IP (old) (62), payload length 7168) d3c3:b2a9:200:400::6238:2949 > 9675:86dd:7300:2c:1c7f:ffff:ffc3:b2a1: mobility: (payload protocol 2 should be 59) BU seq#=116 A lifetime=15360(pad1)(pad1)(type-0x3c: len=19)(ni: ho=0x0400 co=0x0012) [|mobility]

tests/mobility_opt_asan_5.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1 1975-06-23 00:41:36.999999 IP6 (class 0x50, flowlabel 0x0002c, hlim 0, next-header Mobile IP (old) (62), payload length 7168) ff:7f0f:40:0:ee00:0:b658:5203 > 205:20:1:b00:0:2200:af01:e000: mobility: BRR(type-0x06: len=0) [|mobility]
1+
1 1975-06-23 00:41:36.999999 IP6 (class 0x50, flowlabel 0x0002c, hlim 0, next-header Mobile IP (old) (62), payload length 7168) ff:7f0f:40:0:ee00:0:b658:5203 > 205:20:1:b00:0:2200:af01:e000: mobility: (payload protocol 6 should be 59) BRR(type-0x06: len=0) [|mobility]

tests/mobility_opt_asan_6.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1 1975-04-27 07:53:17.131862 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) d400:7fa1:0:400::6238:2949 > 9675:86dd:7300:2c:1c7f:ffff:ffc3:b2a1: mobility: BU seq#=116 A lifetime=15872(pad1) [|mobility]
2-
2 2017-12-27 14:32:13.999999 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) d4c3:b2a1:200:400::6238:2949 > 9675:86dd:73f0:2c:1c7f:ffff:ebc3:b291: mobility: BU seq#=116 A lifetime=15360 [|mobility]
1+
1 1975-04-27 07:53:17.131862 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) d400:7fa1:0:400::6238:2949 > 9675:86dd:7300:2c:1c7f:ffff:ffc3:b2a1: mobility: (payload protocol 2 should be 59) BU seq#=116 A lifetime=15872(pad1) [|mobility]
2+
2 2017-12-27 14:32:13.999999 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) d4c3:b2a1:200:400::6238:2949 > 9675:86dd:73f0:2c:1c7f:ffff:ebc3:b291: mobility: (payload protocol 2 should be 59) BU seq#=116 A lifetime=15360 [|mobility]

tests/mobility_opt_asan_7.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1 1975-04-27 07:53:17.131862 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) d400:7fa1:200:400::6238:2949 > 9675:86dd:7300:2c:1c7f:ffff:ffc3:b2a1: mobility: CoT nonce id=0x74 Care-of Init Cookie=80570f80:00000004 [|mobility]
2-
2 2017-12-27 14:32:13.999999 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) ffc3:b2a1:200:400::6238:2949 > 9675:86dd:73f0:2c:1c7f:ffff:ebc3:b2a1: mobility: BU seq#=39837 lifetime=261452 [|mobility]
1+
1 1975-04-27 07:53:17.131862 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) d400:7fa1:200:400::6238:2949 > 9675:86dd:7300:2c:1c7f:ffff:ffc3:b2a1: mobility: (payload protocol 2 should be 59) CoT nonce id=0x74 Care-of Init Cookie=80570f80:00000004 [|mobility]
2+
2 2017-12-27 14:32:13.999999 IP6 (class 0x50, flowlabel 0x00004, hlim 0, next-header Mobile IP (old) (62), payload length 7168) ffc3:b2a1:200:400::6238:2949 > 9675:86dd:73f0:2c:1c7f:ffff:ebc3:b2a1: mobility: (payload protocol 2 should be 59) BU seq#=39837 lifetime=261452 [|mobility]

0 commit comments

Comments
 (0)