Skip to content

LibAFL-qemu-bridge stop linking with latest rust nightly #2219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vringar opened this issue May 19, 2024 · 6 comments
Closed

LibAFL-qemu-bridge stop linking with latest rust nightly #2219

vringar opened this issue May 19, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@vringar
Copy link
Contributor

vringar commented May 19, 2024

Tested on cf01d04

Describe the bug

LibAFL/fuzzers/qemu_systemmode/target/classic/release/qemu_systemmode: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

When running ldd LibAFL/fuzzers/qemu_systemmode/target/classic/release I get the following output:

ldd qemu_systemmode
	linux-vdso.so.1 (0x00007ffff7fc6000)
	libz.so.1 => not found
	libpixman-1.so.0 => not found
	libgmp.so.10 => not found
	libglib-2.0.so.0 => not found
	libgmodule-2.0.so.0 => not found
	libm.so.6 => /nix/store/apab5i73dqa09wx0q27b6fbhd1r18ihl-glibc-2.39-31/lib/libm.so.6 (0x00007ffff7edb000)
	libnettle.so.8 => not found
	libhogweed.so.6 => not found
	libgcc_s.so.1 => /nix/store/nrwkk6ak3rgkrxbqhsscb01jpzmslf2r-xgcc-13.2.0-libgcc/lib/libgcc_s.so.1 (0x00007ffff7eb6000)
	libc.so.6 => /nix/store/apab5i73dqa09wx0q27b6fbhd1r18ihl-glibc-2.39-31/lib/libc.so.6 (0x00007ffff5c13000)
	/nix/store/apab5i73dqa09wx0q27b6fbhd1r18ihl-glibc-2.39-31/lib/ld-linux-x86-64.so.2 => /nix/store/apab5i73dqa09wx0q27b6fbhd1r18ihl-glibc-2.39-31/lib64/ld-linux-x86-64.so.2 (0x00007ffff7fc8000)

To Reproduce
Steps to reproduce the behavior:

  1. In fuzzers/qemu_systemmode run cargo make build and cargo make run
  2. Observe the error message from the bug description

Expected behavior

The normal fuzzer output

Additional context

I can verify that everything still works on cargo 1.80.0-nightly (0ca60e940 2024-05-08) but doesn't on cargo 1.80.0-nightly (0de7f2ec6 2024-05-17).
I've seen that you have started cancelling qemu builds in CI, so I'm assuming you are aware of the issue. I just wanted to know if this is a bug in qemu_systemmode_build or if you have already filed an upstream bug?

@vringar vringar added the bug Something isn't working label May 19, 2024
@rmalmain rmalmain self-assigned this May 19, 2024
@vringar
Copy link
Contributor Author

vringar commented May 19, 2024

Please lmk, if I can help with any part of this investigation.

@rmalmain
Copy link
Member

I just tried to reproduce your issue. It seems to run as expected on my side.
Your output of ldd suggests some shared libraries cannot be found on your system.
I don't know how they are handled in nix, so I don't think I can be of much help if it is indeed nix-related.
Can you confirm the missing shared libraries from the ldd output are installed on your side?

@vringar
Copy link
Contributor Author

vringar commented May 19, 2024

The shared libraries are installed as shown by the fact that ldd returns the following for cargo 1.80.0-nightly (0ca60e940 2024-05-08)

linux-vdso.so.1 (0x00007ffe4c9fb000)
	libz.so.1 => /nix/store/nw1bnjadmzk9hnd4nbvxmqlh074vr16j-zlib-1.3.1/lib/libz.so.1 (0x00007fa7fe5b5000)
	libpixman-1.so.0 => /nix/store/wp39qd0w5z36qras2rm9dbxb4dh6z4bn-pixman-0.43.4/lib/libpixman-1.so.0 (0x00007fa7fe506000)
	libgmp.so.10 => /nix/store/rkj3k7pflfvjf7shraqvb1qd9s2dz1zs-gmp-with-cxx-6.3.0/lib/libgmp.so.10 (0x00007fa7fe463000)
	libglib-2.0.so.0 => /nix/store/bcms6vbac6jyffwyj8y630brpy1il4ks-glib-2.80.0/lib/libglib-2.0.so.0 (0x00007fa7fc0b5000)
	libgmodule-2.0.so.0 => /nix/store/bcms6vbac6jyffwyj8y630brpy1il4ks-glib-2.80.0/lib/libgmodule-2.0.so.0 (0x00007fa7fe45a000)
	libm.so.6 => /nix/store/apab5i73dqa09wx0q27b6fbhd1r18ihl-glibc-2.39-31/lib/libm.so.6 (0x00007fa7fbfd2000)
	libnettle.so.8 => /nix/store/adalw59bvrk2fg2fl662xnc4y2bqn438-nettle-3.9.1/lib/libnettle.so.8 (0x00007fa7fbf7e000)
	libhogweed.so.6 => /nix/store/adalw59bvrk2fg2fl662xnc4y2bqn438-nettle-3.9.1/lib/libhogweed.so.6 (0x00007fa7fbf33000)
	libgcc_s.so.1 => /nix/store/p3ffjixpnfgkqh20nsrc13vrj3yfi0nj-gcc-13.2.0-lib/lib/libgcc_s.so.1 (0x00007fa7fbf0e000)
	libc.so.6 => /nix/store/apab5i73dqa09wx0q27b6fbhd1r18ihl-glibc-2.39-31/lib/libc.so.6 (0x00007fa7fbd21000)
	/nix/store/apab5i73dqa09wx0q27b6fbhd1r18ihl-glibc-2.39-31/lib/ld-linux-x86-64.so.2 => /nix/store/apab5i73dqa09wx0q27b6fbhd1r18ihl-glibc-2.39-31/lib64/ld-linux-x86-64.so.2 (0x00007fa7fe5d5000)
	libpcre2-8.so.0 => /nix/store/sik7a8dic5lxhm4cp9npibk97x9jcxwf-pcre2-10.43/lib/libpcre2-8.so.0 (0x00007fa7fbc81000)

(and I also explicitly declare most of them here.)

@vringar
Copy link
Contributor Author

vringar commented May 19, 2024

pkg-config --libs zlib also returns -L/nix/store/nw1bnjadmzk9hnd4nbvxmqlh074vr16j-zlib-1.3.1/lib -lz, so it is findable.

@vringar
Copy link
Contributor Author

vringar commented May 19, 2024

cat linkinfo.json| jq .libs returns

[
  "z",
  "pixman-1",
  "gmp",
  "glib-2.0",
  "gmodule-2.0",
  "m",
  "nettle",
  "hogweed",
  "util"
]

so this code should set everything correctly:

for arg in linkinfo["libs"].members() {
let val = arg
.as_str()
.expect("linkinfo.json `libs` values must be strings");
println!("cargo:rustc-link-lib={val}");

@vringar
Copy link
Contributor Author

vringar commented May 22, 2024

This is because of the switch to an internal lld that is not patched to work with Nix. rust-lang/rust#125321

@vringar vringar closed this as completed May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants