app-forensics/honggfuzz: unbreak --linux_perf_bts_block flag
authorSergei Trofimovich <slyfox@gentoo.org>
Fri, 11 Nov 2016 23:02:48 +0000 (23:02 +0000)
committerSergei Trofimovich <slyfox@gentoo.org>
Fri, 11 Nov 2016 23:03:20 +0000 (23:03 +0000)
Workaround --linux_perf_bts_block flag breakage.

Mateusz reports that running honggfuzz fails as:
    [2016-11-11T21:54:27+0000][W][1190] arch_perfOpen():223 mmap(mmapAuxBuf) failed,
    try increasing the kernel.perf_event_mlock_kb sysctl (up to even 300000000): Cannot allocate memory

It seems aux data also needs WRITE permissions.

Reported-by: Mateusz Lenik
Package-Manager: portage-2.3.2

app-forensics/honggfuzz/files/honggfuzz-0.8-bts-perms.patch [new file with mode: 0644]
app-forensics/honggfuzz/honggfuzz-0.8-r1.ebuild [new file with mode: 0644]

diff --git a/app-forensics/honggfuzz/files/honggfuzz-0.8-bts-perms.patch b/app-forensics/honggfuzz/files/honggfuzz-0.8-bts-perms.patch
new file mode 100644 (file)
index 0000000..e8ac491
--- /dev/null
@@ -0,0 +1,19 @@
+Workaround --linux_perf_bts_block flag breakage.
+
+Mateusz reports that running honggfuzz fails as:
+    [2016-11-11T21:54:27+0000][W][1190] arch_perfOpen():223 mmap(mmapAuxBuf) failed,
+    try increasing the kernel.perf_event_mlock_kb sysctl (up to even 300000000): Cannot allocate memory
+
+It seems aux data also needs WRITE permissions.
+
+Reported-by: Mateusz Lenik
+diff --git a/linux/perf.c b/linux/perf.c
+index d8ede5f..2f71b3d 100644
+--- a/linux/perf.c
++++ b/linux/perf.c
+@@ -217,3 +217,4 @@ static bool arch_perfOpen(honggfuzz_t * hfuzz, fuzzer_t * fuzzer UNUSED, pid_t p
+     fuzzer->linux.perfMmapAux =
+-        mmap(NULL, pem->aux_size, PROT_READ, MAP_SHARED, *perfFd, pem->aux_offset);
++        mmap(NULL, pem->aux_size, PROT_READ | PROT_WRITE, MAP_SHARED, *perfFd, pem->aux_offset);
++
+     if (fuzzer->linux.perfMmapAux == MAP_FAILED) {
diff --git a/app-forensics/honggfuzz/honggfuzz-0.8-r1.ebuild b/app-forensics/honggfuzz/honggfuzz-0.8-r1.ebuild
new file mode 100644 (file)
index 0000000..8c9774c
--- /dev/null
@@ -0,0 +1,42 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=6
+
+inherit toolchain-funcs
+
+DESCRIPTION="A general purpose fuzzer with feedback support"
+HOMEPAGE="http://google.github.io/honggfuzz/"
+SRC_URI="https://github.com/google/honggfuzz/archive/${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="Apache-2.0"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE=""
+
+RDEPEND="
+       sys-libs/binutils-libs:=
+       sys-libs/libunwind
+"
+
+DEPEND="${RDEPEND}"
+
+DOCS=(
+       CHANGELOG
+       COPYING
+       CONTRIBUTING
+       README.md
+)
+
+PATCHES=("${FILESDIR}"/${P}-bts-perms.patch)
+
+src_compile() {
+       CC="$(tc-getCC)" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" emake
+}
+
+src_install() {
+       dobin ${PN}
+
+       einstalldocs
+}