Page MenuHomeFreeBSD

Capsicumify open.2
ClosedPublic

Authored by cem on Sep 19 2016, 3:39 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 15 2024, 3:27 PM
Unknown Object (File)
Mar 15 2024, 3:26 PM
Unknown Object (File)
Jan 5 2024, 1:07 PM
Unknown Object (File)
Dec 20 2023, 2:34 AM
Unknown Object (File)
Nov 25 2023, 3:38 AM
Unknown Object (File)
Nov 13 2023, 5:50 PM
Unknown Object (File)
Nov 10 2023, 9:43 PM
Unknown Object (File)
Nov 9 2023, 1:30 PM
Subscribers

Details

Summary

Document open(2) and openat(2) behavior in Capsicum capability mode.

Test Plan

igor clean

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

cem retitled this revision from to Capsicumify open.2.
cem updated this object.
cem edited the test plan for this revision. (Show Details)
cem added reviewers: allanjude, emaste, wblock, rwatson.
lib/libc/sys/open.2
105 ↗(On Diff #20473)

might be good to mention that it is a DIRECTORY descriptor

lib/libc/sys/open.2
105 ↗(On Diff #20473)

That's covered on line 79-80. In this paragraph, I just want to highlight the difference in behavior in the capability mode sandbox.

ed requested changes to this revision.Sep 19 2016, 5:23 AM
ed added a reviewer: ed.
ed added a subscriber: ed.
ed added inline comments.
lib/libc/sys/open.2
108 ↗(On Diff #20473)

I'm not sure this is true. I thought the actual rules were:

  • Paths must be relative. Absolute paths are rejected immediately.
  • During resolution, the path must stay below the directory at all times.

"a/../b/../c/d/../.." is okay. "a/../../b" is not.

This revision now requires changes to proceed.Sep 19 2016, 5:23 AM
lib/libc/sys/open.2
108 ↗(On Diff #20473)
lib/libc/sys/open.2
108 ↗(On Diff #20473)

Ah, got it. Then disregard my comment. :-)

lib/libc/sys/open.2
105 ↗(On Diff #20473)

It's hard to tell what the quote marks mean. They kind of look sarcastic, and might give the opposite of the intended meaning. But the intended meaning is not clear. Maybe remove the quotes and be more specific about the term, or use .Xr to refer to a definition.

lib/libc/sys/open.2
105 ↗(On Diff #20473)

This is a technical document; they're not sarcasm quotes.

They refer to a specific clause with identical quotation in the source code. There's no definition elsewhere in .Xr.

201 #ifdef CAPABILITY_MODE
202         /*
203          * In capability mode, lookups must be "strictly relative" (i.e.
204          * not an absolute path, and not containing '..' components) to
205          * a real file descriptor, not the pseudo-descriptor AT_FDCWD.
206          */
lib/libc/sys/open.2
105 ↗(On Diff #20473)

Maybe just removing the quotes is a good solution?

lib/libc/sys/open.2
105 ↗(On Diff #20473)

And possibly add a reference to the source file:

must be strictly relative to a real file descriptor
.Fa fd ,
as defined in
.Pa sys/kern/vfs_lookup.c .

In general, this seems like a good idea. A bit of wordsmithing does help, and reviewing an updated commit candidate before it goes into the tree wouldn't hurt if you can tolerate another RTT with reviewers :-).

lib/libc/sys/open.2
98 ↗(On Diff #20473)

I wonder if an explicit .Xr to capsicum(4) might be appropriate here?

112 ↗(On Diff #20473)

I'm not sure we need to mention bogus values? People who pass bogus values to openat(2) deserve failure modes.

Just to confirm the above: no use of "..", either in the string passed, nor in symbolic links, is permitted in paths looked up in capability mode.

cem edited edge metadata.
cem marked 5 inline comments as done.

Remove quotes; reference source file.

cem marked 2 inline comments as done.
cem edited edge metadata.
  • Xr capsicum 4
  • Specify symlinks may not contain .. too
  • Remove mention of bogus fd values
ed edited edge metadata.
This revision is now accepted and ready to land.Sep 30 2016, 7:19 PM
emaste edited edge metadata.
emaste added inline comments.
lib/libc/sys/open.2
107 ↗(On Diff #20873)

I would drop "real" here.

cem edited edge metadata.

Remove "real". File descriptor + no AT_FDCWD later in paragraph is sufficient, per emaste@.

This revision now requires review to proceed.Sep 30 2016, 7:25 PM
emaste edited edge metadata.
This revision is now accepted and ready to land.Sep 30 2016, 8:41 PM
This revision was automatically updated to reflect the committed changes.