Page MenuHomeFreeBSD

tests: exercise unix `connectat(2)` with a socket peer descriptor
ClosedPublic

Authored by inquire_JohnEricson.me on Wed, Jul 22, 9:37 PM.
Tags
None
Referenced Files
F166698041: D58406.id183496.diff
Sat, Aug 15, 5:07 PM
Unknown Object (File)
Mon, Aug 10, 9:43 PM
Unknown Object (File)
Mon, Aug 10, 3:04 PM
Unknown Object (File)
Sun, Aug 9, 9:34 AM
Unknown Object (File)
Sat, Aug 8, 4:14 PM
Unknown Object (File)
Sat, Aug 8, 6:13 AM
Unknown Object (File)
Thu, Aug 6, 3:06 PM
Unknown Object (File)
Thu, Aug 6, 4:13 AM
Subscribers

Details

Summary

Cover the new fd-direct connect path: stream connect and data passing,
the peer address reported by getpeername(2), datagram to an unbound
peer, the EINVAL/ENOTSOCK/EPROTOTYPE/ECONNREFUSED error matrix,
and the Capsicum token semantics — a descriptor limited to
CAP_CONNECTAT can be connected to but not listened on, accepted from,
or read, and one lacking CAP_CONNECTAT cannot be a connect target.

Stream listeners are always bound: uipc_listen() refuses unbound
sockets with EDESTADDRREQ, so an unbound fd-direct listener is not
reachable even with this feature.

Signed-off-by: John Ericson <John.Ericson@Obsidian.Systems>
Assisted-by: Claude Code (Claude Opus 4.8 and Fable 5)

Diff Detail

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

Event Timeline

These tests don't exercise fdescfs lookups, nor handling of O_PATH sockets. Were you planning to add something for that? It should be fairly easy to create fdescfs mounts from within the tests themselves, tests/sys/kern/jail_lookup_root.c has some examples of this.

tests/sys/kern/unix_connectat.c
98

Not hugely important, but I think it's good form to check for errors from close(), doing so can catch test bugs (and, rarely, kernel bugs).

These tests don't exercise fdescfs lookups, nor handling of O_PATH sockets. Were you planning to add something for that?

There is some leniency in here so that the tests pass with or without fdescfs, but I didn't know it was OK to mount it within the tests. I'll go do that instead; that's definitely better! And I'll make sure we get O_PATH tested too.

It should be fairly easy to create fdescfs mounts from within the tests themselves, tests/sys/kern/jail_lookup_root.c has some examples of this.

Thanks, that will be useful to make sure I get the idiom correct.

tests/sys/kern/unix_connectat.c
98

Oh oops I admit I didn't notice that --- I absolutely agree. Will fix.

Test all the fdescfs combinations explicitly

This revision is now accepted and ready to land.Mon, Aug 10, 4:20 PM