Page MenuHomeFreeBSD

irdma: improve validation checks further
Needs ReviewPublic

Authored by rscheff on Jul 18 2026, 2:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Aug 15, 11:40 PM
Unknown Object (File)
Sat, Aug 15, 3:09 PM
Unknown Object (File)
Sat, Aug 15, 12:10 PM
Unknown Object (File)
Thu, Aug 13, 5:13 PM
Unknown Object (File)
Wed, Aug 12, 5:28 PM
Unknown Object (File)
Wed, Aug 12, 5:56 AM
Unknown Object (File)
Tue, Aug 11, 10:09 PM
Unknown Object (File)
Mon, Aug 10, 10:13 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 74915
Build 71798: arc lint + arc unit

Event Timeline

Owners added a reviewer: Restricted Owners Package.Jul 18 2026, 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

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