mknodat is not implemented on darwin-xnu

Originator:wwcohen
Number:rdar://FB9862426 Date Originated:01/28/2022
Status:Open Resolved:
Product: Product Version:
Classification: Reproducible:
 
mknodat (https://pubs.opengroup.org/onlinepubs/9699919799/functions/mknodat.html) has not been implemented on darwin (only mknod is present: https://github.com/apple/darwin-xnu/blob/8f02f2a044b9bb1ad951987ef5bab20ec9486310/bsd/sys/stat.h#L567). In situations where we need to avoid race conditions with later setting permissions, we must avoid using mknod on the full path instead. That said, at the moment, the only safe way to implement mknodat on darwin is to use the undocumented syscall pthread_fchdir (349) (https://github.com/apple/darwin-xnu/blob/a1babec6b135d1f35b2590a1990af3c5c5393479/bsd/kern/syscalls.master#L529) to set the cwd for the current thread only.

This was first noticed in 2018 (https://lists.nongnu.org/archive/html/qemu-devel/2018-05/msg07340.html) with attempts to bring 9pfs functionality to QEMU macOS to mirror its capabilities on Linux, and has been brought to my attention as I have tried to bring this proposed functionality in QEMU forward a few years later (https://lists.nongnu.org/archive/html/qemu-devel/2021-11/msg04331.html).

While having mknodat implemented is the ultimate end goal, in addition please do not remove this syscall until that happens.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!