5 ms·
It’s a great concept. But I would NAK the API for Linux: > Calling unveil() for the first time will "drop a veil" across the entire filesystem, rendering the
by amluto 8y ago
It’s a great concept. But I would NAK the API for Linux:
> Calling unveil() for the first time will "drop a veil" across the entire filesystem, rendering the whole thing invisible to the process, with one exception...
Sorry, but the semantics of calling it once should be similar to the semantics of calling it twice. The first call veils and the second call unveils.
Also, on Linux at least, efficiently implementing “you can only see this subtree” is quite tricky due to races against moving the directories in question around. I wonder how OpenBSD gets around those races.
- gjm11 8y agoIt feels less inconsistent if you put it like this: every call unveils, but the first one also veils. Or: every call does the following two things. (1) It ensures that a veil is present. (2) It makes a hole in the veil at the location provided.
- leiroigh 8y agoYeah, an easier formulation would be: noveil(...) to mark pathes we plan to use (fails on veiled pathes), and a subsequent veil() that irreversibly removes access to everything that was not protected by a noveil(...) call between this and the last veil() call. If a veil() call never comes, well, then we did not restrict access at all and only spammed some kernel structure. If all you care is protection in case someone gets codeexec in your process, then this would be simpler and give additional features (we can incrementally drop access, instead of only once). I see an advantage of the unveil(...) in that: Suppose my process cannot irrevocably drop access, because e.g. it anticipates to need to write to some pathes we don't know already. But still, the unveil can help to mitigate stuff like directory traversals: I can't lock (unveil(0,0)), so codeexec is still game over; if my code for late unveiling has bugs it's game over; but if the late unveiling code has no bugs, but the actual file access code is buggy, then this construction will protect me.
- ibejoeb 8y agoThink of it as backward compatible progressive enhancement. You're opting in to veiled FS by making an initial call to unveil a path. The system drops the veil, but only if you indicate that you want to operate in the veiled environment. Subsequent versions could be veiled by default, requiring calls to `unveil` for everything, but obviously that would break every existing program.
- x1798DE 8y agoFrom context I understand the meaning, but what does "NAK" mean here? I'm guessing it's an acronym?
- kalenx 8y agoNot acknowledge, e.g. would advise against and, if were the maintainer, would reject the change. ACK and NAK are used quite a lot in communication protocols, and the usage drift from there.