Page MenuHomeFreeBSD

irdma: improve validation checks further
Needs ReviewPublic

Authored by rscheff on Sat, Jul 18, 2:24 PM.
Tags
None
Referenced Files
F164505223: D58325.id182179.diff
Sat, Aug 1, 12:56 PM
Unknown Object (File)
Wed, Jul 29, 9:40 AM
Unknown Object (File)
Mon, Jul 27, 11:46 PM
Unknown Object (File)
Mon, Jul 27, 11:27 PM
Unknown Object (File)
Mon, Jul 27, 9:48 PM
Unknown Object (File)
Mon, Jul 27, 6:50 PM
Unknown Object (File)
Mon, Jul 27, 4:34 PM
Unknown Object (File)
Mon, Jul 27, 4:09 PM
Subscribers

Details

Reviewers
tuexen
markj
kgalazka
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Summary
Verify  various IP header fields
Check that no no extention headers (IPv6) are present
Check that no IPv4 options are present

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 74914
Build 71797: arc lint + arc unit

Event Timeline

Owners added a reviewer: Restricted Owners Package.Sat, Jul 18, 2:24 PM
sys/dev/irdma/irdma_utils.c
1525

Isn't this check redundant? The check below for iphlen != (iph->ip_hl << 2) will catch this case too: iphlen is either 20 or 40, so if iph->ip_hl < 5, then iph->ip_hl << 2 must be less than 20.

sys/dev/irdma/irdma_utils.c
1614

Why isn't it necessary to patch this function as well?

rscheff added inline comments.
sys/dev/irdma/irdma_utils.c
1525

The issue is that iphlen is not extracted from the actual packets, but populated just by assuming the header is either IPv4 or IPv6; IP headers are variable length with IPv4. iph->ip_hl is the data extracted from the actual header. And with IPv6, one can use extention headers between the IP and TCP header, to dynamically shift the actual TCP (and iWARP) offset around.

These are representing valid uses of IP, and while it is maybe possible the firmware filters this out, ensuring the conformaty in the slow path here seems prudent.

1614

Fixed in D58323, thx.

markj added inline comments.
sys/dev/irdma/irdma_utils.c
1523–1524

Do we need to check that the received buffer is large enough to contain an IP header, before we start dereferencing iph?