4

I am trying to use ksm_preload for Apache inside Docker. The problem is the library does not get mapped when running inside Docker. Outside it works and i am seeing shared/volatile pages. I think the problem lies somewhere in apache, because other applications (like apt) running in the same container with the same LD_PRELOAD parameter show activity in the KSM.

After running make install i tried the following inside the docker container

LD_PRELOAD=/usr/local/share/ksm_preload/libksm_preload.so apache2ctl -k start -D FOREGROUND

I also tried setting /etc/apache2/envvars for the worker processes:

export LD_DEBUG=all
export LD_PRELOAD=/usr/local/share/ksm_preload/libksm_preload.so

The parent process gets the library mapped, but the child worker processes do not.

/proc/pid/map_files of parent process:

7f2e13aef000-7f2e13af1000 -> /usr/local/share/ksm_preload/libksm_preload.so
7f2e13af1000-7f2e13cf0000 -> /usr/local/share/ksm_preload/libksm_preload.so
7f2e13cf0000-7f2e13cf1000 -> /usr/local/share/ksm_preload/libksm_preload.so

Always the following result:

/sys/kernel/mm/ksm/pages_shared:0
/sys/kernel/mm/ksm/pages_sharing:0
/sys/kernel/mm/ksm/pages_to_scan:100
/sys/kernel/mm/ksm/pages_unshared:0
/sys/kernel/mm/ksm/pages_volatile:0
/sys/kernel/mm/ksm/run:1

The LD debug output is rather long https://pastebin.com/KRvKHXxn

Does apache have some kind of protection against LD_PRELOAD ?

Is there maybe a another dynamic library with higher priority overwriting the symbols?

maybe relevant : https://stackoverflow.com/questions/13374240/why-ld-preload-doesnt-work-for-one-of-loaded-shared-libraries tried the solution with UNSET_RTLD_DEEPBIND=1 , no change

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.