lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #234326 from Mindavi/aflplusplus/4.05c

aflplusplus: 2.64c -> 4.06c

authored by

Rick van Schijndel and committed by
GitHub
470d4e5a 8a7d5c03

+185 -85
+61 -29
pkgs/tools/security/aflplusplus/default.nix
··· 1 1 { lib, stdenv, stdenvNoCC, fetchFromGitHub, callPackage, makeWrapper 2 - , clang, llvm, gcc, which, libcgroup, python, perl, gmp 2 + , clang, llvm, gcc, which, libcgroup, python3, perl, gmp 3 3 , file, wine ? null, fetchpatch 4 + , cmocka 5 + , llvmPackages 4 6 }: 5 7 6 8 # wine fuzzing is only known to work for win32 binaries, and using a mixture of ··· 17 19 libtokencap = callPackage ./libtokencap.nix { inherit aflplusplus; }; 18 20 aflplusplus = stdenvNoCC.mkDerivation rec { 19 21 pname = "aflplusplus"; 20 - version = "2.65c"; 22 + version = "4.06c"; 21 23 22 24 src = fetchFromGitHub { 23 25 owner = "AFLplusplus"; 24 26 repo = "AFLplusplus"; 25 27 rev = version; 26 - sha256 = "1np2a3kypb2m8nyv6qnij18yzn41pl8619jzydci40br4vxial9l"; 28 + sha256 = "sha256-Gb1nYDBnwLS+m8e1UD0WLIrnp8KRgliGQVvQD22JXrQ="; 27 29 }; 28 30 enableParallelBuilding = true; 29 31 30 32 # Note: libcgroup isn't needed for building, just for the afl-cgroup 31 33 # script. 32 34 nativeBuildInputs = [ makeWrapper which clang gcc ]; 33 - buildInputs = [ llvm python gmp ] 34 - ++ lib.optional (wine != null) python.pkgs.wrapPython; 35 + buildInputs = [ llvm python3 gmp llvmPackages.bintools ] 36 + ++ lib.optional (wine != null) python3.pkgs.wrapPython; 35 37 38 + # Flag is already set by package and causes some compiler warnings. 39 + # warning: "_FORTIFY_SOURCE" redefined 40 + hardeningDisable = [ "fortify" ]; 36 41 37 42 postPatch = '' 38 - # Replace the CLANG_BIN variables with the correct path 39 - substituteInPlace llvm_mode/afl-clang-fast.c \ 43 + # Don't care about this. 44 + rm Android.bp 45 + 46 + # Replace the CLANG_BIN variables with the correct path. 47 + # Replace "gcc" and friends with full paths in afl-gcc. 48 + # Prevents afl-gcc picking up any (possibly incorrect) gcc from the path. 49 + # Replace LLVM_BINDIR with a non-existing path to give a hard error when it's used. 50 + substituteInPlace src/afl-cc.c \ 40 51 --replace "CLANGPP_BIN" '"${clang}/bin/clang++"' \ 41 52 --replace "CLANG_BIN" '"${clang}/bin/clang"' \ 42 - --replace 'getenv("AFL_PATH")' "(getenv(\"AFL_PATH\") ? getenv(\"AFL_PATH\") : \"$out/lib/afl\")" 43 - 44 - # Replace "gcc" and friends with full paths in afl-gcc 45 - # Prevents afl-gcc picking up any (possibly incorrect) gcc from the path 46 - substituteInPlace src/afl-gcc.c \ 47 53 --replace '"gcc"' '"${gcc}/bin/gcc"' \ 48 54 --replace '"g++"' '"${gcc}/bin/g++"' \ 49 - --replace '"gcj"' '"gcj-UNSUPPORTED"' \ 50 - --replace '"clang"' '"clang-UNSUPPORTED"' \ 51 - --replace '"clang++"' '"clang++-UNSUPPORTED"' 55 + --replace 'getenv("AFL_PATH")' "(getenv(\"AFL_PATH\") ? getenv(\"AFL_PATH\") : \"$out/lib/afl\")" 56 + 57 + substituteInPlace src/afl-ld-lto.c \ 58 + --replace 'LLVM_BINDIR' '"/nixpkgs-patched-does-not-exist"' 59 + 60 + # Remove the rest of the line 61 + sed -i 's|LLVM_BINDIR = .*|LLVM_BINDIR = |' utils/aflpp_driver/GNUmakefile 62 + substituteInPlace utils/aflpp_driver/GNUmakefile \ 63 + --replace 'LLVM_BINDIR = ' 'LLVM_BINDIR = ${clang}/bin/' 64 + 65 + substituteInPlace GNUmakefile.llvm \ 66 + --replace "\$(LLVM_BINDIR)/clang" "${clang}/bin/clang" 52 67 ''; 53 68 54 69 env.NIX_CFLAGS_COMPILE = toString [ ··· 56 71 "-Wno-error=use-after-free" 57 72 ]; 58 73 59 - makeFlags = [ "PREFIX=$(out)" ]; 74 + makeFlags = [ 75 + "PREFIX=$(out)" 76 + "USE_BINDIR=0" 77 + ]; 60 78 buildPhase = '' 79 + runHook preBuild 80 + 61 81 common="$makeFlags -j$NIX_BUILD_CORES" 62 - make all $common 63 - make radamsa $common 64 - make -C gcc_plugin CC=${gcc}/bin/gcc CXX=${gcc}/bin/g++ $common 65 - make -C llvm_mode $common 82 + make distrib $common 66 83 make -C qemu_mode/libcompcov $common 67 84 make -C qemu_mode/unsigaction $common 85 + 86 + runHook postBuild 68 87 ''; 69 88 70 89 postInstall = '' ··· 75 94 cp qemu_mode/unsigaction/unsigaction*.so $out/lib/afl/ 76 95 77 96 # Install the custom QEMU emulator for binary blob fuzzing. 78 - cp ${aflplusplus-qemu}/bin/${qemu-exe-name} $out/bin/afl-qemu-trace 97 + ln -s ${aflplusplus-qemu}/bin/${qemu-exe-name} $out/bin/afl-qemu-trace 79 98 80 99 # give user a convenient way of accessing libcompconv.so, libdislocator.so, libtokencap.so 81 100 cat > $out/bin/get-afl-qemu-libcompcov-so <<END ··· 83 102 echo $out/lib/afl/libcompcov.so 84 103 END 85 104 chmod +x $out/bin/get-afl-qemu-libcompcov-so 86 - cp ${libdislocator}/bin/get-libdislocator-so $out/bin/ 87 - cp ${libtokencap}/bin/get-libtokencap-so $out/bin/ 105 + ln -s ${libdislocator}/bin/get-libdislocator-so $out/bin/ 106 + ln -s ${libtokencap}/bin/get-libtokencap-so $out/bin/ 88 107 89 108 # Install the cgroups wrapper for asan-based fuzzing. 90 - cp examples/asan_cgroups/limit_memory.sh $out/bin/afl-cgroup 109 + cp utils/asan_cgroups/limit_memory.sh $out/bin/afl-cgroup 91 110 chmod +x $out/bin/afl-cgroup 92 111 substituteInPlace $out/bin/afl-cgroup \ 93 112 --replace "cgcreate" "${libcgroup}/bin/cgcreate" \ ··· 107 126 if [ -x $winePath ]; then break; fi 108 127 done 109 128 makeWrapperArgs="--set-default 'AFL_WINE_PATH' '$winePath'" \ 110 - wrapPythonProgramsIn $out/bin ${python.pkgs.pefile} 129 + wrapPythonProgramsIn $out/bin ${python3.pkgs.pefile} 111 130 ''; 112 131 113 - nativeInstallCheckInputs = [ perl file ]; 132 + nativeInstallCheckInputs = [ perl file cmocka ]; 114 133 doInstallCheck = true; 115 134 installCheckPhase = '' 135 + runHook preInstallCheck 136 + 116 137 # replace references to tools in build directory with references to installed locations 117 - substituteInPlace test/test.sh \ 138 + substituteInPlace test/test-qemu-mode.sh \ 118 139 --replace '../libcompcov.so' '`$out/bin/get-afl-qemu-libcompcov-so`' \ 140 + --replace '../afl-qemu-trace' '$out/bin/afl-qemu-trace' \ 141 + --replace '../afl-fuzz' '$out/bin/afl-fuzz' \ 142 + --replace '../qemu_mode/unsigaction/unsigaction32.so' '$out/lib/afl/unsigaction32.so' \ 143 + --replace '../qemu_mode/unsigaction/unsigaction64.so' '$out/lib/afl/unsigaction64.so' 144 + 145 + substituteInPlace test/test-libextensions.sh \ 119 146 --replace '../libdislocator.so' '`$out/bin/get-libdislocator-so`' \ 120 147 --replace '../libtokencap.so' '`$out/bin/get-libtokencap-so`' 121 - perl -pi -e 's|(?<!\.)(?<!-I)(\.\./)([^\s\/]+?)(?<!\.c)(?<!\.s?o)(?=\s)|\$out/bin/\2|g' test/test.sh 122 - cd test && ./test.sh 148 + substituteInPlace test/test-llvm.sh \ 149 + --replace '../afl-cmin.bash' '`$out/bin/afl-cmin.bash`' 150 + # perl -pi -e 's|(?<!\.)(?<!-I)(\.\./)([^\s\/]+?)(?<!\.c)(?<!\.s?o)(?=\s)|\$out/bin/\2|g' test/test.sh 151 + patchShebangs . 152 + cd test && ./test-all.sh 153 + 154 + runHook postInstallCheck 123 155 ''; 124 156 125 157 passthru = {
+2 -3
pkgs/tools/security/aflplusplus/libdislocator.nix
··· 6 6 7 7 src = aflplusplus.src; 8 8 postUnpack = "chmod -R +w ${aflplusplus.src.name}"; 9 - sourceRoot = "${aflplusplus.src.name}/libdislocator"; 9 + sourceRoot = "${aflplusplus.src.name}/utils/libdislocator"; 10 10 11 11 makeFlags = [ "PREFIX=$(out)" ]; 12 12 13 13 preInstall = '' 14 14 mkdir -p $out/lib/afl 15 - # issue is fixed upstream: https://github.com/AFLplusplus/AFLplusplus/commit/2a60ceb6944a7ca273057ddf64dcf837bf7f9521 16 - sed -i 's/README\.dislocator\.md/README\.md/g' Makefile 17 15 ''; 16 + 18 17 postInstall = '' 19 18 mkdir $out/bin 20 19 cat > $out/bin/get-libdislocator-so <<END
+2 -2
pkgs/tools/security/aflplusplus/libtokencap.nix
··· 6 6 7 7 src = aflplusplus.src; 8 8 postUnpack = "chmod -R +w ${aflplusplus.src.name}"; 9 - sourceRoot = "${aflplusplus.src.name}/libtokencap"; 9 + sourceRoot = "${aflplusplus.src.name}/utils/libtokencap"; 10 10 11 11 makeFlags = [ "PREFIX=$(out)" ]; 12 12 ··· 24 24 ''; 25 25 26 26 meta = with lib; { 27 - homepage = "https://github.com/vanhauser-thc/AFLplusplus"; 27 + homepage = "https://github.com/AFLplusplus/AFLplusplus"; 28 28 description = "strcmp & memcmp token capture library"; 29 29 license = lib.licenses.asl20; 30 30 maintainers = with maintainers; [ ris ];
+117 -48
pkgs/tools/security/aflplusplus/qemu.nix
··· 1 - { lib, stdenv, fetchurl, aflplusplus, python3, zlib, pkg-config, glib, perl 2 - , texinfo, libuuid, flex, bison, pixman, autoconf 1 + { lib 2 + , stdenv 3 + , fetchurl 4 + , aflplusplus 5 + , python3 6 + , zlib 7 + , pkg-config 8 + , glib 9 + , perl 10 + , texinfo 11 + , libuuid 12 + , flex 13 + , bison 14 + , pixman 15 + , meson 16 + , fetchFromGitHub 17 + , ninja 3 18 }: 4 19 5 20 let 6 - qemuName = "qemu-3.1.0"; 7 - cpuTarget = if stdenv.targetPlatform.system == "x86_64-linux" then "x86_64-linux-user" 21 + qemuName = "qemu-5.2.50"; 22 + cpuTarget = 23 + if stdenv.targetPlatform.system == "x86_64-linux" then "x86_64-linux-user" 8 24 else if stdenv.targetPlatform.system == "i686-linux" then "i386-linux-user" 9 25 else throw "aflplusplus: no support for ${stdenv.targetPlatform.system}!"; 10 26 in 11 27 stdenv.mkDerivation { 12 28 name = "aflplusplus-${qemuName}"; 13 29 14 - srcs = [ 15 - (fetchurl { 16 - url = "http://wiki.qemu.org/download/${qemuName}.tar.bz2"; 17 - sha256 = "08frr1fdjx8qcfh3fafn10kibdwbvkqqvfl7hpqbm7i9dg4f1zlq"; 18 - }) 19 - aflplusplus.src 20 - ]; 21 - 22 - sourceRoot = qemuName; 23 - 24 - postUnpack = '' 25 - chmod -R +w ${aflplusplus.src.name} 26 - for f in ${aflplusplus.src.name}/qemu_mode/patches/* ; do 27 - sed -E -i 's|(\.\./)+patches/([a-z-]+\.h)|\2|g' $f 28 - sed -E -i 's|\.\./\.\./config\.h|afl-config.h|g' $f 29 - sed -E -i 's|\.\./\.\./include/cmplog\.h|afl-cmplog.h|g' $f 30 - done 31 - cp ${aflplusplus.src.name}/qemu_mode/patches/*.h $sourceRoot/ 32 - cp ${aflplusplus.src.name}/types.h $sourceRoot/afl-types.h 33 - substitute ${aflplusplus.src.name}/config.h $sourceRoot/afl-config.h \ 34 - --replace "types.h" "afl-types.h" 35 - substitute ${aflplusplus.src.name}/include/cmplog.h $sourceRoot/afl-cmplog.h \ 36 - --replace "config.h" "afl-config.h" \ 37 - --replace "forkserver.h" "afl-forkserver.h" 38 - substitute ${aflplusplus.src.name}/include/forkserver.h $sourceRoot/afl-forkserver.h \ 39 - --replace "types.h" "afl-types.h" 40 - 41 - cat ${aflplusplus.src.name}/qemu_mode/patches/*.diff > all.patch 42 - ''; 30 + src = fetchFromGitHub { 31 + owner = "AFLplusplus"; 32 + repo = "qemuafl"; 33 + rev = "0569eff8a12dec73642b96757f6b5b51a618a03a"; 34 + sha256 = "sha256-nYWHyRfOH2p9znRxjxsiyw11uZuMBiuJfEc7FHM5X7M="; 35 + fetchSubmodules = true; 36 + }; 43 37 44 38 nativeBuildInputs = [ 45 - python3 perl pkg-config flex bison autoconf texinfo 39 + python3 40 + perl 41 + pkg-config 42 + flex 43 + bison 44 + meson 45 + texinfo 46 + ninja 46 47 ]; 47 48 48 49 buildInputs = [ 49 - zlib glib pixman libuuid 50 + zlib 51 + glib 52 + pixman 53 + libuuid 50 54 ]; 51 55 52 56 enableParallelBuilding = true; 53 57 54 - patches = [ 55 - # patches extracted from aflplusplus source 56 - "../all.patch" 57 - # nix-specific patches to make installation more well-behaved 58 - ./qemu-no-etc-install.patch 59 - ]; 58 + dontUseMesonConfigure = true; # meson's configurePhase isn't compatible with qemu build 59 + preBuild = "cd build"; 60 + preConfigure = '' 61 + # this script isn't marked as executable b/c it's indirectly used by meson. Needed to patch its shebang 62 + chmod +x ./scripts/shaderinclude.pl 63 + patchShebangs . 64 + ''; 60 65 61 66 configureFlags = 62 - [ "--disable-system" 67 + [ 68 + "--target-list=${stdenv.hostPlatform.uname.processor}-linux-user" 69 + "--sysconfdir=/etc" 70 + "--localstatedir=/var" 71 + "--meson=meson" 72 + "--disable-system" 63 73 "--enable-linux-user" 74 + "--enable-pie" 75 + "--audio-drv-list=" 76 + "--disable-blobs" 77 + "--disable-bochs" 78 + "--disable-brlapi" 79 + "--disable-bsd-user" 80 + "--disable-bzip2" 81 + "--disable-cap-ng" 82 + "--disable-cloop" 83 + "--disable-curl" 84 + "--disable-curses" 85 + "--disable-dmg" 86 + "--disable-fdt" 87 + "--disable-gcrypt" 88 + "--disable-glusterfs" 89 + "--disable-gnutls" 64 90 "--disable-gtk" 91 + "--disable-guest-agent" 92 + "--disable-iconv" 93 + "--disable-libiscsi" 94 + "--disable-libnfs" 95 + "--disable-libssh" 96 + "--disable-libusb" 97 + "--disable-linux-aio" 98 + "--disable-live-block-migration" 99 + "--disable-lzo" 100 + "--disable-nettle" 101 + "--disable-numa" 102 + "--disable-opengl" 103 + "--disable-parallels" 104 + "--disable-plugins" 105 + "--disable-qcow1" 106 + "--disable-qed" 107 + "--disable-rbd" 108 + "--disable-rdma" 109 + "--disable-replication" 65 110 "--disable-sdl" 111 + "--disable-seccomp" 112 + "--disable-sheepdog" 113 + "--disable-smartcard" 114 + "--disable-snappy" 115 + "--disable-spice" 116 + "--disable-system" 117 + "--disable-tools" 118 + "--disable-tpm" 119 + "--disable-usb-redir" 120 + "--disable-vde" 121 + "--disable-vdi" 122 + "--disable-vhost-crypto" 123 + "--disable-vhost-kernel" 124 + "--disable-vhost-net" 125 + "--disable-vhost-scsi" 126 + "--disable-vhost-user" 127 + "--disable-vhost-vdpa" 128 + "--disable-vhost-vsock" 129 + "--disable-virglrenderer" 130 + "--disable-virtfs" 66 131 "--disable-vnc" 67 - "--disable-kvm" 68 - "--target-list=${cpuTarget}" 69 - "--enable-pie" 70 - "--sysconfdir=/etc" 71 - "--localstatedir=/var" 132 + "--disable-vnc-jpeg" 133 + "--disable-vnc-png" 134 + "--disable-vnc-sasl" 135 + "--disable-vte" 136 + "--disable-vvfat" 137 + "--disable-xen" 138 + "--disable-xen-pci-passthrough" 139 + "--disable-xfsctl" 140 + "--without-default-devices" 72 141 ]; 73 142 74 143 meta = with lib; { 75 - homepage = "https://www.qemu.org/"; 144 + homepage = "https://github.com/AFLplusplus/qemuafl"; 76 145 description = "Fork of QEMU with AFL++ instrumentation support"; 77 146 license = licenses.gpl2Plus; 78 147 maintainers = with maintainers; [ ris ];
+3 -3
pkgs/top-level/all-packages.nix
··· 1416 1416 }; 1417 1417 1418 1418 aflplusplus = callPackage ../tools/security/aflplusplus { 1419 - clang = clang_9; 1420 - llvm = llvm_9; 1421 - python = python3; 1419 + clang = clang_15; 1420 + llvm = llvm_15; 1421 + llvmPackages = llvmPackages_15; 1422 1422 wine = null; 1423 1423 }; 1424 1424