summaryrefslogtreecommitdiff
path: root/gnu/packages/debug.scm
diff options
context:
space:
mode:
authorEric Bavier <bavier@member.fsf.org>2015-08-16 06:07:28 -0500
committerEric Bavier <bavier@member.fsf.org>2015-08-16 18:06:25 -0500
commit9b459fc7e180582a51c5625fc1bcfcd208013669 (patch)
tree0e42f4a160d92b30977130bfc139372c55d08785 /gnu/packages/debug.scm
parent20c263b00fc89355f423e64c7dd591c3ec438ef2 (diff)
gnu: Add American fuzzy lop.
* gnu/packages/debug.scm (american-fuzzy-lop): New variable.
Diffstat (limited to 'gnu/packages/debug.scm')
-rw-r--r--gnu/packages/debug.scm101
1 files changed, 100 insertions, 1 deletions
diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
index ba80711f01f..b0988326818 100644
--- a/gnu/packages/debug.scm
+++ b/gnu/packages/debug.scm
@@ -27,7 +27,10 @@
27 #:use-module (gnu packages indent) 27 #:use-module (gnu packages indent)
28 #:use-module (gnu packages llvm) 28 #:use-module (gnu packages llvm)
29 #:use-module (gnu packages perl) 29 #:use-module (gnu packages perl)
30 #:use-module (gnu packages pretty-print)) 30 #:use-module (gnu packages pretty-print)
31 #:use-module (gnu packages qemu)
32 #:use-module (ice-9 match)
33 #:use-module (srfi srfi-1))
31 34
32(define-public delta 35(define-public delta
33 (package 36 (package
@@ -137,3 +140,99 @@ produces a much smaller C/C++ program that has the same property. It is
137intended for use by people who discover and report bugs in compilers and other 140intended for use by people who discover and report bugs in compilers and other
138tools that process C/C++ code.") 141tools that process C/C++ code.")
139 (license ncsa))) 142 (license ncsa)))
143
144(define-public american-fuzzy-lop
145 (let ((machine (match (or (%current-target-system)
146 (%current-system))
147 ("x86_64-linux" "x86_64")
148 ("i686-linux" "i386")
149 ;; Prevent errors when querying this package on unsupported
150 ;; platforms, e.g. when running "guix package --search="
151 (_ "UNSUPPORTED"))))
152 (package
153 (name "american-fuzzy-lop")
154 (version "1.86b") ;It seems all releases have the 'b' suffix
155 (source
156 (origin
157 (method url-fetch)
158 (uri (string-append "http://lcamtuf.coredump.cx/afl/releases/"
159 "afl-" version ".tgz"))
160 (sha256
161 (base32
162 "1by9ncf6lgcyibzqwyla34jv64sd66mn8zhgjz2pcgsds51qwn0r"))))
163 (build-system gnu-build-system)
164 (inputs
165 `(("custom-qemu"
166 ;; The afl-qemu tool builds qemu 2.3.0 with a few patches applied.
167 ,(package (inherit qemu-headless)
168 (name "afl-qemu")
169 (inputs
170 `(("afl-src" ,source)
171 ,@(package-inputs qemu-headless)))
172 ;; afl only supports using a single afl-qemu-trace executable, so
173 ;; we only build qemu for the native target.
174 (arguments
175 `(#:configure-flags
176 (list (string-append "--target-list=" ,machine "-linux-user"))
177 #:modules ((srfi srfi-1)
178 ,@%gnu-build-system-modules)
179 ,@(substitute-keyword-arguments (package-arguments qemu-headless)
180 ((#:phases qemu-phases)
181 `(modify-phases ,qemu-phases
182 (add-after
183 'unpack 'apply-afl-patches
184 (lambda* (#:key inputs #:allow-other-keys)
185 (let* ((afl-dir (string-append "afl-" ,version))
186 (patch-dir
187 (string-append afl-dir
188 "/qemu_mode/patches")))
189 (unless (zero?
190 (system* "tar" "xf"
191 (assoc-ref inputs "afl-src")))
192 (error "tar failed to unpack afl-src"))
193 (copy-file (string-append patch-dir
194 "/afl-qemu-cpu-inl.h")
195 "./afl-qemu-cpu-inl.h")
196 (copy-file (string-append afl-dir "/config.h")
197 "./afl-config.h")
198 (copy-file (string-append afl-dir "/types.h")
199 "./types.h")
200 (substitute* "afl-qemu-cpu-inl.h"
201 (("\\.\\./\\.\\./config.h") "afl-config.h"))
202 (substitute* (string-append patch-dir
203 "/cpu-exec.diff")
204 (("\\.\\./patches/") ""))
205 (every (lambda (patch-file)
206 (zero? (system* "patch" "--force" "-p1"
207 "--input" patch-file)))
208 (find-files patch-dir
209 "\\.diff$"))))))))))))))
210 (arguments
211 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
212 "CC=gcc")
213 #:phases (modify-phases %standard-phases
214 (delete 'configure)
215 (add-after
216 ;; TODO: Build and install the afl-llvm tool.
217 'install 'install-qemu
218 (lambda* (#:key inputs outputs #:allow-other-keys)
219 (let ((qemu (assoc-ref inputs "custom-qemu"))
220 (out (assoc-ref outputs "out")))
221 (copy-file (string-append qemu "/bin/qemu-" ,machine)
222 (string-append out "/bin/afl-qemu-trace"))
223 #t)))
224 (delete 'check))))
225 (supported-systems (fold delete
226 %supported-systems
227 '("armhf-linux" "mips64el-linux")))
228 (home-page "http://lcamtuf.coredump.cx/afl")
229 (synopsis "Security-oriented fuzzer")
230 (description
231 "American fuzzy lop is a security-oriented fuzzer that employs a novel
232type of compile-time instrumentation and genetic algorithms to automatically
233discover clean, interesting test cases that trigger new internal states in the
234targeted binary. This substantially improves the functional coverage for the
235fuzzed code. The compact synthesized corpora produced by the tool are also
236useful for seeding other, more labor- or resource-intensive testing regimes
237down the road.")
238 (license asl2.0))))