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)
Sun, Jan 26, 1:17 AM
Unknown Object (File)
Thu, Jan 23, 6:49 PM
Unknown Object (File)
Mon, Jan 20, 9:23 PM
Unknown Object (File)
Sat, Jan 18, 9:35 PM
Unknown Object (File)
Fri, Jan 17, 10:07 PM
Unknown Object (File)
Dec 30 2024, 7:02 AM
Unknown Object (File)
Dec 26 2024, 11:08 PM
Unknown Object (File)
Dec 26 2024, 10:10 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