Page MenuHomeFreeBSD

ktrace: Record namei violations with KTR_CAPFAIL
ClosedPublic

Authored by jfree on Jun 20 2023, 10:08 PM.
Referenced Files
Unknown Object (File)
Fri, Nov 15, 6:59 AM
Unknown Object (File)
Thu, Nov 14, 2:46 AM
Unknown Object (File)
Sat, Nov 9, 2:52 PM
Unknown Object (File)
Thu, Nov 7, 4:00 PM
Unknown Object (File)
Wed, Nov 6, 9:15 PM
Unknown Object (File)
Tue, Nov 5, 7:39 AM
Unknown Object (File)
Oct 18 2024, 7:51 AM
Unknown Object (File)
Oct 17 2024, 1:59 PM
Subscribers

Details

Summary
Report namei path lookups while Capsicum violation tracing with
CAPFAIL_NAMEI. vfs caching is also ignored when tracing to mimic
capability mode behavior.

Programs that are not yet Capsicumized may be traced to discover
potential capability failures. With `ktrace -t p` and kdump, you
are given a list of syscalls as a starting point for program
Capsicumization.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Change NI_LCF_STRICTRELATIVE to NI_LCF_STRICTREL where applicable.

sys/kern/uipc_syscalls.c
496

Consider making it a bit clearer that this is symbolic by writing "<AT_FDCWD>" instead, same above.

sys/kern/vfs_lookup.c
245

Are you sure that this string is nul-terminated?

jfree marked an inline comment as done.Jan 9 2024, 4:14 AM
jfree added inline comments.
sys/kern/vfs_lookup.c
245

Are you sure that this string is nul-terminated?

It looks like cn_pnbuf is copied in using copyinstr(9) inside of namei_getpath(). A quick look at some copyinstr(9) assembly indicates that its return buffer will be nul-terminated upon success.

namei_getpath() is called at the beginning of the namei() routine, so I'm pretty certain that cn_pnbuf should always be nul-terminated.

sys/kern/vfs_lookup.c
245

I should also note that it doesn't look like cn_pnbuf is modified anywhere, so its nul-terminator should never be overwritten.

Replace all instances of "AT_FDCWD" with "<AT_FDCWD>" when reporting a violation via ktrcapfail().

This revision is now accepted and ready to land.Jan 18 2024, 3:46 PM
jfree retitled this revision from ktrace: Record vfs violations with KTR_CAPFAIL to ktrace: Record namei violations with KTR_CAPFAIL.Mar 10 2024, 4:23 AM
jfree edited the summary of this revision. (Show Details)
  • Record *namei* violations instead of vfs. Slight wording change for clarity.
  • Rebase on main after several months
This revision now requires review to proceed.Mar 10 2024, 4:24 AM
This revision is now accepted and ready to land.Mar 29 2024, 3:34 PM