Details
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 20178
Event Timeline
lib/libc/sys/open.2 | ||
---|---|---|
273 | Worded slightly better: .Dv O_BENEATH |
I accept absolute paths for O_BENEATH. This can be tweaked, I am not sure what is the useful approach there.
Did the comparision. That revision:
- Does not accept absolute paths for O_BENEATH.
- Returns EPERM instead of ENOTCAPABLE.
- Does not use the dotdot tracker since the revision was written before I introduced it.
- There is no AT_BENEATH.
I can reproduce features 1 and 2, please provide your opinions.
Unconditionally allowing absolute paths with O_BENEATH seems a bit strange, as I expect this to be used for partially untrusted paths. An application can easily check for absolute paths and cause either behaviour (allowing or disallowing).
Not all functions that now accept AT_BENEATH have this mentioned in their man page.
This was one of my questions. But, it is not clear to me what change, if any, you are proposing.
Not all functions that now accept AT_BENEATH have this mentioned in their man page.
Yes, I do not want to copy/paste text from fstatat(2) until the patch is finalized.
I propose to disallow absolute paths with O_BENEATH, resulting in the [ENOTCAPABLE] error.
Not all functions that now accept AT_BENEATH have this mentioned in their man page.
Yes, I do not want to copy/paste text from fstatat(2) until the patch is finalized.
Fair enough.
lib/libc/sys/access.2 | ||
---|---|---|
124 ↗ | (On Diff #49360) | I would rephrase these to avoid the negative - something like "Only allow operation on a file which is a child of the starting directory." |
lib/libc/sys/utimensat.2 | ||
275 ↗ | (On Diff #49360) | or contained a ".." component ? Also I think I would put the AT_BENEATH flag first (since it's the unusual case), The AT_BENEATH flag was specified, and path was absolute or contained a ".." component... |
I've made a few minor suggestions about man page wording (which might reasonably apply to all of the man pages in the review). I've also made a minor suggestion about deriving LCF_STRICTRELATIVE from BENEATH rather than including lots of if (... STRICTRELATIVE || ... BENEATH).
On a more substantive point, do we set errno in the same way as Linux when openat(... O_BENEATH) fails? It might be helpful to porters if our behaviour is consistent, i.e., we don't set ENOTCAPABLE when people are expecting something like EINVAL.
lib/libc/sys/access.2 | ||
---|---|---|
124 ↗ | (On Diff #49360) | This might be clearer if it said something like, "Only operate on files and directories within the starting directory". |
200 ↗ | (On Diff #49360) | I might suggest: .Dv AT_BENEATH was specified but .Fa path is not strictly relative to the starting directory. For example, .Fa path is absolute or includes a ".." component that escapes the starting directory. |
lib/libc/sys/chflags.2 | ||
97 ↗ | (On Diff #49360) | see comment from access.2 |
308 ↗ | (On Diff #49360) | see comment from access.2 |
lib/libc/sys/open.2 | ||
145 | maybe "require path to be strictly relative to starting directory"? | |
sys/kern/vfs_lookup.c | ||
245 | Would it be sensible to instead use cn_flags & BENEATH as a reason to set NI_LCF_STRICTRELATIVE? That might then avoid some of the duplicate logic... |
I am sure that we do not, because I have no idea how the Linux does it. An argument for ENOTCAPABLE is that this error code makes the cause for error distinguished.
If you can explain the Linux error codes, it is certainly for the discussion.
sys/kern/vfs_lookup.c | ||
---|---|---|
245 | I am not completely sure what is your suggestion there, but I can provide some explanation why the current patch is structured as it is. I ended up disabling absolute paths for O_BENEATH, according to jilles' suggestion, for the immediate commit. My plan is to allow absolute paths, assuming that the tail of the path descends into cwd and does not leave it (I hope the idea is clear, I will try to word it more comprehensibly when I implement it). This mode is only relevant for BENEATH and not for STRICTRELATIVE AKA cap mode, for obvious reasons. So I want to test for BENEATH where it is actually BENEATH mode. |