Skip to content

Commit c5c912a

Browse files
committed
NFS: Add two length checks
This change avoids adding a large number to the packet pointer and overflow it. It also avoids the differences between 32-bit and 64-bit printouts. Example: 32-bit: NFS request xid 1168185174 80 readdirplus fh / 1441792 bytes @ 1585267068834414592 [|nfs] --- 64-bit: NFS request xid 1168185174 80 readdirplus [|nfs] Add a test file. Update a test output accordingly. (cherry picked from commit 47edb26)
1 parent 4966c76 commit c5c912a

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

print-nfs.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,11 @@ parsereq(netdissect_options *ndo,
434434
if (length < 2 * sizeof(*dp))
435435
goto trunc;
436436
len = GET_BE_U_4(dp + 1);
437+
if (len > length) {
438+
ND_PRINT(" [credentials length %u > %u]", len, length);
439+
nd_print_invalid(ndo);
440+
return NULL;
441+
}
437442
rounded_len = roundup2(len, 4);
438443
ND_TCHECK_LEN(dp + 2, rounded_len);
439444
if (2 * sizeof(*dp) + rounded_len <= length) {
@@ -453,6 +458,11 @@ parsereq(netdissect_options *ndo,
453458
if (length < 2 * sizeof(*dp))
454459
goto trunc;
455460
len = GET_BE_U_4(dp + 1);
461+
if (len > length) {
462+
ND_PRINT(" [verifier length %u > %u]", len, length);
463+
nd_print_invalid(ndo);
464+
return NULL;
465+
}
456466
rounded_len = roundup2(len, 4);
457467
ND_TCHECK_LEN(dp + 2, rounded_len);
458468
if (2 * sizeof(*dp) + rounded_len < length) {

tests/TESTLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ macsec-short-valid macsec-short-valid.pcap macsec-short-valid.out -e
766766
# NFS tests
767767
# fuzzed pcap
768768
nfs-write-verf-cookie nfs-write-verf-cookie.pcapng nfs-write-verf-cookie.out -vv
769+
nfs_large_credentials_length nfs_large_credentials_length.pcap nfs_large_credentials_length.out
769770

770771
# NFS fuzzed
771772
nfs-seg-fault-1 nfs-seg-fault-1.pcapng nfs-seg-fault-1.out

tests/nfs-attr-oobr.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,5 +301,5 @@
301301
0x0030: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000
302302
0x0040: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000
303303
0x0050: 3030 00
304-
47 1995-08-15 05:27:12.808464432 IP 48.48.48.48.12336 > 48.48.48.48.2049: NFS request xid 3056611558 12308 access [|nfs]
304+
47 1995-08-15 05:27:12.808464432 IP 48.48.48.48.12336 > 48.48.48.48.2049: NFS request xid 3056611558 12308 access [credentials length 808464432 > 12308] (invalid) [|nfs]
305305
48 1995-08-15 05:27:12.808464432 IP 48.48.48.48.2049 > 48.48.48.48.12336: NFS reply xid 3056611558 reply ok 12308 access [|nfs]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 1971-09-12 02:15:12.134350544 IP 255.10.0.1.63476 > 127.0.0.1.2049: NFS request xid 1168185174 80 readdirplus [credentials length 4294967295 > 80] (invalid) [|nfs]
147 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)