Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8BCBEC433EF for ; Thu, 7 Apr 2022 09:41:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D678383C04; Thu, 7 Apr 2022 11:41:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="Gpmu732k"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 57C5983C0E; Thu, 7 Apr 2022 11:41:36 +0200 (CEST) Received: from mail-wm1-x349.google.com (mail-wm1-x349.google.com [IPv6:2a00:1450:4864:20::349]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 984D583BBE for ; Thu, 7 Apr 2022 11:41:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=3y7FOYgYKBoIgyi0rrmuumrk.ius0-huuzroyzy.jkt3.jk@flex--ascull.bounces.google.com Received: by mail-wm1-x349.google.com with SMTP id t2-20020a7bc3c2000000b003528fe59cb9so2718146wmj.5 for ; Thu, 07 Apr 2022 02:41:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=/1JNcGdFvjHODq0bmMIAaME+dOzpTd44mj+eJtU04as=; b=Gpmu732khM6SkxwdptWorzMKNiRRXRiZxm25rENXr3kfFQinVi13IAiC/CMltfDQD/ 1iRXIhSn5QBZlQqY/L0UVh+CH1UkszQgrpvTp/w+RmZ2FyQ4JnS7ZYRSDWsh+r+lmNC1 m3CA38UhrivFkaYaWe96aRaGL5Jgd2uUr1eUBSmoF0R4k8xxL4wgDfqVWOjsALhurQd2 3ga0ZhrrmNfRZnTyjV1ZmbKEmvr1oOGkyo8wvMDTyaKdf+uO5OECi7vlCWp/f6Ua6YAE EvDLWAuqdXo/9m8ngcoi9yTpnOHKrx3z0GexDCmGbcxmRrjqiIrdYd7iixnSybHKTLa+ er/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=/1JNcGdFvjHODq0bmMIAaME+dOzpTd44mj+eJtU04as=; b=hPpUfZbMWHhLYDo3B3J7Q1+uu16NVXSxQVF3cz6YJQU/UFLuoDEJKcdvCZn2qQxWNN cajiiX8ZDrBPjsBfQG3/uouUfS4aHjt0+Rkz+3QIpZR10VtOmBA86teU35tvO87evALr Eru+R5wo7LVQeo/5U8vUlnZA3DBVLWo4a6EZSvWbf4sj6uYizTeao3dcvh45EKhFzTtt KzAe9WJCN1QXzm04k8Z1BWKe/sRwFEgCbQLRtT1/GWgZaqhh2infvVlixUNWjNaRW/pe 6JslwfhXDtYKrbHz5o96znjN9YA5FccZzC3dTuEG5EeVfmOvLXi6POCW5RHQbcrdHN7H bT6A== X-Gm-Message-State: AOAM532Am9Yw45Z5BsDaKHkmbMmwgvaPCK9SR5ijQAdiQifKjdOBbbzH YgSuZbdeT+WKqXhissm94540xVw+22ONqRhGTw2YaejOmxx/6lwBj1MiQNJWetIzTUV7pQg+2Cq 6Y1ct1avwGipWoERTdZ4CXYRxG7b1iov+Jf5/GcajILD7CeP890BB6twrWj8= X-Google-Smtp-Source: ABdhPJy3p3uxEXALDv3W/pd4mc+1JnT4BvgQ1fE/HdKzO2W6gXDZTFBioDTLgc9cXMrL4RRUYVLAACqoeFQ= X-Received: from ascull.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1510]) (user=ascull job=sendgmr) by 2002:a1c:35c7:0:b0:38e:4c59:6788 with SMTP id c190-20020a1c35c7000000b0038e4c596788mr402153wma.1.1649324491507; Thu, 07 Apr 2022 02:41:31 -0700 (PDT) Date: Thu, 7 Apr 2022 09:41:12 +0000 Message-Id: <20220407094123.1752236-1-ascull@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.1.1094.g7c7d902a7c-goog Subject: [PATCH 00/11] Fuzzing and ASAN for sandbox From: Andrew Scull To: u-boot@lists.denx.de Cc: sjg@chromium.org, seanga2@gmail.com, Andrew Scull Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean This series sets up a basic fuzzing infrastructure that works with sandbox. The example fuzz test towards the end of the series will find something pretty quickly (that something is fixed by "virtio_ring: Maintain a shadow copy of descriptors" from another series). There is some refactoring to stop using '.' prefixed sections that elf defines as being for system use and clang's ASAN instrumentation happily adds redzones between, but that's not what we want for things like linker lists where the linker script has carefully placed the sections contiguously. It may require patches from the "Fix misc ASAN reports" series to be applied as I've already dealt with the first set of ASAN reports from running the tests. Andrew Scull (11): sandbox: Set the EFI symbols in linker script sandbox: Migrate getopt section to linker list linker_lists: Rename sections to remove . prefix sandbox: Add support for Address Sanitizer fuzzing_engine: Add fuzzing engine uclass test: fuzz: Add framework for fuzzing sandbox: Decouple program entry from sandbox init sandbox: Add libfuzzer integration sandbox: Implement fuzzing engine driver fuzz: virtio: Add fuzzer for vring RFC: Hack dlmalloc to poison memory Kconfig | 15 + arch/Kconfig | 2 + arch/arc/cpu/u-boot.lds | 4 +- arch/arm/config.mk | 4 +- arch/arm/cpu/arm926ejs/sunxi/u-boot-spl.lds | 4 +- arch/arm/cpu/armv7/sunxi/u-boot-spl.lds | 4 +- arch/arm/cpu/armv8/u-boot-spl.lds | 4 +- arch/arm/cpu/armv8/u-boot.lds | 4 +- arch/arm/cpu/u-boot-spl.lds | 4 +- arch/arm/cpu/u-boot.lds | 6 +- arch/arm/mach-at91/arm926ejs/u-boot-spl.lds | 2 +- arch/arm/mach-at91/armv7/u-boot-spl.lds | 2 +- arch/arm/mach-omap2/u-boot-spl.lds | 4 +- arch/arm/mach-orion5x/u-boot-spl.lds | 4 +- arch/arm/mach-rockchip/u-boot-tpl-v8.lds | 4 +- arch/arm/mach-zynq/u-boot-spl.lds | 4 +- arch/arm/mach-zynq/u-boot.lds | 4 +- arch/m68k/cpu/u-boot.lds | 4 +- arch/microblaze/cpu/u-boot-spl.lds | 4 +- arch/microblaze/cpu/u-boot.lds | 4 +- arch/mips/config.mk | 2 +- arch/mips/cpu/u-boot-spl.lds | 4 +- arch/mips/cpu/u-boot.lds | 4 +- arch/nds32/cpu/n1213/u-boot.lds | 4 +- arch/nios2/cpu/u-boot.lds | 4 +- arch/powerpc/cpu/mpc83xx/u-boot.lds | 4 +- arch/powerpc/cpu/mpc85xx/u-boot-nand.lds | 4 +- arch/powerpc/cpu/mpc85xx/u-boot-nand_spl.lds | 4 +- arch/powerpc/cpu/mpc85xx/u-boot-spl.lds | 4 +- arch/powerpc/cpu/mpc85xx/u-boot.lds | 4 +- arch/riscv/cpu/u-boot-spl.lds | 4 +- arch/riscv/cpu/u-boot.lds | 4 +- arch/sandbox/config.mk | 15 +- arch/sandbox/cpu/os.c | 97 +++++- arch/sandbox/cpu/start.c | 12 +- arch/sandbox/cpu/u-boot-spl.lds | 10 +- arch/sandbox/cpu/u-boot.lds | 42 +-- arch/sandbox/dts/test.dts | 4 + arch/sandbox/include/asm/fuzzing_engine.h | 25 ++ arch/sandbox/include/asm/getopt.h | 19 +- arch/sandbox/include/asm/main.h | 18 ++ arch/sandbox/include/asm/sections.h | 25 -- arch/sandbox/lib/Makefile | 2 +- arch/sandbox/lib/sections.c | 13 - arch/sh/cpu/u-boot.lds | 4 +- arch/x86/cpu/u-boot-64.lds | 6 +- arch/x86/cpu/u-boot-spl.lds | 6 +- arch/x86/cpu/u-boot.lds | 6 +- arch/x86/lib/elf_ia32_efi.lds | 4 +- arch/x86/lib/elf_x86_64_efi.lds | 4 +- arch/xtensa/cpu/u-boot.lds | 2 +- arch/xtensa/include/asm/ldscript.h | 4 +- board/compulab/cm_t335/u-boot.lds | 4 +- board/cssi/MCR3000/u-boot.lds | 4 +- .../davinci/da8xxevm/u-boot-spl-da850evm.lds | 2 +- board/qualcomm/dragonboard820c/u-boot.lds | 4 +- board/samsung/common/exynos-uboot-spl.lds | 4 +- board/synopsys/iot_devkit/u-boot.lds | 4 +- board/ti/am335x/u-boot.lds | 4 +- board/vscom/baltos/u-boot.lds | 4 +- common/dlmalloc.c | 284 +++++++++++++++--- configs/sandbox_defconfig | 1 + doc/api/linker_lists.rst | 22 +- doc/develop/commands.rst | 4 +- doc/develop/driver-model/of-plat.rst | 4 +- drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/fuzzing_engine/Kconfig | 17 ++ drivers/fuzzing_engine/Makefile | 8 + .../fuzzing_engine/fuzzing_engine-uclass.c | 28 ++ .../fuzzing_engine/sandbox_fuzzing_engine.c | 35 +++ include/compiler.h | 1 + include/dm/uclass-id.h | 1 + include/fuzzing_engine.h | 51 ++++ include/linker_lists.h | 18 +- include/linux/types.h | 1 + include/test/fuzz.h | 51 ++++ test/Makefile | 1 + test/fuzz/Makefile | 8 + test/fuzz/cmd_fuzz.c | 82 +++++ test/fuzz/virtio.c | 72 +++++ 81 files changed, 909 insertions(+), 264 deletions(-) create mode 100644 arch/sandbox/include/asm/fuzzing_engine.h create mode 100644 arch/sandbox/include/asm/main.h delete mode 100644 arch/sandbox/lib/sections.c create mode 100644 drivers/fuzzing_engine/Kconfig create mode 100644 drivers/fuzzing_engine/Makefile create mode 100644 drivers/fuzzing_engine/fuzzing_engine-uclass.c create mode 100644 drivers/fuzzing_engine/sandbox_fuzzing_engine.c create mode 100644 include/fuzzing_engine.h create mode 100644 include/test/fuzz.h create mode 100644 test/fuzz/Makefile create mode 100644 test/fuzz/cmd_fuzz.c create mode 100644 test/fuzz/virtio.c -- 2.35.1.1094.g7c7d902a7c-goog