From mboxrd@z Thu Jan 1 00:00:00 1970 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 A8E6CC433F5 for ; Thu, 7 Apr 2022 09:43:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E89F483D98; Thu, 7 Apr 2022 11:42:55 +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="iEX9HIbG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3406B83C6C; Thu, 7 Apr 2022 11:42:11 +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 0300383C11 for ; Thu, 7 Apr 2022 11:41:51 +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=337FOYgYKBpY0I2KBB6EE6B4.2ECK-1EEJB8IJI.34DN.34@flex--ascull.bounces.google.com Received: by mail-wm1-x349.google.com with SMTP id i6-20020a05600c354600b0038be262d9d9so4329073wmq.8 for ; Thu, 07 Apr 2022 02:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=sWShb86y2hVliJEAjnPImgDT8TeGmkFhh8uUCa7pyYw=; b=iEX9HIbGQl0jbJCLhqCv234V/yMqCQd+1yL22VrMlgydGdUM9/7yTLk8CQIacsGopO i7LE6NW1O45gcRN91ZXWszi5Xg4tH5KL/e1fZAB1BUHDN4nxEUVpVQYONs7nKO1/Yfcs xiKi4eJpeFirGf07piPoJ7YPXvFuvtHcPP3fO79SGQ+plDiJu74fnsmer4k3yUGhFLtK Or2Pf852/kLUkM7iItuTk7v0CoWktXgRcMvpuNIEl6zMZa4CM1CSJJu53mHeb7ZeKaQy oG/NTO5161AlPGmL2zTHGw/iok63AYReVbbETPWY5RDOejEIYvuPtzwXu+i9jpPGtbh5 qzmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=sWShb86y2hVliJEAjnPImgDT8TeGmkFhh8uUCa7pyYw=; b=hmujNrvuyx56zb8amvFeinRp9ZCLGV1N8ybL8EtPcjqyDfftkQSFJ5iH8JSRgWdiOj IEXcgNzitQUUCka27u8pDr/+UPjn5zDbTgMNJvmpcLH+7ZAH+q4MkV3wLZAe9W9X50uK SROXNKv39irpyEl7FyikBly6Vz3+Pa3fqaNEYmIVhScOdbsWPEQnkZhI/P6/jvxOuiSk qtBJ82vJPLZD2ethZHhlZQA/STGGaRnstubgrR+SSrPdLg8RUO2IzA9y47AY/pVciPov iFcbd3KfkiTGn2YyyRfjnuUKpMSe1DlPIoQFc01mhih86wzBOdRw8WWGl/P0SXEd+7S7 hY0w== X-Gm-Message-State: AOAM530P4ooaCGdMGogBCYnffTPkec4p6LVH4d723RmHjo+b0aQwMaua wGjwrN1ugy/BiCkPPRT4wnS11Rcf6Nax0plXoVRTv/MKU4y3+fDv2HcLKo0esWNVqUhCkbLOlYO oAOzHaA16lCH+cPREN6Um9AeC2BYkpTcAs5aN5DqlKTbPQxrYEqmlLCnPYuQ= X-Google-Smtp-Source: ABdhPJy9HA8f3onO4o/63c+COPIuXvGz9sN59IzhozsJ5sir3ON9Jt/NAykYeSqADFuzsm7Cn337kPc5sxc= X-Received: from ascull.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1510]) (user=ascull job=sendgmr) by 2002:a7b:c841:0:b0:389:864c:e715 with SMTP id c1-20020a7bc841000000b00389864ce715mr11195163wml.72.1649324511348; Thu, 07 Apr 2022 02:41:51 -0700 (PDT) Date: Thu, 7 Apr 2022 09:41:21 +0000 In-Reply-To: <20220407094123.1752236-1-ascull@google.com> Message-Id: <20220407094123.1752236-10-ascull@google.com> Mime-Version: 1.0 References: <20220407094123.1752236-1-ascull@google.com> X-Mailer: git-send-email 2.35.1.1094.g7c7d902a7c-goog Subject: [PATCH 09/11] sandbox: Implement fuzzing engine driver 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 Add a fuzzing engine driver for the sandbox to take inputs from libfuzzer and expose them to the fuzz tests. Signed-off-by: Andrew Scull --- arch/Kconfig | 2 ++ arch/sandbox/dts/test.dts | 4 +++ drivers/fuzzing_engine/Kconfig | 11 ++++++ drivers/fuzzing_engine/Makefile | 1 + .../fuzzing_engine/sandbox_fuzzing_engine.c | 35 +++++++++++++++++++ 5 files changed, 53 insertions(+) create mode 100644 drivers/fuzzing_engine/sandbox_fuzzing_engine.c diff --git a/arch/Kconfig b/arch/Kconfig index e6191446a3..6320a98db6 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -135,6 +135,7 @@ config SANDBOX select BZIP2 select CMD_POWEROFF select DM + select DM_FUZZING_ENGINE select DM_GPIO select DM_I2C select DM_KEYBOARD @@ -170,6 +171,7 @@ config SANDBOX imply CRC32_VERIFY imply FAT_WRITE imply FIRMWARE + imply FUZZING_ENGINE_SANDBOX imply HASH_VERIFY imply LZMA imply TEE diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 48ca3e1e47..848329fda5 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -71,6 +71,10 @@ }; }; + fuzzing-engine { + compatible = "sandbox,sandbox-fuzzing-engine"; + }; + reboot-mode0 { compatible = "reboot-mode-gpio"; gpios = <&gpio_c 0 GPIO_ACTIVE_HIGH>, <&gpio_c 1 GPIO_ACTIVE_HIGH>; diff --git a/drivers/fuzzing_engine/Kconfig b/drivers/fuzzing_engine/Kconfig index f405fc75e8..6311385222 100644 --- a/drivers/fuzzing_engine/Kconfig +++ b/drivers/fuzzing_engine/Kconfig @@ -4,3 +4,14 @@ config DM_FUZZING_ENGINE help Enable driver model for fuzzing engine devices. This interface is used to get fuzzing inputs from a fuzzing engine. + +if DM_FUZZING_ENGINE + +config FUZZING_ENGINE_SANDBOX + bool "Sanbox fuzzing engine" + depends on SANDBOX + default y + help + Enable fuzzing engine for sandbox. + +endif diff --git a/drivers/fuzzing_engine/Makefile b/drivers/fuzzing_engine/Makefile index acd894999c..073743ba94 100644 --- a/drivers/fuzzing_engine/Makefile +++ b/drivers/fuzzing_engine/Makefile @@ -5,3 +5,4 @@ # obj-$(CONFIG_DM_FUZZING_ENGINE) += fuzzing_engine-uclass.o +obj-$(CONFIG_FUZZING_ENGINE_SANDBOX) += sandbox_fuzzing_engine.o diff --git a/drivers/fuzzing_engine/sandbox_fuzzing_engine.c b/drivers/fuzzing_engine/sandbox_fuzzing_engine.c new file mode 100644 index 0000000000..4d187deaa4 --- /dev/null +++ b/drivers/fuzzing_engine/sandbox_fuzzing_engine.c @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2022 Google, Inc. + * Written by Andrew Scull + */ + +#include +#include +#include +#include + +static int get_input(struct udevice *dev, + const uint8_t **data, + size_t *size) +{ + return sandbox_fuzzing_engine_get_input(data, size); +} + +static const struct dm_fuzzing_engine_ops sandbox_fuzzing_engine_ops = { + .get_input = get_input, +}; + +static const struct udevice_id sandbox_fuzzing_engine_match[] = { + { + .compatible = "sandbox,sandbox-fuzzing-engine", + }, + {}, +}; + +U_BOOT_DRIVER(sandbox_fuzzing_engine) = { + .name = "sandbox-fuzzing-engine", + .id = UCLASS_FUZZING_ENGINE, + .of_match = sandbox_fuzzing_engine_match, + .ops = &sandbox_fuzzing_engine_ops, +}; -- 2.35.1.1094.g7c7d902a7c-goog