Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pgnU0-0007sc-8e for mharc-grub-devel@gnu.org; Mon, 27 Mar 2023 10:06:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pgnTt-0007oF-0j for grub-devel@gnu.org; Mon, 27 Mar 2023 10:05:53 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pgnTm-0002sq-Qh for grub-devel@gnu.org; Mon, 27 Mar 2023 10:05:52 -0400 Received: by mail-pl1-x630.google.com with SMTP id u10so8531558plz.7 for ; Mon, 27 Mar 2023 07:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; t=1679925938; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u8Kn9vIzvO5lMvIW/FOgVnbKJ/xV8JPQBC4ZFQuJx5s=; b=nPF+2UQPCW9m2OzCV1jk1pS9+irdzjErtyjEkWDSrN2QWKlU9SMaluKUClaOYIjPQY AmYkN/Ygmq1TuTIWUVLl7Oe4ZcrtS+sd+PO7a01+xmHT4/Wr8A6SWYl9TEDd2ymMHwRf b7rQM+O+xiHUBeuXnwAEH8DJrq0n7ZYqFE6Do= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679925938; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u8Kn9vIzvO5lMvIW/FOgVnbKJ/xV8JPQBC4ZFQuJx5s=; b=eYHvTmga5YAc/GxrVcbWSmwtWwd5n36s9/64svS0PwxMGzWP9p5yVIdOppL+OTzE/0 sfIC2b3BDNT0mgCwiVuH4LXvrbho7le/NYQhEIwX+zh0p/sHC8MQw+KuZA9XKj8VBIPi tRQzW4HbtpYm6lPfK7pavBZSNSQNJQELQFy6abVk6O4A3XUbA8oUl9SIurr8n/v8NPOi YBM9OuXLuLgg2Htho36ANg8Ln1zcMRNzIC/z+BDX2wuZRINzpSLFcF9EL0puC8lqcxVg vbROppolpbEEI1cc6wLZiioG/uFcPLHRSQgXGHOeYsOOuePrU8QrA+MJhqiVU3EXNqzm VkXw== X-Gm-Message-State: AAQBX9d3MeEAteddAus3Qy+xNt82khofTsGF6/kT/enWcMuiffyBmYPb qxgaWUhmFJbAq+DCM//dDkXRD1uSyASP2YPEG3U= X-Google-Smtp-Source: AKy350ZyEXGANonHX3QC5ClNAqga+viZlF40pqMhuRMrlt+dS5Mph94MCZKnsAQAEr+wU2AmeA/F0g== X-Received: by 2002:a17:903:1106:b0:1a2:58f1:5e1d with SMTP id n6-20020a170903110600b001a258f15e1dmr1093570plh.36.1679925938203; Mon, 27 Mar 2023 07:05:38 -0700 (PDT) Received: from linkitivity.lan (123-243-125-234.tpgi.com.au. [123.243.125.234]) by smtp.gmail.com with ESMTPSA id c11-20020a170902aa4b00b001a1fe42a141sm8493032plr.115.2023.03.27.07.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 07:05:37 -0700 (PDT) From: Daniel Axtens To: grub-devel@gnu.org Cc: Daniel Axtens Subject: [PATCH 6/6] docs: document fuzzer support Date: Tue, 28 Mar 2023 01:04:59 +1100 Message-Id: <20230327140459.601018-7-dja@axtens.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230327140459.601018-1-dja@axtens.net> References: <20230327140459.601018-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=dja@axtens.net; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Mar 2023 14:05:53 -0000 This is basic documentation. There are a few extra, super-hacky things we can do to get asan or afl++ going which are a bit too messy at the moment to commit to the docs. But, so as they are not lost to time, here's the invocations that currently work for me: libfuzzer + ASan: ./configure CC=clang --with-platform=emu --enable-fuzzers=yes; make clean ASAN_OPTIONS=detect_leaks=0 make CFLAGS='-fsanitize=address -Wl,--allow-multiple-definition' -j4 -k || \ echo "the compile is expected to fail eventually, but the fuzzers should still build" AFL++: ./configure CC=clang --with-platform=emu --enable-fuzzers=yes; make clean make CC=/path/to/afl-cc CFLAGS="-Wl,--allow-multiple-definition" -j4 -k || \ echo "the compile is expected to fail eventually, but the fuzzers should still build" AFL++ + ASan: ./configure CC=clang --with-platform=emu --enable-fuzzers=yes; make clean AFL_USE_ASAN=1 ASAN_OPTIONS=detect_leaks=0 make CC=/path/to/afl-cc CFLAGS="-Wl,--allow-multiple-definition" -j4 -k || \ echo "the compile is expected to fail eventually, but the fuzzers should still build" In these cases the compilation of grub-emu(-lite) will fail, but the fuzzers themselves will be built and can be run as desired. --- docs/grub-dev.texi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index 31eb99ea2994..11a92d04eda0 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -88,6 +88,7 @@ This edition documents version @value{VERSION}. * Graphical Menu Software Design:: * Verifiers framework:: * Lockdown framework:: +* Fuzzing the GRUB:: * Copying This Manual:: Copying This Manual * Index:: @end menu @@ -2165,6 +2166,25 @@ when the GRUB is in lockdown mode. @end itemize +@node Fuzzing the GRUB +@chapter Fuzzing the GRUB + +The GRUB has support for in-process fuzzing of various image format +parsers, based on libfuzzer. + +Fuzzers are compiled by default if the host compiler supports the +@code{-fsanitize=fuzzer} compile flag. Fuzzers can be explictly enabled with +@code{./configure --enable-fuzzers=yes}, such that configuration will not +succeed unless they can be built. Fuzzers are built as @code{grub-fuzz-XXX} +binaries in the top-level directory. + +These fuzzers build with clang out of the box. When built with clang they +can be run against a corpus as e.g. @code{./grub-fuzz-jpeg jpeg-corpus}. +Consult the LLVM libfuzzer documentation for more details and options. + +Building the fuzzers with other sanitizers (such as AddressSanitizer) or +with AFL++ can provide better results, but the process is not yet stable. + @node Copying This Manual @appendix Copying This Manual -- 2.25.1