From nobody Wed Dec 17 21:49:13 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591350676; cv=none; d=zohomail.com; s=zohoarc; b=BPUOWIjADyhGEMOKCwGK+XQo994Fak2oa9flDwD1BSecMWFUKP+fZJeZ0e1FMx7RCz0JcEbVBiRevPMQtE7VZe3QpMm8/tP8iPLm7R+OGrsXWYKTtIWM9ikvLAAbykexU6+GuvZqUXI0tITwO6+G8MB3D/6AdJx8SHjTRnjL0zo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591350676; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PAclCbkK965kzoir3NvjWZkVoHfN2nNhuLsOqTw6Ncc=; b=Qj/Vw6cIRD5kbp9dZgLPaYvUoeC/u9g6ggSmHyVCbtGCLtfLXNxJllVKknCrESvgzzemRnaKhh1qLl1GOdR+RZVlYoNV/sy0nu8IXr4XjBaBmdQXoYm9LRU+EHwaxNEs+aTnn0Ft+zkwjo5QSi83AUMRNx/SR360oZfneVGq+W0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591350676872502.87384294550884; Fri, 5 Jun 2020 02:51:16 -0700 (PDT) Received: from localhost ([::1]:38268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jh90N-0007Cg-Ia for importer@patchew.org; Fri, 05 Jun 2020 05:51:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jh8xq-0002GB-JS for qemu-devel@nongnu.org; Fri, 05 Jun 2020 05:48:38 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:36798 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jh8xp-0006l0-Cj for qemu-devel@nongnu.org; Fri, 05 Jun 2020 05:48:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-95-f6vMfDOrOO2yVomshhH3iA-1; Fri, 05 Jun 2020 05:48:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 256FE1940921; Fri, 5 Jun 2020 09:48:33 +0000 (UTC) Received: from localhost (ovpn-114-214.ams2.redhat.com [10.36.114.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35B5E5D9D7; Fri, 5 Jun 2020 09:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591350516; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PAclCbkK965kzoir3NvjWZkVoHfN2nNhuLsOqTw6Ncc=; b=LD3KxuzLT20/kojC4dePYhfNAGnW3biU4sUOI9jqfDxCHRsAdMETMhFzW6NYbXPfyyc7yX tNFMBjCuVmj10oAiedFjjN9Ipx/U2nxdmutrCkv6DId56tSFoJKlYhV6D9F8qxaerT295R 1TQPGXaFBCPCJJdsa4JfiEQNcx1Kt6U= X-MC-Unique: f6vMfDOrOO2yVomshhH3iA-1 From: Stefan Hajnoczi To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 03/11] fuzz: add datadir for oss-fuzz compatability Date: Fri, 5 Jun 2020 10:47:42 +0100 Message-Id: <20200605094750.149957-4-stefanha@redhat.com> In-Reply-To: <20200605094750.149957-1-stefanha@redhat.com> References: <20200605094750.149957-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=stefanha@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/05 03:07:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , Thomas Huth , qemu-block@nongnu.org, Darren Kenny , Laurent Vivier , Julia Suvorova , Max Reitz , Alexander Bulekov , Bandan Das , qemu-arm@nongnu.org, Stefan Hajnoczi , Keith Busch , Paolo Bonzini , Aarushi Mehta , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Alexander Bulekov This allows us to keep pc-bios in executable_dir/pc-bios, rather than executable_dir/../pc-bios, which is incompatible with oss-fuzz' file structure. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny Message-id: 20200512030133.29896-2-alxndr@bu.edu Signed-off-by: Stefan Hajnoczi --- include/sysemu/sysemu.h | 2 ++ softmmu/vl.c | 2 +- tests/qtest/fuzz/fuzz.c | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 26c0c802d1..3efccdba7e 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -15,6 +15,8 @@ extern const char *qemu_name; extern QemuUUID qemu_uuid; extern bool qemu_uuid_set; =20 +void qemu_add_data_dir(const char *path); + void qemu_add_exit_notifier(Notifier *notify); void qemu_remove_exit_notifier(Notifier *notify); =20 diff --git a/softmmu/vl.c b/softmmu/vl.c index ae5451bc23..05d1a4cb6b 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1993,7 +1993,7 @@ char *qemu_find_file(int type, const char *name) return NULL; } =20 -static void qemu_add_data_dir(const char *path) +void qemu_add_data_dir(const char *path) { int i; =20 diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index f5c923852e..33365c3782 100644 --- a/tests/qtest/fuzz/fuzz.c +++ b/tests/qtest/fuzz/fuzz.c @@ -137,6 +137,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char = ***envp) { =20 char *target_name; + char *dir; =20 /* Initialize qgraph and modules */ qos_graph_init(); @@ -147,6 +148,20 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char= ***envp) target_name =3D strstr(**argv, "-target-"); if (target_name) { /* The binary name specifies the target */ target_name +=3D strlen("-target-"); + /* + * With oss-fuzz, the executable is kept in the root of a director= y (we + * cannot assume the path). All data (including bios binaries) mus= t be + * in the same dir, or a subdir. Thus, we cannot place the pc-bios= so + * that it would be in exec_dir/../pc-bios. + * As a workaround, oss-fuzz allows us to use argv[0] to get the + * location of the executable. Using this we add exec_dir/pc-bios = to + * the datadirs. + */ + dir =3D g_build_filename(g_path_get_dirname(**argv), "pc-bios", NU= LL); + if (g_file_test(dir, G_FILE_TEST_IS_DIR)) { + qemu_add_data_dir(dir); + } + g_free(dir); } else if (*argc > 1) { /* The target is specified as an argument */ target_name =3D (*argv)[1]; if (!strstr(target_name, "--fuzz-target=3D")) { --=20 2.25.4