diff options
-rw-r--r-- | .SRCINFO | 31 | ||||
-rw-r--r-- | PKGBUILD | 51 | ||||
-rw-r--r-- | glfs_io_cbk.diff | 91 | ||||
-rw-r--r-- | glfs_truncate.diff | 80 | ||||
-rw-r--r-- | memfd.diff | 55 |
5 files changed, 308 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..1da85d895b60 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,31 @@ +pkgbase = afl-qemu + pkgdesc = Lets you fuzz black-box binaries with afl. + pkgver = 2.52b + pkgrel = 1 + url = http://lcamtuf.coredump.cx/afl/ + arch = any + license = apache + depends = afl + depends = libtool + depends = wget + depends = python2 + depends = automake + depends = autoconf + depends = bison + depends = glibc + options = staticlibs + options = !emptydirs + options = !strip + source = http://lcamtuf.coredump.cx/afl/releases/afl-2.52b.tgz + source = http://download.qemu-project.org/qemu-2.10.0.tar.xz + source = memfd.diff + source = glfs_truncate.diff + source = glfs_io_cbk.diff + md5sums = d4fa778e6c2221aee4f5326f22e1983d + md5sums = a89e3293cf69c32cf4be4188dfa25544 + md5sums = 9715c550f9a71c55339a9b9fb8c136ad + md5sums = 05b5604dd7b10f43a8f2dca238d948df + md5sums = 93cce7e3cffc9574b325c886d4686428 + +pkgname = afl-qemu + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..972f41f5a968 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,51 @@ +# Maintainer: Asger Hautop Drewsen <asgerdrewsen@gmail.com> +pkgname=afl-qemu +pkgver=2.52b +pkgrel=1 +pkgdesc="Lets you fuzz black-box binaries with afl." +arch=('any') +url="http://lcamtuf.coredump.cx/afl/" +license=('apache') +depends=('afl' 'libtool' 'wget' 'python2' 'automake' 'autoconf' 'bison' 'glibc') +options=('staticlibs' '!emptydirs' '!strip') +qemu_version="2.10.0" +source=( + "http://lcamtuf.coredump.cx/afl/releases/afl-${pkgver}.tgz" + "http://download.qemu-project.org/qemu-${qemu_version}.tar.xz" + "memfd.diff" + "glfs_truncate.diff" + "glfs_io_cbk.diff" +) +md5sums=('d4fa778e6c2221aee4f5326f22e1983d' + 'a89e3293cf69c32cf4be4188dfa25544' + '9715c550f9a71c55339a9b9fb8c136ad' + '05b5604dd7b10f43a8f2dca238d948df' + '93cce7e3cffc9574b325c886d4686428') + +prepare() { + cd "${srcdir}/afl-${pkgver}/qemu_mode" + rm -rf "qemu-${qemu_version}" + mv "${srcdir}/qemu-${qemu_version}" . + + cd "qemu-${qemu_version}" + for p in ../patches/*.diff; do + patch -p1 < "$p" + done + + patch -p1 < "${srcdir}/memfd.diff" + patch -p1 < "${srcdir}/glfs_truncate.diff" + patch -p1 < "${srcdir}/glfs_io_cbk.diff" +} + +build() { + cd "${srcdir}/afl-${pkgver}/qemu_mode/qemu-${qemu_version}" + CFLAGS="-O3 -ggdb" ./configure --disable-system \ + --enable-linux-user --disable-gtk --disable-sdl --disable-vnc \ + --target-list="x86_64-linux-user" --enable-pie --enable-kvm \ + --python=/usr/bin/python2 + make PREFIX=/usr +} + +package() { + install -D "${srcdir}/afl-${pkgver}/qemu_mode/qemu-${qemu_version}/x86_64-linux-user/qemu-x86_64" "${pkgdir}/usr/bin/afl-qemu-trace" +} diff --git a/glfs_io_cbk.diff b/glfs_io_cbk.diff new file mode 100644 index 000000000000..0c49a0e03b15 --- /dev/null +++ b/glfs_io_cbk.diff @@ -0,0 +1,91 @@ +From 0e3b891fefacc0e49f3c8ffa3a753b69eb7214d2 Mon Sep 17 00:00:00 2001 +From: Niels de Vos <ndevos@redhat.com> +Date: Tue, 5 Mar 2019 16:46:34 +0100 +Subject: [PATCH] gluster: the glfs_io_cbk callback function pointer adds + pre/post stat args + +The glfs_*_async() functions do a callback once finished. This callback +has changed its arguments, pre- and post-stat structures have been +added. This makes it possible to improve caching, which is useful for +Samba and NFS-Ganesha, but not so much for QEMU. Gluster 6 is the first +release that includes these new arguments. + +With an additional detection in ./configure, the new arguments can +conditionally get included in the glfs_io_cbk handler. + +Signed-off-by: Niels de Vos <ndevos@redhat.com> +Signed-off-by: Kevin Wolf <kwolf@redhat.com> +--- + block/gluster.c | 6 +++++- + configure | 24 ++++++++++++++++++++++++ + 2 files changed, 29 insertions(+), 1 deletion(-) + +diff --git a/block/gluster.c b/block/gluster.c +index f853aa8..51f184c 100644 +--- a/block/gluster.c ++++ b/block/gluster.c +@@ -729,7 +729,11 @@ static struct glfs *qemu_gluster_init(BlockdevOptionsGluster *gconf, + /* + * AIO callback routine called from GlusterFS thread. + */ +-static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, void *arg) ++static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, ++#ifdef CONFIG_GLUSTERFS_IOCB_HAS_STAT ++ struct glfs_stat *pre, struct glfs_stat *post, ++#endif ++ void *arg) + { + GlusterAIOCB *acb = (GlusterAIOCB *)arg; + +diff --git a/configure b/configure +index 5354d51..45a3654 100755 +--- a/configure ++++ b/configure +@@ -457,6 +457,7 @@ glusterfs_discard="no" + glusterfs_fallocate="no" + glusterfs_zerofill="no" + glusterfs_ftruncate_has_stat="no" ++glusterfs_iocb_has_stat="no" + gtk="" + gtk_gl="no" + tls_priority="NORMAL" +@@ -4105,6 +4106,25 @@ EOF + if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then + glusterfs_ftruncate_has_stat="yes" + fi ++ cat > $TMPC << EOF ++#include <glusterfs/api/glfs.h> ++ ++/* new glfs_io_cbk() passes two additional glfs_stat structs */ ++static void ++glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data) ++{} ++ ++int ++main(void) ++{ ++ glfs_io_cbk iocb = &glusterfs_iocb; ++ iocb(NULL, 0 , NULL, NULL, NULL); ++ return 0; ++} ++EOF ++ if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then ++ glusterfs_iocb_has_stat="yes" ++ fi + else + if test "$glusterfs" = "yes" ; then + feature_not_found "GlusterFS backend support" \ +@@ -6994,6 +7014,10 @@ if test "$glusterfs_ftruncate_has_stat" = "yes" ; then + echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak + fi + ++if test "$glusterfs_iocb_has_stat" = "yes" ; then ++ echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak ++fi ++ + if test "$libssh2" = "yes" ; then + echo "CONFIG_LIBSSH2=m" >> $config_host_mak + echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak +-- +1.8.3.1 + diff --git a/glfs_truncate.diff b/glfs_truncate.diff new file mode 100644 index 000000000000..cc8b397531c9 --- /dev/null +++ b/glfs_truncate.diff @@ -0,0 +1,80 @@ +From e014dbe74e0484188164c61ff6843f8a04a8cb9d Mon Sep 17 00:00:00 2001 +From: Prasanna Kumar Kalever <prasanna.kalever@redhat.com> +Date: Tue, 5 Mar 2019 16:46:33 +0100 +Subject: [PATCH 1/1] gluster: Handle changed glfs_ftruncate signature + +New versions of Glusters libgfapi.so have an updated glfs_ftruncate() +function that returns additional 'struct stat' structures to enable +advanced caching of attributes. This is useful for file servers, not so +much for QEMU. Nevertheless, the API has changed and needs to be +adopted. + +Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com> +Signed-off-by: Niels de Vos <ndevos@redhat.com> +Signed-off-by: Kevin Wolf <kwolf@redhat.com> +--- + block/gluster.c | 4 ++++ + configure | 18 ++++++++++++++++++ + 2 files changed, 22 insertions(+) + +diff --git a/block/gluster.c b/block/gluster.c +index af64330..f853aa8 100644 +--- a/block/gluster.c ++++ b/block/gluster.c +@@ -20,6 +20,10 @@ + #include "qemu/option.h" + #include "qemu/cutils.h" + ++#ifdef CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT ++# define glfs_ftruncate(fd, offset) glfs_ftruncate(fd, offset, NULL, NULL) ++#endif ++ + #define GLUSTER_OPT_FILENAME "filename" + #define GLUSTER_OPT_VOLUME "volume" + #define GLUSTER_OPT_PATH "path" +diff --git a/configure b/configure +index cab830a..5354d51 100755 +--- a/configure ++++ b/configure +@@ -456,6 +456,7 @@ glusterfs_xlator_opt="no" + glusterfs_discard="no" + glusterfs_fallocate="no" + glusterfs_zerofill="no" ++glusterfs_ftruncate_has_stat="no" + gtk="" + gtk_gl="no" + tls_priority="NORMAL" +@@ -4091,6 +4092,19 @@ if test "$glusterfs" != "no" ; then + glusterfs_fallocate="yes" + glusterfs_zerofill="yes" + fi ++ cat > $TMPC << EOF ++#include <glusterfs/api/glfs.h> ++ ++int ++main(void) ++{ ++ /* new glfs_ftruncate() passes two additional args */ ++ return glfs_ftruncate(NULL, 0, NULL, NULL); ++} ++EOF ++ if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then ++ glusterfs_ftruncate_has_stat="yes" ++ fi + else + if test "$glusterfs" = "yes" ; then + feature_not_found "GlusterFS backend support" \ +@@ -6976,6 +6990,10 @@ if test "$glusterfs_zerofill" = "yes" ; then + echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak + fi + ++if test "$glusterfs_ftruncate_has_stat" = "yes" ; then ++ echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak ++fi ++ + if test "$libssh2" = "yes" ; then + echo "CONFIG_LIBSSH2=m" >> $config_host_mak + echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak +-- +1.8.3.1 + diff --git a/memfd.diff b/memfd.diff new file mode 100644 index 000000000000..48149e9885ce --- /dev/null +++ b/memfd.diff @@ -0,0 +1,55 @@ +From 75e5b70e6b5dcc4f2219992d7cffa462aa406af0 Mon Sep 17 00:00:00 2001 +From: Paolo Bonzini <pbonzini@redhat.com> +Date: Tue, 28 Nov 2017 11:51:27 +0100 +Subject: [PATCH 1/1] memfd: fix configure test +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf8 +Content-Transfer-Encoding: 8bit + +Recent glibc added memfd_create in sys/mman.h. This conflicts with +the definition in util/memfd.c: + + /builddir/build/BUILD/qemu-2.11.0-rc1/util/memfd.c:40:12: error: static declaration of memfd_create follows non-static declaration + +Fix the configure test, and remove the sys/memfd.h inclusion since the +file actually does not exist---it is a typo in the memfd_create(2) man +page. + +Cc: Marc-André Lureau <marcandre.lureau@redhat.com> +Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> +--- + configure | 2 +- + util/memfd.c | 4 +--- + 2 files changed, 2 insertions(+), 4 deletions(-) + +diff --git a/configure b/configure +index 9c8aa5a..99ccc17 100755 +--- a/configure ++++ b/configure +@@ -3923,7 +3923,7 @@ fi + # check if memfd is supported + memfd=no + cat > $TMPC << EOF +-#include <sys/memfd.h> ++#include <sys/mman.h> + + int main(void) + { +diff --git a/util/memfd.c b/util/memfd.c +index 4571d1a..412e94a 100644 +--- a/util/memfd.c ++++ b/util/memfd.c +@@ -31,9 +31,7 @@ + + #include "qemu/memfd.h" + +-#ifdef CONFIG_MEMFD +-#include <sys/memfd.h> +-#elif defined CONFIG_LINUX ++#if defined CONFIG_LINUX && !defined CONFIG_MEMFD + #include <sys/syscall.h> + #include <asm/unistd.h> + +-- +1.8.3.1 + |