> If memfd_create() could be created by passing the memory address, without the need to use a write() in the created fd
Thinking out loud, but vmsplice into a memfd (possibly through a pipe) might allow you to populate the memfd without any copy.
Re:Dynamic Linking
by oscargrouch on Wednesday July 01, 2020 @04:27PM
(#23706180)
Yes, if i create a memfd, populate it with with a reference from vmsplice, that maps to a mmaped file memory chunk, open it with dlopen through procfs in the child process (that i've passed through pipe) will make it happen without any copy.
This is what i've been looking for, as the child process is sandboxed and it's good to have a option where there's no need to access the filesystem to work some things out.
This is pretty good, thank you. I've passed through vmsplice here and there.. but as i didn't need to use it, i've completely forgot about its existence. So thank you for this good reminder of a great syscall.
Note that in my use case i will/can pass the file descriptors to the child process, so that's why memfd_create suited me well. But if you happen to know how i can just use the mmaped file, as long as i can point the exact offset to be readed, it will be much better, because it will be basically a zero-copy implementation of it.
(If memfd_create() could be created by passing the memory address, without the need to use a write() in the created fd, it would also be much less expensive)
Thank you for your tip, that is a really nice trick!