Page MenuHomeFreeBSD

ktrace: Record namei violations with KTR_CAPFAIL
ClosedPublic

Authored by jfree on Jun 20 2023, 10:08 PM.
Referenced Files
F104336893: D40680.id135580.diff
Fri, Dec 6, 12:42 PM
Unknown Object (File)
Mon, Nov 25, 8:58 PM
Unknown Object (File)
Sun, Nov 24, 10:27 AM
Unknown Object (File)
Sun, Nov 24, 6:31 AM
Unknown Object (File)
Sat, Nov 23, 6:57 AM
Unknown Object (File)
Sat, Nov 23, 6:54 AM
Unknown Object (File)
Sat, Nov 23, 6:53 AM
Unknown Object (File)
Sat, Nov 23, 6:49 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 Not Applicable
Unit
Tests Not Applicable

Event Timeline

Change NI_LCF_STRICTRELATIVE to NI_LCF_STRICTREL where applicable.

sys/kern/uipc_syscalls.c
477

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

sys/kern/vfs_lookup.c
243

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
243

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
243

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