Skip to content

Commit 47edb26

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.
1 parent 067f7dd commit 47edb26

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
@@ -432,6 +432,11 @@ parsereq(netdissect_options *ndo,
432432
if (length < 2 * sizeof(*dp))
433433
goto trunc;
434434
len = GET_BE_U_4(dp + 1);
435+
if (len > length) {
436+
ND_PRINT(" [credentials length %u > %u]", len, length);
437+
nd_print_invalid(ndo);
438+
return NULL;
439+
}
435440
rounded_len = roundup2(len, 4);
436441
ND_TCHECK_LEN(dp + 2, rounded_len);
437442
if (2 * sizeof(*dp) + rounded_len <= length) {
@@ -451,6 +456,11 @@ parsereq(netdissect_options *ndo,
451456
if (length < 2 * sizeof(*dp))
452457
goto trunc;
453458
len = GET_BE_U_4(dp + 1);
459+
if (len > length) {
460+
ND_PRINT(" [verifier length %u > %u]", len, length);
461+
nd_print_invalid(ndo);
462+
return NULL;
463+
}
454464
rounded_len = roundup2(len, 4);
455465
ND_TCHECK_LEN(dp + 2, rounded_len);
456466
if (2 * sizeof(*dp) + rounded_len < length) {

tests/TESTLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,7 @@ macsec-short-valid macsec-short-valid.pcap macsec-short-valid.out -e
836836
# NFS tests
837837
# fuzzed pcap
838838
nfs-write-verf-cookie nfs-write-verf-cookie.pcapng nfs-write-verf-cookie.out -vv
839+
nfs_large_credentials_length nfs_large_credentials_length.pcap nfs_large_credentials_length.out
839840

840841
# NFS fuzzed
841842
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)