This is required for Samba 4.17 and higher. Internally samba uses the openat2 flag RESOLVE_NO_SMYLINKS as an optimization to create a fast-path for opening files that helps mitigate a Samba 4.13+ metadata performance regression due to symlink safety checks. This commit adds an open flag equivalent to the MNT_NOSYMLINKFOLLOW mount flag.
Diff Detail
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
open(2) should be updated to describe the flag. Probably additional text explaining the difference with O_NOFOLLOW would be useful as well.
Does the same flag needed for *at() syscalls?
sounds like the thing to do is to add openat2 so that this automagically works, instead of a freebsd-specific flag
Yes, that is a better solution in general. I'm not sure how many Linux applications other than Samba use openat2 since glibc doesn't currently have a wrapper for it (samba uses syscall(2) to call it), but maybe in future it will be more common.
I don't think a corresponding _at flag is needed needed (unless someone has particular use-case for it). Good point about manpage, totally slipped my mind.
I can possibly submit a minimal openat2() implementation that only supports existing resolve flags for now (for example: RESOLVE_BENEATH, RESOLVE_NO_SYMLINK) if decision is firm that we don't want to add more path-resolution flags for open(2).
Linux folk explicitly designed openat2 to be extensible, so I expect it is going to pick up explicit "official" usage down the road.
That said, I think a minimal initial implementation is the way to go here.
I uploaded a minimal implementation. Basically, I opted to to use an internal open flag to pass to kern_openat rather than adding kern_openat2 or significantly changing kern_openat. Very basic testing seems to work. If you don't have concerns with implementing in this manner, I will start working on a manpage and tests.
Please
- Move addition of the open2 syscall into a new review.
- Do not put changes to generated files into the diff (it should be committed as an additional commit anyway).
- I very much dislike internal openat flag. Please add a new flag2 argument for kern_openat(9) (and perhaps vn_open_cred() but might be not needed right now) and pass a new flag there.
lib/libc/sys/openat2.c | ||
---|---|---|
5 ↗ | (On Diff #132488) | Definitely not, I know. |
sys/kern/vfs_syscalls.c | ||
1128 ↗ | (On Diff #132488) | Why - ? |
1130 ↗ | (On Diff #132488) | |
sys/sys/openat2.h | ||
52 ↗ | (On Diff #132488) | |
57 ↗ | (On Diff #132488) |
Okay. I will make the requested changes into new review and link add reference to here. Sorry about the copy-pasted copyright in header. E2BIG is specified response in Linux manpage for this situation.
Per feedback, this reverts syscall-related changes and restores original diff. Will create new diff for syscall.