|
From: Tom H. <to...@co...> - 2020-01-02 11:01:41
|
On 02/01/2020 09:48, Julian Seward wrote: > Ryan, I am seeing this problem also when running Gecko now, as compiled > with rustc 1.40. > >> `statx` is a relatively new system call, only appearing in Linux 4.11. >> Rust uses a trick where it calls `statx` with two NULL pointers to see >> if the kernel/glibc support it because it's faster than calling it with >> a real filename. If it returns `EFAULT` the system call is supported, >> otherwise it returns `ENOSYS`. The comments in the Rust source code >> imply this is a known trick. > > Can you point me at the comments in the Rust source code? I read the man > page for statx pretty carefully, and saw nothing there implying that NULL > is an acceptable value for the |filename| argument. I also didn't see > anything like that in the kernel sources (but I could easily have missed > it, it's a twisty maze in there). Well it sounds like it's relying on side effects of the implementation. No doubt the kernel will try to call copy_from_user or something similar on the filename argument and that will trigger EFAULT if the address is not a valid address in the processes address space, which NULL won't be. So EFAULT means the system call is implemented as the kernel has tried to access the filename, and ENOSYS means it isn't implemented. You could do much the same thing with any system call that takes a user space address as an argument. Tom -- Tom Hughes (to...@co...) http://compton.nu/ |