Page MenuHomeFreeBSD

ping: Test IHL/quoted data/inner packet paths
ClosedPublic

Authored by jlduran on Feb 12 2023, 3:04 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 8, 10:25 PM
Unknown Object (File)
Sep 25 2024, 8:49 PM
Unknown Object (File)
Sep 25 2024, 9:03 AM
Unknown Object (File)
Sep 25 2024, 6:51 AM
Unknown Object (File)
Sep 25 2024, 1:43 AM
Unknown Object (File)
Sep 23 2024, 5:12 PM
Unknown Object (File)
Sep 23 2024, 12:18 AM
Unknown Object (File)
Sep 22 2024, 1:07 PM

Details

Summary

Commit 46d7b45a267b3d78c5054b210ff7b6c55bfca42b introduced these code paths.
Test and document them.

Test Plan

With a FreeBSD kernel I was not able to reach some of them. I've documented the tests used.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sbin/ping/ping.c
1174 ↗(On Diff #117025)

I don't really agree with this part of the change. Really we are assuming that the kernel (or rather, the caller of pr_pack()) won't give us malformed/truncated packets. But this could happen as a result of a kernel bug. We've had security bugs in the past wherein the kernel's implementation of raw sockets would omit some validation before passing a packet to userland, and userland didn't handle certain cases because it expected the kernel to handle them.

So if we're going to annotate this code path at all, I'd suggest having a comment which explains that we expect these conditions to always be false, but we check anyway out of paranoia. NOTREACHED suggests that the code is provably unreachable, and I don't think it's the right annotation here.

sbin/ping/ping.c
1174 ↗(On Diff #117025)

I see... good point. I'll update the patch removing the NOTREACHED comments.
Those annotations are in the tests, if for some reason, a kernel bug is introduced, the tests should fail.

jlduran retitled this revision from ping: Document NOTREACHED paths to ping: Test IHL/quoted data/inner packet paths.
jlduran edited the summary of this revision. (Show Details)
jlduran edited the test plan for this revision. (Show Details)
This revision is now accepted and ready to land.Feb 14 2023, 2:09 PM
This revision was automatically updated to reflect the committed changes.