Page MenuHomeFreeBSD

cat: Capsicumize without libcasper
Needs ReviewPublic

Authored by markj on Mon, Jun 15, 3:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jul 9, 7:50 AM
Unknown Object (File)
Wed, Jul 1, 5:04 PM
Unknown Object (File)
Wed, Jul 1, 5:01 PM
Unknown Object (File)
Tue, Jun 30, 3:08 PM
Unknown Object (File)
Tue, Jun 30, 3:05 PM
Unknown Object (File)
Wed, Jun 24, 6:36 PM
Unknown Object (File)
Wed, Jun 24, 8:02 AM
Unknown Object (File)
Wed, Jun 24, 3:56 AM
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary
  • Pre-open directory fds for the cwd and root dir. Use those to open all paths specified on the command line. This weakens the sandbox slightly, but avoids forking.
  • For unix sockets, just try all of the socket types in turn rather than using getaddrinfo(), which can't easily be used in capability mode.
  • Limit stdio descriptors.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 73885
Build 70768: arc lint + arc unit

Event Timeline

markj requested review of this revision.Mon, Jun 15, 3:45 PM

If you could wait a little before making this change, I'd appreciate it. I'm currently working on a similar mechanism built into fileargs when the number of file descriptors is below the cache size.

It should then be applicable to all programs, such as head, tail, etc.

If you could wait a little before making this change, I'd appreciate it.

This is just a proposal, I am not planning on committing it yet.

I'm currently working on a similar mechanism built into fileargs when the number of file descriptors is below the cache size.

It should then be applicable to all programs, such as head, tail, etc.

Won't you still need cap_net for unix domain sockets?

I really think cap_fileargs is the wrong approach for unix filter programs. Pre-opening files gives subtly different semantics, e.g., if a path is a FIFO, or output from the command is redirected to an input file. I guess most of the performance overhead can be mitigated by avoiding fork() for some threshold number of files, but what's the right threshold?