Page MenuHomeFreeBSD

ktrace: Record namei violations with KTR_CAPFAIL
ClosedPublic

Authored by jfree on Jun 20 2023, 10:08 PM.
Referenced Files
F106162180: D40680.diff
Thu, Dec 26, 10:10 AM
Unknown Object (File)
Fri, Dec 6, 12:42 PM
Unknown Object (File)
Nov 25 2024, 8:58 PM
Unknown Object (File)
Nov 24 2024, 10:27 AM
Unknown Object (File)
Nov 24 2024, 6:31 AM
Unknown Object (File)
Nov 23 2024, 6:57 AM
Unknown Object (File)
Nov 23 2024, 6:54 AM
Unknown Object (File)
Nov 23 2024, 6:53 AM
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
500

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