0

I want to hook mmap system call in qemu, and I use libvirt to passthrough the environment argument like this:

<qemu:commandline>
  <qemu:env name='LD_PRELOAD' value='/glibcHookMMAP.so'/>
</qemu:commandline>

But it failed! I can hardly find out what is the matter! The log in libvirt like this:

ERROR: ld.so: object '/glibcHookMMAP.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

Firstly, I think it's the problem of authority. But the file glibcHookMMAP.so has been done with command chmod 777.

Environment:

Ubuntu 18.04.2 Linux 5.4.0-92

libvirt 4.0.0

qemu 2.11.1

Xiong.
  • 1
  • 2
  • Why the / in the path? – stark Jan 06 '22 at 12:18
  • Does this answer your question? [cannot open shared object file: No such file or directory](https://stackoverflow.com/questions/2172621/cannot-open-shared-object-file-no-such-file-or-directory) – stark Jan 06 '22 at 12:19
  • 1
    / is a strange place to put the library. – stark Jan 06 '22 at 12:29
  • '/' is the root path(maybe the problem of the parent directory permission...). By using LD_PRELOAD=/glibcHookMMAP.so qemu-system-x86_64 ...(args), it works! I think is not the target. – Xiong. Jan 06 '22 at 12:33

1 Answers1

0

OK, now I know the solution: Apparmor policy in Ubuntu limits the work, is like the SELinux. Thus I should modify configuration in /etc/apparmor.d/abstractions/libvirt-qemu to allow libvirt to link .so.

Xiong.
  • 1
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 07 '22 at 10:33