google / AFL

american fuzzy lop - a security-oriented fuzzer
https://lcamtuf.coredump.cx/afl/
Apache License 2.0
3.68k stars 635 forks source link

Kali Rolling 2020.3 ‘memfd_create’ Error When Building qemu Support #108

Open ninp0 opened 4 years ago

ninp0 commented 4 years ago

Looks like the following error is still happening in Kali despite being fixed in Debian & Ubuntu. Fwiw, this issue occurs in the master branch:

$ ./build_qemu_support.sh 
=================================================
AFL binary-only instrumentation QEMU build script
=================================================

[*] Performing basic sanity checks...
[+] All checks passed!
[*] Downloading QEMU 2.10.0 from the web...
--2020-07-24 05:18:48--  http://download.qemu-project.org/qemu-2.10.0.tar.xz
Resolving download.qemu-project.org (download.qemu-project.org)... 172.99.69.163
Connecting to download.qemu-project.org (download.qemu-project.org)|172.99.69.163|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://download.qemu.org/qemu-2.10.0.tar.xz [following]
--2020-07-24 05:18:49--  http://download.qemu.org/qemu-2.10.0.tar.xz
Resolving download.qemu.org (download.qemu.org)... 172.99.69.163
Reusing existing connection to download.qemu-project.org:80.
HTTP request sent, awaiting response... 302 Found
Location: https://download.qemu.org/qemu-2.10.0.tar.xz [following]
--2020-07-24 05:18:49--  https://download.qemu.org/qemu-2.10.0.tar.xz
Connecting to download.qemu.org (download.qemu.org)|172.99.69.163|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25040324 (24M) [application/x-xz]
Saving to: ‘qemu-2.10.0.tar.xz’

qemu-2.10.0.tar.xz                          100%[========================================================================================>]  23.88M  12.6MB/s    in 1.9s    

2020-07-24 05:18:52 (12.6 MB/s) - ‘qemu-2.10.0.tar.xz’ saved [25040324/25040324]

[+] Cryptographic signature on qemu-2.10.0.tar.xz checks out.
[*] Uncompressing archive (this will take a while)...
[+] Unpacking successful.
[*] Configuring QEMU for ...
[*] Applying patches...
patching file linux-user/elfload.c
patching file accel/tcg/cpu-exec.c
patching file linux-user/syscall.c
[+] Patching done.
Install prefix    /usr/local
BIOS directory    /usr/local/share/qemu
binary directory  /usr/local/bin
library directory /usr/local/lib
module directory  /usr/local/lib/qemu
libexec directory /usr/local/libexec
include directory /usr/local/include
config directory  /usr/local/etc
local state directory   /usr/local/var
Manual directory  /usr/local/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path       /opt/afl-dev/qemu_mode/qemu-2.10.0
C compiler        cc
Host C compiler   cc
C++ compiler      c++
Objective-C compiler clang
ARFLAGS           rv
CFLAGS            -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g -O3 -ggdb
QEMU_CFLAGS       -I/usr/include/pixman-1 -I$(SRC_PATH)/dtc/libfdt -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -DNCURSES_WIDECHAR -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -fPIE -DPIE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv  -Wexpansion-to-defined -Wendif-labels -Wno-shift-negative-value -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-strong  -I/usr/include/libusb-1.0
LDFLAGS           -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g 
make              make
install           install
python            python -B
smbd              /usr/sbin/smbd
module support    no
host CPU          x86_64
host big endian   no
target list       x86_64-linux-user
gprof enabled     no
sparse enabled    no
strip binaries    yes
profiler          no
static build      no
pixman            system
SDL support       no 
GTK support       no 
GTK GL support    no
VTE support       no 
TLS priority      NORMAL
GNUTLS support    no
GNUTLS rnd        no
libgcrypt         no
libgcrypt kdf     no
nettle            no 
nettle kdf        no
libtasn1          no
curses support    yes
virgl support     no
curl support      yes
mingw32 support   no
Audio drivers     oss
Block whitelist (rw) 
Block whitelist (ro) 
VirtFS support    
VNC support       no
xen support       no
brlapi support    no
bluez  support    yes
Documentation     no
PIE               yes
vde support       no
netmap support    no
Linux AIO support no
ATTR/XATTR support yes
Install blobs     yes
KVM support       yes
HAX support       no
TCG support       yes
TCG debug enabled no
TCG interpreter   no
RDMA support      no
fdt support       yes
preadv support    yes
fdatasync         yes
madvise           yes
posix_madvise     yes
libcap-ng support no
vhost-net support yes
vhost-scsi support yes
vhost-vsock support yes
vhost-user support yes
Trace backends    log
spice support     no 
rbd support       no
xfsctl support    no
smartcard support no
libusb            yes
usb net redir     no
OpenGL support    no
OpenGL dmabufs    no
libiscsi support  no
libnfs support    no
build guest agent yes
QGA VSS support   no
QGA w32 disk info no
QGA MSI support   no
seccomp support   yes
coroutine backend ucontext
coroutine pool    yes
debug stack usage no
crypto afalg      no
GlusterFS support no
gcov              gcov
gcov enabled      no
TPM support       yes
libssh2 support   no
TPM passthrough   yes
QOM debugging     yes
Live block migration yes
lzo support       no
snappy support    no
bzip2 support     yes
NUMA host support no
tcmalloc support  no
jemalloc support  no
avx2 optimization yes
replication support yes
VxHS block device no
[+] Configuration complete.
[*] Attempting to build QEMU (fingers crossed!)...
  GEN     x86_64-linux-user/config-devices.mak.tmp
  GEN     x86_64-linux-user/config-devices.mak
  GEN     config-all-devices.mak
  GEN     config-host.h
     DEP tests/dumptrees.c
     DEP tests/trees.S
     DEP tests/testutils.c
     DEP tests/value-labels.c
     DEP tests/asm_tree_dump.c
     DEP tests/truncated_property.c
     DEP tests/check_path.c
     DEP tests/overlay_bad_fixup.c
     DEP tests/overlay.c
     DEP tests/subnode_iterate.c
     DEP tests/property_iterate.c
     DEP tests/integer-expressions.c
     DEP tests/utilfdt_test.c
     DEP tests/path_offset_aliases.c
     DEP tests/add_subnode_with_nops.c
     DEP tests/dtbs_equal_unordered.c
     DEP tests/dtb_reverse.c
     DEP tests/dtbs_equal_ordered.c
     DEP tests/extra-terminating-null.c
     DEP tests/incbin.c
     DEP tests/boot-cpuid.c
     DEP tests/phandle_format.c
     DEP tests/path-references.c
     DEP tests/references.c
     DEP tests/string_escapes.c
     DEP tests/propname_escapes.c
     DEP tests/appendprop2.c
     DEP tests/appendprop1.c
     DEP tests/del_node.c
     DEP tests/del_property.c
     DEP tests/setprop.c
     DEP tests/set_name.c
     DEP tests/rw_tree1.c
     DEP tests/open_pack.c
     DEP tests/nopulate.c
     DEP tests/mangle-layout.c
     DEP tests/move_and_save.c
     DEP tests/sw_tree1.c
     DEP tests/nop_node.c
     DEP tests/nop_property.c
     DEP tests/setprop_inplace.c
     DEP tests/stringlist.c
     DEP tests/addr_size_cells.c
     DEP tests/notfound.c
     DEP tests/sized_cells.c
     DEP tests/char_literal.c
     DEP tests/get_alias.c
     DEP tests/node_offset_by_compatible.c
     DEP tests/node_check_compatible.c
     DEP tests/node_offset_by_phandle.c
     DEP tests/node_offset_by_prop_value.c
     DEP tests/parent_offset.c
     DEP tests/supernode_atdepth_offset.c
     DEP tests/get_path.c
     DEP tests/get_phandle.c
     DEP tests/getprop.c
     DEP tests/get_name.c
     DEP tests/path_offset.c
     DEP tests/subnode_offset.c
     DEP tests/find_property.c
     DEP tests/root_node.c
     DEP tests/get_mem_rsv.c
     DEP libfdt/fdt_overlay.c
     DEP libfdt/fdt_addresses.c
     DEP libfdt/fdt_empty_tree.c
     DEP libfdt/fdt_strerror.c
     DEP libfdt/fdt_rw.c
     DEP libfdt/fdt_sw.c
     DEP libfdt/fdt_wip.c
     DEP libfdt/fdt_ro.c
     DEP libfdt/fdt.c
     DEP util.c
     DEP fdtput.c
     DEP fdtget.c
     DEP fdtdump.c
     LEX convert-dtsv0-lexer.lex.c
     DEP convert-dtsv0-lexer.lex.c
     DEP srcpos.c
     BISON dtc-parser.tab.c
     DEP dtc-parser.tab.c
     LEX dtc-lexer.lex.c
     DEP dtc-lexer.lex.c
     DEP treesource.c
     DEP livetree.c
     DEP fstree.c
     DEP flattree.c
     DEP dtc.c
     DEP data.c
     DEP checks.c
    CHK version_gen.h
    UPD version_gen.h
     DEP util.c
    CHK version_gen.h
     CC libfdt/fdt.o
     CC libfdt/fdt_ro.o
     CC libfdt/fdt_wip.o
     CC libfdt/fdt_sw.o
     CC libfdt/fdt_rw.o
     CC libfdt/fdt_strerror.o
     CC libfdt/fdt_empty_tree.o
     CC libfdt/fdt_addresses.o
     CC libfdt/fdt_overlay.o
     AR libfdt/libfdt.a
ar: creating libfdt/libfdt.a
a - libfdt/fdt.o
a - libfdt/fdt_ro.o
a - libfdt/fdt_wip.o
a - libfdt/fdt_sw.o
a - libfdt/fdt_rw.o
a - libfdt/fdt_strerror.o
a - libfdt/fdt_empty_tree.o
a - libfdt/fdt_addresses.o
a - libfdt/fdt_overlay.o
  GEN     qemu-options.def
  GEN     qmp-commands.h
  GEN     qapi-types.h
  GEN     qapi-visit.h
  GEN     qapi-event.h
  GEN     qmp-marshal.c
  GEN     qapi-types.c
  GEN     qapi-visit.c
  GEN     qapi-event.c
  GEN     qmp-introspect.h
  GEN     qmp-introspect.c
  GEN     trace/generated-tcg-tracers.h
  GEN     trace/generated-helpers-wrappers.h
  GEN     trace/generated-helpers.h
  GEN     trace/generated-helpers.c
  GEN     module_block.h
  GEN     tests/test-qapi-types.h
  GEN     tests/test-qapi-visit.h
  GEN     tests/test-qmp-commands.h
  GEN     tests/test-qapi-event.h
  GEN     tests/test-qmp-introspect.h
  GEN     trace-root.h
  GEN     util/trace.h
  GEN     crypto/trace.h
  GEN     io/trace.h
  GEN     migration/trace.h
  GEN     block/trace.h
  GEN     chardev/trace.h
  GEN     hw/block/trace.h
  GEN     hw/block/dataplane/trace.h
  GEN     hw/char/trace.h
  GEN     hw/intc/trace.h
  GEN     hw/net/trace.h
  GEN     hw/virtio/trace.h
  GEN     hw/audio/trace.h
  GEN     hw/misc/trace.h
  GEN     hw/usb/trace.h
  GEN     hw/scsi/trace.h
  GEN     hw/nvram/trace.h
  GEN     hw/display/trace.h
  GEN     hw/input/trace.h
  GEN     hw/timer/trace.h
  GEN     hw/dma/trace.h
  GEN     hw/sparc/trace.h
  GEN     hw/sd/trace.h
  GEN     hw/isa/trace.h
  GEN     hw/mem/trace.h
  GEN     hw/i386/trace.h
  GEN     hw/i386/xen/trace.h
  GEN     hw/9pfs/trace.h
  GEN     hw/ppc/trace.h
  GEN     hw/pci/trace.h
  GEN     hw/s390x/trace.h
  GEN     hw/vfio/trace.h
  GEN     hw/acpi/trace.h
  GEN     hw/arm/trace.h
  GEN     hw/alpha/trace.h
  GEN     hw/xen/trace.h
  GEN     ui/trace.h
  GEN     audio/trace.h
  GEN     net/trace.h
  GEN     target/arm/trace.h
  GEN     target/i386/trace.h
  GEN     target/mips/trace.h
  GEN     target/sparc/trace.h
  GEN     target/s390x/trace.h
  GEN     target/ppc/trace.h
  GEN     qom/trace.h
  GEN     linux-user/trace.h
  GEN     qapi/trace.h
  GEN     accel/tcg/trace.h
  GEN     accel/kvm/trace.h
  GEN     nbd/trace.h
  GEN     trace-root.c
  GEN     util/trace.c
  GEN     crypto/trace.c
  GEN     io/trace.c
  GEN     migration/trace.c
  GEN     block/trace.c
  GEN     chardev/trace.c
  GEN     hw/block/trace.c
  GEN     hw/block/dataplane/trace.c
  GEN     hw/char/trace.c
  GEN     hw/intc/trace.c
  GEN     hw/net/trace.c
  GEN     hw/virtio/trace.c
  GEN     hw/audio/trace.c
  GEN     hw/misc/trace.c
  GEN     hw/usb/trace.c
  GEN     hw/scsi/trace.c
  GEN     hw/nvram/trace.c
  GEN     hw/display/trace.c
  GEN     hw/input/trace.c
  GEN     hw/timer/trace.c
  GEN     hw/dma/trace.c
  GEN     hw/sparc/trace.c
  GEN     hw/sd/trace.c
  GEN     hw/isa/trace.c
  GEN     hw/mem/trace.c
  GEN     hw/i386/trace.c
  GEN     hw/i386/xen/trace.c
  GEN     hw/9pfs/trace.c
  GEN     hw/ppc/trace.c
  GEN     hw/pci/trace.c
  GEN     hw/s390x/trace.c
  GEN     hw/vfio/trace.c
  GEN     hw/acpi/trace.c
  GEN     hw/arm/trace.c
  GEN     hw/alpha/trace.c
  GEN     hw/xen/trace.c
  GEN     ui/trace.c
  GEN     audio/trace.c
  GEN     net/trace.c
  GEN     target/arm/trace.c
  GEN     target/i386/trace.c
  GEN     target/mips/trace.c
  GEN     target/sparc/trace.c
  GEN     target/s390x/trace.c
  GEN     target/ppc/trace.c
  GEN     qom/trace.c
  GEN     linux-user/trace.c
  GEN     qapi/trace.c
  GEN     accel/tcg/trace.c
  GEN     accel/kvm/trace.c
  GEN     nbd/trace.c
    CHK version_gen.h
  CC      tests/qemu-iotests/socket_scm_helper.o
  LINK    tests/qemu-iotests/socket_scm_helper
  GEN     qga/qapi-generated/qga-qapi-types.h
  GEN     qga/qapi-generated/qga-qapi-visit.h
  GEN     qga/qapi-generated/qga-qmp-commands.h
  CC      qga/commands.o
  CC      qga/guest-agent-command-state.o
  CC      qga/main.o
qga/main.c: In function ‘ga_log’:
qga/main.c:300:5: warning: ‘GTimeVal’ is deprecated: Use 'GDateTime' instead [-Wdeprecated-declarations]
  300 |     GTimeVal time;
      |     ^~~~~~~~
In file included from /usr/include/glib-2.0/glib/galloca.h:32,
                 from /usr/include/glib-2.0/glib.h:30,
                 from /opt/afl-dev/qemu_mode/qemu-2.10.0/include/glib-compat.h:19,
                 from /opt/afl-dev/qemu_mode/qemu-2.10.0/include/qemu/osdep.h:107,
                 from qga/main.c:13:
/usr/include/glib-2.0/glib/gtypes.h:547:8: note: declared here
  547 | struct _GTimeVal
      |        ^~~~~~~~~
qga/main.c:315:9: warning: ‘g_get_current_time’ is deprecated: Use 'g_get_real_time' instead [-Wdeprecated-declarations]
  315 |         g_get_current_time(&time);
      |         ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/glib/giochannel.h:33,
                 from /usr/include/glib-2.0/glib.h:54,
                 from /opt/afl-dev/qemu_mode/qemu-2.10.0/include/glib-compat.h:19,
                 from /opt/afl-dev/qemu_mode/qemu-2.10.0/include/qemu/osdep.h:107,
                 from qga/main.c:13:
/usr/include/glib-2.0/glib/gmain.h:679:8: note: declared here
  679 | void   g_get_current_time                 (GTimeVal       *result);
      |        ^~~~~~~~~~~~~~~~~~
  CC      qga/commands-posix.o
  CC      qga/channel-posix.o
  GEN     qga/qapi-generated/qga-qapi-types.c
  CC      qga/qapi-generated/qga-qapi-types.o
  GEN     qga/qapi-generated/qga-qapi-visit.c
  CC      qga/qapi-generated/qga-qapi-visit.o
  GEN     qga/qapi-generated/qga-qmp-marshal.c
  CC      qga/qapi-generated/qga-qmp-marshal.o
  CC      qmp-introspect.o
  CC      qapi-types.o
  CC      qapi-visit.o
  CC      qapi-event.o
  CC      qapi/qapi-visit-core.o
  CC      qapi/qapi-dealloc-visitor.o
  CC      qapi/qobject-input-visitor.o
  CC      qapi/qobject-output-visitor.o
  CC      qapi/qmp-registry.o
  CC      qapi/qmp-dispatch.o
  CC      qapi/string-input-visitor.o
qapi/string-input-visitor.c: In function ‘parse_type_uint64’:
qapi/string-input-visitor.c:261:14: warning: ‘i’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  261 |         *obj = i;
      |         ~~~~~^~~
  CC      qapi/string-output-visitor.o
  CC      qapi/opts-visitor.o
  CC      qapi/qapi-clone-visitor.o
  CC      qapi/qmp-event.o
  CC      qapi/qapi-util.o
  CC      qobject/qnull.o
  CC      qobject/qnum.o
  CC      qobject/qstring.o
  CC      qobject/qdict.o
  CC      qobject/qlist.o
  CC      qobject/qbool.o
  CC      qobject/qjson.o
  CC      qobject/qobject.o
  CC      qobject/json-lexer.o
  CC      qobject/json-streamer.o
  CC      qobject/json-parser.o
  CC      trace/control.o
  CC      trace/qmp.o
  CC      util/osdep.o
  CC      util/cutils.o
  CC      util/unicode.o
  CC      util/qemu-timer-common.o
  CC      util/bufferiszero.o
  CC      util/lockcnt.o
  CC      util/aiocb.o
  CC      util/async.o
  CC      util/thread-pool.o
  CC      util/qemu-timer.o
  CC      util/main-loop.o
  CC      util/iohandler.o
  CC      util/aio-posix.o
  CC      util/compatfd.o
  CC      util/event_notifier-posix.o
  CC      util/mmap-alloc.o
  CC      util/oslib-posix.o
  CC      util/qemu-openpty.o
  CC      util/qemu-thread-posix.o
  CC      util/memfd.o
util/memfd.c:40:12: error: static declaration of ‘memfd_create’ follows non-static declaration
   40 | static int memfd_create(const char *name, unsigned int flags)
      |            ^~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/mman-linux.h:111,
                 from /usr/include/x86_64-linux-gnu/bits/mman.h:34,
                 from /usr/include/x86_64-linux-gnu/sys/mman.h:41,
                 from /opt/afl-dev/qemu_mode/qemu-2.10.0/include/sysemu/os-posix.h:29,
                 from /opt/afl-dev/qemu_mode/qemu-2.10.0/include/qemu/osdep.h:104,
                 from util/memfd.c:28:
/usr/include/x86_64-linux-gnu/bits/mman-shared.h:50:5: note: previous declaration of ‘memfd_create’ was here
   50 | int memfd_create (const char *__name, unsigned int __flags) __THROW;
      |     ^~~~~~~~~~~~
make: *** [/opt/afl-dev/qemu_mode/qemu-2.10.0/rules.mak:66: util/memfd.o] Error 1
$ lsb_release -a
No LSB modules are available.
Distributor ID: Kali
Description:    Kali GNU/Linux Rolling
Release:    2020.3
Codename:   kali-rolling