Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Feb 2016 08:00:54 +0000 (UTC)
From:      Kurt Jaeger <pi@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r409224 - in head/security/afl: . files
Message-ID:  <201602200800.u1K80sLq027116@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pi
Date: Sat Feb 20 08:00:53 2016
New Revision: 409224
URL: https://svnweb.freebsd.org/changeset/ports/409224

Log:
  security/afl: 1.96.b -> 2.02b
  
  Changes:
  - Add new LLVM option which adds afl-clang-fast and afl-clang-fast++.
    Enabled by default, but broken on FreeBSD 9.
  - The PLOT_SUPPORT option was broken in r405132 because of a typo in
    its RUN_DEPENDS.  Gnuplot is only required by afl-plot which will
    quit with an error alerting the user if it isn't installed, so
    instead of fixing the typo we remove it instead.  Added a
    pkg-message suggesting to install gnuplot if afl-plot is wanted.
  
  PR:		207236
  Submitted by:	Tobias Kortkamp <t@tobik.me> (maintainer)

Added:
  head/security/afl/files/
  head/security/afl/files/patch-Makefile   (contents, props changed)
  head/security/afl/files/patch-llvm__mode_afl-clang-fast.c   (contents, props changed)
  head/security/afl/pkg-message   (contents, props changed)
Modified:
  head/security/afl/Makefile
  head/security/afl/distinfo
  head/security/afl/pkg-plist

Modified: head/security/afl/Makefile
==============================================================================
--- head/security/afl/Makefile	Sat Feb 20 07:16:31 2016	(r409223)
+++ head/security/afl/Makefile	Sat Feb 20 08:00:53 2016	(r409224)
@@ -2,7 +2,7 @@
 # $FreeBSD$
 
 PORTNAME=	afl
-PORTVERSION=	1.96b
+PORTVERSION=	2.02b
 CATEGORIES=	security
 MASTER_SITES=	http://lcamtuf.coredump.cx/afl/releases/
 
@@ -12,48 +12,66 @@ COMMENT=	Fast instrumented fuzzer
 LICENSE=	APACHE20
 LICENSE_FILE=	${WRKSRC}/docs/COPYING
 
-USES=		compiler gmake tar:tgz
+USES=	compiler gmake tar:tgz
 
-OPTIONS_DEFINE=		DEBUG DOCS MINIMIZE_CORPUS PLOT_SUPPORT TEST_INSTRUMENTATION
+OPTIONS_DEFINE=		DEBUG DOCS MINIMIZE_CORPUS LLVM TEST_INSTRUMENTATION
 MINIMIZE_CORPUS_DESC=	Install afl-cmin. Adds bash dependency
-PLOT_SUPPORT_DESC=	Support progress plotting. Adds Gnuplot dependency
 TEST_INSTRUMENTATION_DESC=	Execute tests (expected to fail in jails)
-OPTIONS_DEFAULT=		DOCS MINIMIZE_CORPUS PLOT_SUPPORT
+LLVM_DESC=	LLVM-based instrumentation (broken on 9.x)
+OPTIONS_DEFAULT=	DOCS LLVM MINIMIZE_CORPUS
 
 OPTIONS_SUB=	yes
 
-PORTSCOUT=	ignore:1
-
-ONLY_FOR_ARCHS=		amd64 i386
+ONLY_FOR_ARCHS=	amd64 i386
 ONLY_FOR_ARCHS_REASON=	Uses binary instrumentation
 
-.include <bsd.port.pre.mk>
+LLVM_BUILD_DEPENDS=	clang37:${PORTSDIR}/devel/llvm37
+LLVM_RUN_DEPENDS=	clang37:${PORTSDIR}/devel/llvm37
+MINIMIZE_CORPUS_RUN_DEPENDS=	${LOCALBASE}/bin/bash:${PORTSDIR}/shells/bash
+
+.include <bsd.port.options.mk>
 
-.if (${COMPILER_TYPE} == "clang" && ${ARCH} == "i386")
+.if ${OSVERSION} < 1000013
+# Broken on FreeBSD 9
+PLIST_SUB+=	LLVM_SUB="@comment "
+.else
+PLIST_SUB+=	LLVM_SUB=""
+.endif
+
+.if ${ARCH} == "i386"
 # Clang i386 emits .cfi_sections which base as(1) doesn't understand
-BUILD_DEPENDS +=	${LOCALBASE}/bin/as:${PORTSDIR}/devel/binutils
-RUN_DEPENDS +=		${LOCALBASE}/bin/as:${PORTSDIR}/devel/binutils
+BUILD_DEPENDS+=	${LOCALBASE}/bin/as:${PORTSDIR}/devel/binutils
+RUN_DEPENDS+=	${LOCALBASE}/bin/as:${PORTSDIR}/devel/binutils
 .endif
 
-MINIMIZE_CORPUS_RUN_DEPENDS=	${LOCALBASE}/bin/bash:${PORTSDIR}/shells/bash
-PLOT_SUPORT_RUN_DEPENDS=	gnuplot:${PORTSDIR}/math/gnuplot
+MAKE_ARGS=	INSTALL_PROGRAM="${INSTALL_PROGRAM}" \
+		INSTALL_SCRIPT="${INSTALL_SCRIPT}"
 
-post-patch:
-.if ! ${PORT_OPTIONS:MTEST_INSTRUMENTATION}
+post-patch-TEST_INSTRUMENTATION-off:
 # afl needs shmget() which usually isn't available in jails. Disabling
 # the instrumentation tests makes sure building packages in jails works
 # by default anyway.
 	${REINPLACE_CMD} -e 's@^\(all.*\) test_build@\1@' ${WRKSRC}/Makefile
-.endif
-	${REINPLACE_CMD} -E -e 's@ -O3@@; s@ -g@@' \
-		-e 's@install -m 755@${INSTALL_PROGRAM}@' \
-		-e 's@ afl-(cmin|plot|whatsup) @ @g' \
-		${WRKSRC}/Makefile
-.if (${COMPILER_TYPE} == "clang" && ${ARCH} == "i386")
+	${REINPLACE_CMD} -e 's@^\(all.*\) test_build@\1@' ${WRKSRC}/llvm_mode/Makefile
+
+post-patch:
+.if ${ARCH} == "i386"
 	${REINPLACE_CMD} -e 's@\(  as_params\[0\] = afl_as ? afl_as : \)\(.*\)@\1(u8*)"${LOCALBASE}/bin/as";@' \
 		${WRKSRC}/afl-as.c
 .endif
 
+.if ! ${OSVERSION} < 1000013
+# Broken on FreeBSD 9
+post-build-LLVM-on:
+	@(cd ${WRKSRC}/llvm_mode; ${SETENV} \
+		CC=clang37 \
+		CXX=clang++37 \
+		LLVM_CONFIG=llvm-config37 \
+		CFLAGS="${CFLAGS}" \
+		CXXFLAGS="${CXXFLAGS}" \
+		${GMAKE})
+.endif
+
 post-install:
 	${INSTALL_DATA} ${WRKSRC}/docs/COPYING ${STAGEDIR}${DOCSDIR}/
 
@@ -64,4 +82,4 @@ post-install:
 post-install-MINIMIZE_CORPUS-on:
 	${INSTALL_SCRIPT} ${WRKSRC}/afl-cmin ${STAGEDIR}${PREFIX}/bin/
 
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>

Modified: head/security/afl/distinfo
==============================================================================
--- head/security/afl/distinfo	Sat Feb 20 07:16:31 2016	(r409223)
+++ head/security/afl/distinfo	Sat Feb 20 08:00:53 2016	(r409224)
@@ -1,2 +1,2 @@
-SHA256 (afl-1.96b.tgz) = 03beb06f8993dcb37d348e53da19ca9d064c83fcedc9d87b0b506c73c310f27c
-SIZE (afl-1.96b.tgz) = 804864
+SHA256 (afl-2.02b.tgz) = 8a508220675d3004ca6aef3cbf50dbbe4c377fc6723f3886ec36a8dfdc9bf057
+SIZE (afl-2.02b.tgz) = 809740

Added: head/security/afl/files/patch-Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/security/afl/files/patch-Makefile	Sat Feb 20 08:00:53 2016	(r409224)
@@ -0,0 +1,29 @@
+--- Makefile.orig	2016-02-16 07:14:22 UTC
++++ Makefile
+@@ -21,6 +21,8 @@ BIN_PATH    = $(PREFIX)/bin
+ HELPER_PATH = $(PREFIX)/lib/afl
+ DOC_PATH    = $(PREFIX)/share/doc/afl
+ MISC_PATH   = $(PREFIX)/share/afl
++INSTALL_PROGRAM?=	install -s -m755
++INSTALL_SCRIPT?=	isntall -m755
+ 
+ PROGS       = afl-gcc afl-fuzz afl-showmap afl-tmin afl-gotcpu afl-analyze
+ SH_PROGS    = afl-plot afl-cmin afl-whatsup
+@@ -115,12 +117,13 @@ clean:
+ install: all
+ 	mkdir -p -m 755 $${DESTDIR}$(BIN_PATH) $${DESTDIR}$(HELPER_PATH) $${DESTDIR}$(DOC_PATH) $${DESTDIR}$(MISC_PATH)
+ 	rm -f $${DESTDIR}$(BIN_PATH)/afl-plot.sh
+-	install -m 755 $(PROGS) $(SH_PROGS) $${DESTDIR}$(BIN_PATH)
++	${INSTALL_PROGRAM} $(PROGS) $${DESTDIR}$(BIN_PATH)
++	${INSTALL_SCRIPT} $(SH_PROGS) $${DESTDIR}$(BIN_PATH)
+ 	rm -f $${DESTDIR}$(BIN_PATH)/afl-as
+-	if [ -f afl-qemu-trace ]; then install -m 755 afl-qemu-trace $${DESTDIR}$(BIN_PATH); fi
+-	if [ -f afl-clang-fast -a -f afl-llvm-pass.so -a -f afl-llvm-rt.o ]; then set -e; install -m 755 afl-clang-fast $${DESTDIR}$(BIN_PATH); ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-fast++; install -m 755 afl-llvm-pass.so afl-llvm-rt.o $${DESTDIR}$(HELPER_PATH); fi
++	if [ -f afl-qemu-trace ]; then ${INSTALL_PROGRAM} afl-qemu-trace $${DESTDIR}$(BIN_PATH); fi
++	if [ -f afl-clang-fast -a -f afl-llvm-pass.so -a -f afl-llvm-rt.o ]; then set -e; ${INSTALL_PROGRAM} afl-clang-fast $${DESTDIR}$(BIN_PATH); ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-fast++; ${INSTALL_PROGRAM} afl-llvm-pass.so $${DESTDIR}$(HELPER_PATH); install -m 755 afl-llvm-rt.o $${DESTDIR}$(HELPER_PATH); fi
+ 	set -e; for i in afl-g++ afl-clang afl-clang++; do ln -sf afl-gcc $${DESTDIR}$(BIN_PATH)/$$i; done
+-	install -m 755 afl-as $${DESTDIR}$(HELPER_PATH)
++	${INSTALL_PROGRAM} afl-as $${DESTDIR}$(HELPER_PATH)
+ 	ln -sf afl-as $${DESTDIR}$(HELPER_PATH)/as
+ 	install -m 644 docs/README docs/ChangeLog docs/*.txt $${DESTDIR}$(DOC_PATH)
+ 	cp -r testcases/ $${DESTDIR}$(MISC_PATH)

Added: head/security/afl/files/patch-llvm__mode_afl-clang-fast.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/security/afl/files/patch-llvm__mode_afl-clang-fast.c	Sat Feb 20 08:00:53 2016	(r409224)
@@ -0,0 +1,15 @@
+--- llvm_mode/afl-clang-fast.c.orig	2015-09-08 22:37:25 UTC
++++ llvm_mode/afl-clang-fast.c
+@@ -106,10 +106,10 @@ static void edit_params(u32 argc, char**
+ 
+   if (!strcmp(name, "afl-clang-fast++")) {
+     u8* alt_cxx = getenv("AFL_CXX");
+-    cc_params[0] = alt_cxx ? alt_cxx : (u8*)"clang++";
++    cc_params[0] = alt_cxx ? alt_cxx : (u8*)"clang++37";
+   } else {
+     u8* alt_cc = getenv("AFL_CC");
+-    cc_params[0] = alt_cc ? alt_cc : (u8*)"clang";
++    cc_params[0] = alt_cc ? alt_cc : (u8*)"clang37";
+   }
+ 
+   cc_params[cc_par_cnt++] = "-Xclang";

Added: head/security/afl/pkg-message
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/security/afl/pkg-message	Sat Feb 20 08:00:53 2016	(r409224)
@@ -0,0 +1 @@
+If you want to use afl-plot also install math/gnuplot.

Modified: head/security/afl/pkg-plist
==============================================================================
--- head/security/afl/pkg-plist	Sat Feb 20 07:16:31 2016	(r409223)
+++ head/security/afl/pkg-plist	Sat Feb 20 08:00:53 2016	(r409224)
@@ -1,11 +1,16 @@
+bin/afl-analyze
 bin/afl-clang
 bin/afl-clang++
+%%LLVM_SUB%%%%LLVM%%bin/afl-clang-fast
+%%LLVM_SUB%%%%LLVM%%bin/afl-clang-fast++
+%%LLVM_SUB%%%%LLVM%%lib/afl/afl-llvm-pass.so
+%%LLVM_SUB%%%%LLVM%%lib/afl/afl-llvm-rt.o
 %%MINIMIZE_CORPUS%%bin/afl-cmin
 bin/afl-fuzz
 bin/afl-g++
 bin/afl-gcc
 bin/afl-gotcpu
-%%PLOT_SUPPORT%%bin/afl-plot
+bin/afl-plot
 bin/afl-showmap
 bin/afl-tmin
 bin/afl-whatsup



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201602200800.u1K80sLq027116>