From nobody Thu Dec 18 17:53:32 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=1588605404; cv=none; d=zohomail.com; s=zohoarc; b=AXDxgYmFZGptplnBMF3/rfhBRgOdVzKATWWOX+KeKHfW3tHe1VJFKbcpxvwSCNRcEXNl+QpP7QpPFOvNQkKEGUtrZLX5FWmNg1SUPSgOynCg0FeQLI+wIArw0i0jz3bCAnhXrOF6Yp3RnxrB6s7QG6PFCvqYcbiXEdYhoALf90Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588605404; 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=6izAc39XclI6yWRGdmTS6QgDssVoShYy45qY4EU02x4=; b=nXHnJj1UIRdUuo6Xx9UdIhsymX3t9ZHmZk82QJJfqmcvDTh4sGhoBk66uIRGDqnhFBp0wV6lgAc8sjVwc1BLsYtGvQLDoy8uM11xV60rM84YZqBHwXFvasDvXRIyhHh/C+jg0cTXz2HD9/4tAA0vCgaYUni/2ytGt1xl2fj/oSc= 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 1588605404817683.3750844715344; Mon, 4 May 2020 08:16:44 -0700 (PDT) Received: from localhost ([::1]:50614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVcpn-0004jI-05 for importer@patchew.org; Mon, 04 May 2020 11:16:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVcoI-0002WS-GG for qemu-devel@nongnu.org; Mon, 04 May 2020 11:15:10 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:41942 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 1jVcoH-0007kW-Jx for qemu-devel@nongnu.org; Mon, 04 May 2020 11:15:10 -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-37-rPwD-vntPxO3yPxlUyaeBA-1; Mon, 04 May 2020 11:15:03 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49F6218FF665; Mon, 4 May 2020 15:15:02 +0000 (UTC) Received: from localhost (ovpn-113-75.ams2.redhat.com [10.36.113.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id D05C663F81; Mon, 4 May 2020 15:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588605308; 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=6izAc39XclI6yWRGdmTS6QgDssVoShYy45qY4EU02x4=; b=bZnBDHsz10KltBVQ+TVa59o9ozTyfOiFHgDUrR/L5KzwY+6lDBraX1CTaipdZeM48NbK4c mNag8uK91QuZhQcIbHBxeFbfsnzbzHVNQAWr/1whq8Y3FRWspY6/DpmKTIEjhlnmqscp+0 eBgLly8bklflrwh/Hc52bwNqFqlZG1g= X-MC-Unique: rPwD-vntPxO3yPxlUyaeBA-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PULL v2 1/4] fuzz: select fuzz target using executable name Date: Mon, 4 May 2020 16:14:35 +0100 Message-Id: <20200504151438.362702-2-stefanha@redhat.com> In-Reply-To: <20200504151438.362702-1-stefanha@redhat.com> References: <20200504151438.362702-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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/05/04 05:09:11 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_H2=-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: Kevin Wolf , Laurent Vivier , Thomas Huth , Alex Williamson , qemu-block@nongnu.org, Juan Quintela , Peter Maydell , Markus Armbruster , Yuval Shaia , Peter Lieven , "Dr. David Alan Gilbert" , Max Reitz , Alexander Bulekov , Bandan Das , Gerd Hoffmann , Ronnie Sahlberg , Paolo Bonzini , Stefan Hajnoczi , Darren Kenny 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 The fuzzers are built into a binary (e.g. qemu-fuzz-i386). To select the device to fuzz/fuzz target, we usually use the --fuzz-target=3D argument. This commit allows the fuzz-target to be specified using the name of the executable. If the executable name ends with -target-FUZZ_TARGET, then we select the fuzz target based on this name, rather than the --fuzz-target argument. This is useful for systems such as oss-fuzz where we don't have control of the arguments passed to the fuzzer. [Fixed incorrect indentation. --Stefan] Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny Message-id: 20200421182230.6313-1-alxndr@bu.edu Signed-off-by: Stefan Hajnoczi --- tests/qtest/fuzz/fuzz.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index 0d78ac8d36..f5c923852e 100644 --- a/tests/qtest/fuzz/fuzz.c +++ b/tests/qtest/fuzz/fuzz.c @@ -91,6 +91,7 @@ static void usage(char *path) printf(" * %s : %s\n", tmp->target->name, tmp->target->description); } + printf("Alternatively, add -target-FUZZ_TARGET to the executable name\= n"); exit(0); } =20 @@ -143,18 +144,20 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, cha= r ***envp) module_call_init(MODULE_INIT_QOM); module_call_init(MODULE_INIT_LIBQOS); =20 - if (*argc <=3D 1) { + target_name =3D strstr(**argv, "-target-"); + if (target_name) { /* The binary name specifies the target */ + target_name +=3D strlen("-target-"); + } else if (*argc > 1) { /* The target is specified as an argument */ + target_name =3D (*argv)[1]; + if (!strstr(target_name, "--fuzz-target=3D")) { + usage(**argv); + } + target_name +=3D strlen("--fuzz-target=3D"); + } else { usage(**argv); } =20 /* Identify the fuzz target */ - target_name =3D (*argv)[1]; - if (!strstr(target_name, "--fuzz-target=3D")) { - usage(**argv); - } - - target_name +=3D strlen("--fuzz-target=3D"); - fuzz_target =3D fuzz_get_target(target_name); if (!fuzz_target) { usage(**argv); --=20 2.25.3