Re: [INTERNALS-WIN] OPcache: auto address mapping fallback desired?
[email protected] ("Christoph M. Becker") Mon, 18 Mar 2019 09:40:40 +0100
| Newsgroups | php.internals.win |
|---|---|
| Message-ID | <[email protected]> |
On 17.03.2019 at 20:28, Anatol Belski wrote: > On Sun, 2019-03-17 at 15:51 +0100, Christoph M. Becker wrote: > >> I've noticed that the win32 model of OPcache's shared memory may map >> it >> to an automatic address determinded by the OS. I wonder whether this >> is >> actually desired, and if so, why we try to map to hard-coded >> addresses >> in the first place. If the auto adress mapping is not desired, we >> should apply something like this patch: >> <https://gist.github.com/cmb69/80e2ecc2d46f5255a315a268fcdd6f94>. > > Thanks for the checks. The flow as i read it is currently > > - if no mmap_base specified, map a fixed address > - if mmap_base specified, map to it > - if any of above failed, obtain an address from OS > > The point is, that once the mapping is successfull, it's going to be > saved and read by another process. The doc of MapViewOfFileEx says > > [quote] > While it is possible to specify an address that is safe now (not used > by the operating system), there is no guarantee that the address will > remain safe over time. Therefore, it is better to let the operating > system choose the address. In this case, you would not store pointers > in the memory mapped file, you would store offsets from the base of the > file mapping so that the mapping can be used at any address. > [/quote] > > Those fixed addresses are considered safe from experience, so they're > used when no base address has been specified. But also, from the > experience, none of those methods is ideal. Thanks, Anatol, this makes sense. So sticking with the current flow is fine. > Removing the possibility to use a system chosen base address will > effectively mean, that processes would fail to reattach if any of the > fixed addresses is unusable on the given system. Of course one can say, > then user should seek for a usable address, but that's probably a bit > too much of burden for a user :) > > Also you check on ASLR why these failures happen > > https://en.wikipedia.org/wiki/Address_space_layout_randomization > > On a moders system, it doesn't seem possible to disable ASLR at all, > which is good for security, but causes issues with Opcache. That's why > we've invented also the file_cache_fallback. -- Christoph M. Becker