NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: fork and COW





On 29.06.2020 22:48, Jaromír Doleček wrote:
I know running binary on image upload is a bad idea, but I wonder
why in our testing environment on Linux it does not happen. My thought
was somewhere around COW capabilities of fork() but as I know COW is
implemented in NetBSD as well. Is it true and it should work same as on
Linux or there might be some differences?

Yes, it works the same.

However COW is only relevant before php-fpm does exec of ImageMagick.
Immediately after fork the child shares the address space with the
parent having the memory pages marked as COW, after exec the child no
longer shares the virtual address space with the parent. There is
never any address space sharing for the independently executed
ImageMagick processes.

Just to be sure - let's say 512M process is forked and now we have
two 512M processes which have most of their pages shared. Second
process runs external binary and you say no external process can share
pages with parent and its fair and secure, so now second process is named "imagick" and what about its 512M not-yet-copied space? Is it dropped because php exited and now this process has its own new reservations as much as it need for itself?

It's likely Something Else (tm).

Thank you, I will investigate further.

Does php-imagick support what you need to do? That way you'd avoid
executing external binaries.

Yes, it is, but it is based on external technology stack which is hard to rework right now.

--
Dima Veselov
Physics R&D Establishment of Saint-Petersburg University


Home | Main Index | Thread Index | Old Index