unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 1/2] gnu: qemu: Honor #:configure-flags argument.
@ 2015-08-16 12:35 ericbavier
  2015-08-16 12:35 ` [PATCH 2/2] gnu: Add American fuzzy lop ericbavier
  2015-08-16 18:56 ` [PATCH 1/2] gnu: qemu: Honor #:configure-flags argument Mark H Weaver
  0 siblings, 2 replies; 5+ messages in thread
From: ericbavier @ 2015-08-16 12:35 UTC (permalink / raw)
  To: guix-devel; +Cc: Eric Bavier

From: Eric Bavier <bavier@member.fsf.org>

* gnu/packages/qemu.scm (qemu-headless)[arguments]: Honor #:configure-flags
  arguments for configure phase.
---
 gnu/packages/qemu.scm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/qemu.scm b/gnu/packages/qemu.scm
index af39427..6979655 100644
--- a/gnu/packages/qemu.scm
+++ b/gnu/packages/qemu.scm
@@ -74,7 +74,8 @@
     (arguments
      '(#:phases (alist-replace
                  'configure
-                 (lambda* (#:key inputs outputs #:allow-other-keys)
+                 (lambda* (#:key inputs outputs (configure-flags '())
+                           #:allow-other-keys)
                    ;; The `configure' script doesn't understand some of the
                    ;; GNU options.  Thus, add a new phase that's compatible.
                    (let ((out (assoc-ref outputs "out")))
@@ -87,11 +88,13 @@
                      ;; The binaries need to be linked against -lrt.
                      (setenv "LDFLAGS" "-lrt")
                      (zero?
-                      (system* "./configure"
-                               (string-append "--cc=" (which "gcc"))
+                      (apply system*
+                             `("./configure"
+                               ,(string-append "--cc=" (which "gcc"))
                                "--disable-debug-info" ; save build space
                                "--enable-virtfs"      ; just to be sure
-                               (string-append "--prefix=" out)))))
+                               ,(string-append "--prefix=" out)
+                               ,@configure-flags)))))
                  (alist-cons-after
                   'install 'install-info
                   (lambda* (#:key inputs outputs #:allow-other-keys)
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] gnu: Add American fuzzy lop.
  2015-08-16 12:35 [PATCH 1/2] gnu: qemu: Honor #:configure-flags argument ericbavier
@ 2015-08-16 12:35 ` ericbavier
  2015-08-16 23:22   ` Mark H Weaver
  2015-08-16 18:56 ` [PATCH 1/2] gnu: qemu: Honor #:configure-flags argument Mark H Weaver
  1 sibling, 1 reply; 5+ messages in thread
From: ericbavier @ 2015-08-16 12:35 UTC (permalink / raw)
  To: guix-devel; +Cc: Eric Bavier

From: Eric Bavier <bavier@member.fsf.org>

* gnu/packages/debug.scm (american-fuzzy-lop): New variable.
---
 gnu/packages/debug.scm | 96 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 95 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
index ba80711..dba3091 100644
--- a/gnu/packages/debug.scm
+++ b/gnu/packages/debug.scm
@@ -27,7 +27,10 @@
   #:use-module (gnu packages indent)
   #:use-module (gnu packages llvm)
   #:use-module (gnu packages perl)
-  #:use-module (gnu packages pretty-print))
+  #:use-module (gnu packages pretty-print)
+  #:use-module (gnu packages qemu)
+  #:use-module (ice-9 match)
+  #:use-module (srfi srfi-1))
 
 (define-public delta
   (package
@@ -137,3 +140,94 @@ produces a much smaller C/C++ program that has the same property.  It is
 intended for use by people who discover and report bugs in compilers and other
 tools that process C/C++ code.")
     (license ncsa)))
+
+(define-public american-fuzzy-lop
+  (let ((machine (match (or (%current-target-system)
+                            (%current-system))
+                   ("x86_64-linux"   "x86_64")
+                   ("i686-linux"     "i386")
+                   ;; Prevent errors when querying this package on unsupported
+                   ;; platforms, e.g. when running "guix package --search="
+                   (_                "UNSUPPORTED"))))
+    (package
+      (name "american-fuzzy-lop")
+      (version "1.86b")             ;It seems all releases have the 'b' suffix
+      (source
+       (origin
+         (method url-fetch)
+         (uri (string-append "http://lcamtuf.coredump.cx/afl/releases/"
+                             "afl-" version ".tgz"))
+         (sha256
+          (base32
+           "1by9ncf6lgcyibzqwyla34jv64sd66mn8zhgjz2pcgsds51qwn0r"))))
+      (build-system gnu-build-system)
+      (inputs
+       `(("custom-qemu"
+          ;; The afl-qemu tool builds qemu 2.3.0 with a few patches applied.
+          ,(package (inherit qemu-headless)
+             (name "afl-qemu")
+             (inputs
+              `(("afl-src" ,source)
+                ,@(package-inputs qemu-headless)))
+             ;; afl only supports using a single afl-qemu-trace executable, so
+             ;; we only build qemu for the native target.
+             (arguments
+              `(#:configure-flags
+                (list (string-append "--target-list=" ,machine "-linux-user"))
+                ,@(substitute-keyword-arguments (package-arguments qemu-headless)
+                    ((#:phases qemu-phases)
+                     `(modify-phases ,qemu-phases
+                        (add-after
+                         'unpack 'apply-afl-patches
+                         (lambda* (#:key inputs #:allow-other-keys)
+                           (let* ((afl-dir (string-append "afl-" ,version))
+                                  (patch-dir
+                                   (string-append afl-dir
+                                                  "/qemu_mode/patches")))
+                             (system* "tar" "xf" (assoc-ref inputs "afl-src"))
+                             (copy-file (string-append patch-dir
+                                                       "/afl-qemu-cpu-inl.h")
+                                        "./afl-qemu-cpu-inl.h")
+                             (copy-file (string-append afl-dir "/config.h")
+                                        "./afl-config.h")
+                             (copy-file (string-append afl-dir "/types.h")
+                                        "./types.h")
+                             (substitute* "afl-qemu-cpu-inl.h"
+                               (("\\.\\./\\.\\./config.h") "afl-config.h"))
+                             (substitute* (string-append patch-dir
+                                                         "/cpu-exec.diff")
+                               (("\\.\\./patches/") ""))
+                             (for-each (lambda (patch-file)
+                                         (system* "patch" "--force" "-p1"
+                                                  "--input" patch-file))
+                                       (find-files patch-dir
+                                                   ".*\\.diff"))))))))))))))
+      (arguments
+       `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
+                            "CC=gcc")
+         #:phases (modify-phases %standard-phases
+                    (delete 'configure)
+                    (add-after
+                     ;; TODO: Build and install th afl-llvm tool.
+                     'install 'install-qemu
+                     (lambda* (#:key inputs outputs #:allow-other-keys)
+                       (let ((qemu (assoc-ref inputs "custom-qemu"))
+                             (out  (assoc-ref %outputs "out")))
+                         (copy-file (string-append qemu "/bin/qemu-" ,machine)
+                                    (string-append out "/bin/afl-qemu-trace"))
+                         #t)))
+                    (delete 'check))))
+      (supported-systems (fold delete
+                               %supported-systems
+                               '("armhf-linux" "mips64el-linux")))
+      (home-page "http://lcamtuf.coredump.cx/afl")
+      (synopsis "Security-oriented fuzzer")
+      (description
+       "American fuzzy lop is a security-oriented fuzzer that employs a novel
+type of compile-time instrumentation and genetic algorithms to automatically
+discover clean, interesting test cases that trigger new internal states in the
+targeted binary.  This substantially improves the functional coverage for the
+fuzzed code.  The compact synthesized corpora produced by the tool are also
+useful for seeding other, more labor- or resource-intensive testing regimes
+down the road.")
+      (license asl2.0))))
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] gnu: qemu: Honor #:configure-flags argument.
  2015-08-16 12:35 [PATCH 1/2] gnu: qemu: Honor #:configure-flags argument ericbavier
  2015-08-16 12:35 ` [PATCH 2/2] gnu: Add American fuzzy lop ericbavier
@ 2015-08-16 18:56 ` Mark H Weaver
  1 sibling, 0 replies; 5+ messages in thread
From: Mark H Weaver @ 2015-08-16 18:56 UTC (permalink / raw)
  To: ericbavier; +Cc: guix-devel, Eric Bavier

ericbavier@openmailbox.org writes:

> From: Eric Bavier <bavier@member.fsf.org>
>
> * gnu/packages/qemu.scm (qemu-headless)[arguments]: Honor #:configure-flags
>   arguments for configure phase.

Okay, please push.

    Thanks,
      Mark

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] gnu: Add American fuzzy lop.
  2015-08-16 23:22   ` Mark H Weaver
@ 2015-08-16 23:11     ` Eric Bavier
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Bavier @ 2015-08-16 23:11 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: guix-devel

On Sun, 16 Aug 2015 19:22:51 -0400
Mark H Weaver <mhw@netris.org> wrote:

> ericbavier@openmailbox.org writes:
> 
> > From: Eric Bavier <bavier@member.fsf.org>
> >
> > * gnu/packages/debug.scm (american-fuzzy-lop): New variable.
> > ---
> >  gnu/packages/debug.scm | 96
> > +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed,
> > 95 insertions(+), 1 deletion(-)
> >
> > diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
> > index ba80711..dba3091 100644
> > --- a/gnu/packages/debug.scm
> > +++ b/gnu/packages/debug.scm
> > @@ -27,7 +27,10 @@
> >    #:use-module (gnu packages indent)
> >    #:use-module (gnu packages llvm)
> >    #:use-module (gnu packages perl)
> > -  #:use-module (gnu packages pretty-print))
> > +  #:use-module (gnu packages pretty-print)
> > +  #:use-module (gnu packages qemu)
> > +  #:use-module (ice-9 match)
> > +  #:use-module (srfi srfi-1))
> >  
> >  (define-public delta
> >    (package
> > @@ -137,3 +140,94 @@ produces a much smaller C/C++ program that has
> > the same property.  It is intended for use by people who discover
> > and report bugs in compilers and other tools that process C/C++
> > code.") (license ncsa)))
> > +
> > +(define-public american-fuzzy-lop
> > +  (let ((machine (match (or (%current-target-system)
> > +                            (%current-system))
> > +                   ("x86_64-linux"   "x86_64")
> > +                   ("i686-linux"     "i386")
> > +                   ;; Prevent errors when querying this package on
> > unsupported
> > +                   ;; platforms, e.g. when running "guix package
> > --search="
> > +                   (_                "UNSUPPORTED"))))
> > +    (package
> > +      (name "american-fuzzy-lop")
> > +      (version "1.86b")             ;It seems all releases have
> > the 'b' suffix
> > +      (source
> > +       (origin
> > +         (method url-fetch)
> > +         (uri (string-append
> > "http://lcamtuf.coredump.cx/afl/releases/"
> > +                             "afl-" version ".tgz"))
> > +         (sha256
> > +          (base32
> > +
> > "1by9ncf6lgcyibzqwyla34jv64sd66mn8zhgjz2pcgsds51qwn0r"))))
> > +      (build-system gnu-build-system)
> > +      (inputs
> > +       `(("custom-qemu"
> > +          ;; The afl-qemu tool builds qemu 2.3.0 with a few
> > patches applied.
> > +          ,(package (inherit qemu-headless)
> > +             (name "afl-qemu")
> > +             (inputs
> > +              `(("afl-src" ,source)
> > +                ,@(package-inputs qemu-headless)))
> > +             ;; afl only supports using a single afl-qemu-trace
> > executable, so
> > +             ;; we only build qemu for the native target.
> > +             (arguments
> > +              `(#:configure-flags
> > +                (list (string-append "--target-list=" ,machine
> > "-linux-user"))
> > +                ,@(substitute-keyword-arguments (package-arguments
> > qemu-headless)
> > +                    ((#:phases qemu-phases)
> > +                     `(modify-phases ,qemu-phases
> > +                        (add-after
> > +                         'unpack 'apply-afl-patches
> > +                         (lambda* (#:key inputs #:allow-other-keys)
> > +                           (let* ((afl-dir (string-append
> > "afl-" ,version))
> > +                                  (patch-dir
> > +                                   (string-append afl-dir
> > +
> > "/qemu_mode/patches")))
> > +                             (system* "tar" "xf" (assoc-ref inputs
> > "afl-src"))
> 
> Please check for an error here, with something like:
> 
>   (unless (zero? (system* ...))
>     (error "tar failed to unpack afl-src"))
> 
> > +                             (copy-file (string-append patch-dir
> > +
> > "/afl-qemu-cpu-inl.h")
> > +                                        "./afl-qemu-cpu-inl.h")
> > +                             (copy-file (string-append afl-dir
> > "/config.h")
> > +                                        "./afl-config.h")
> > +                             (copy-file (string-append afl-dir
> > "/types.h")
> > +                                        "./types.h")
> > +                             (substitute* "afl-qemu-cpu-inl.h"
> > +                               (("\\.\\./\\.\\./config.h")
> > "afl-config.h"))
> > +                             (substitute* (string-append patch-dir
> > +
> > "/cpu-exec.diff")
> > +                               (("\\.\\./patches/") ""))
> > +                             (for-each (lambda (patch-file)
> > +                                         (system* "patch"
> > "--force" "-p1"
> > +                                                  "--input"
> > patch-file))
> 
> Likewise, if these patches fail to apply, the failures will be
> ignored. Please change 'for-each' to 'every', and wrap (zero? ...)
> around the 'system*' call.
> 
> > +                                       (find-files patch-dir
> > +
> > ".*\\.diff"))))))))))))))
> 
> "\\.diff$"
> 
> > +      (arguments
> > +       `(#:make-flags (list (string-append "PREFIX=" (assoc-ref
> > %outputs "out"))
> > +                            "CC=gcc")
> > +         #:phases (modify-phases %standard-phases
> > +                    (delete 'configure)
> > +                    (add-after
> > +                     ;; TODO: Build and install th afl-llvm tool.
> 
> s/th/the/
> 
> > +                     'install 'install-qemu
> > +                     (lambda* (#:key inputs outputs
> > #:allow-other-keys)
> > +                       (let ((qemu (assoc-ref inputs
> > "custom-qemu"))
> > +                             (out  (assoc-ref %outputs "out")))
> 
> s/%outputs/outputs/
> 
> > +                         (copy-file (string-append qemu
> > "/bin/qemu-" ,machine)
> > +                                    (string-append out
> > "/bin/afl-qemu-trace"))
> > +                         #t)))
> > +                    (delete 'check))))
> > +      (supported-systems (fold delete
> > +                               %supported-systems
> > +                               '("armhf-linux" "mips64el-linux")))
> > +      (home-page "http://lcamtuf.coredump.cx/afl")
> > +      (synopsis "Security-oriented fuzzer")
> > +      (description
> > +       "American fuzzy lop is a security-oriented fuzzer that
> > employs a novel +type of compile-time instrumentation and genetic
> > algorithms to automatically +discover clean, interesting test cases
> > that trigger new internal states in the +targeted binary.  This
> > substantially improves the functional coverage for the +fuzzed
> > code.  The compact synthesized corpora produced by the tool are
> > also +useful for seeding other, more labor- or resource-intensive
> > testing regimes +down the road.")
> > +      (license asl2.0))))
> 
> Otherwise it looks good to me.

Thank you for the review.  Changes applied and pushed.

`~Eric

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] gnu: Add American fuzzy lop.
  2015-08-16 12:35 ` [PATCH 2/2] gnu: Add American fuzzy lop ericbavier
@ 2015-08-16 23:22   ` Mark H Weaver
  2015-08-16 23:11     ` Eric Bavier
  0 siblings, 1 reply; 5+ messages in thread
From: Mark H Weaver @ 2015-08-16 23:22 UTC (permalink / raw)
  To: ericbavier; +Cc: guix-devel, Eric Bavier

ericbavier@openmailbox.org writes:

> From: Eric Bavier <bavier@member.fsf.org>
>
> * gnu/packages/debug.scm (american-fuzzy-lop): New variable.
> ---
>  gnu/packages/debug.scm | 96 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 95 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
> index ba80711..dba3091 100644
> --- a/gnu/packages/debug.scm
> +++ b/gnu/packages/debug.scm
> @@ -27,7 +27,10 @@
>    #:use-module (gnu packages indent)
>    #:use-module (gnu packages llvm)
>    #:use-module (gnu packages perl)
> -  #:use-module (gnu packages pretty-print))
> +  #:use-module (gnu packages pretty-print)
> +  #:use-module (gnu packages qemu)
> +  #:use-module (ice-9 match)
> +  #:use-module (srfi srfi-1))
>  
>  (define-public delta
>    (package
> @@ -137,3 +140,94 @@ produces a much smaller C/C++ program that has the same property.  It is
>  intended for use by people who discover and report bugs in compilers and other
>  tools that process C/C++ code.")
>      (license ncsa)))
> +
> +(define-public american-fuzzy-lop
> +  (let ((machine (match (or (%current-target-system)
> +                            (%current-system))
> +                   ("x86_64-linux"   "x86_64")
> +                   ("i686-linux"     "i386")
> +                   ;; Prevent errors when querying this package on unsupported
> +                   ;; platforms, e.g. when running "guix package --search="
> +                   (_                "UNSUPPORTED"))))
> +    (package
> +      (name "american-fuzzy-lop")
> +      (version "1.86b")             ;It seems all releases have the 'b' suffix
> +      (source
> +       (origin
> +         (method url-fetch)
> +         (uri (string-append "http://lcamtuf.coredump.cx/afl/releases/"
> +                             "afl-" version ".tgz"))
> +         (sha256
> +          (base32
> +           "1by9ncf6lgcyibzqwyla34jv64sd66mn8zhgjz2pcgsds51qwn0r"))))
> +      (build-system gnu-build-system)
> +      (inputs
> +       `(("custom-qemu"
> +          ;; The afl-qemu tool builds qemu 2.3.0 with a few patches applied.
> +          ,(package (inherit qemu-headless)
> +             (name "afl-qemu")
> +             (inputs
> +              `(("afl-src" ,source)
> +                ,@(package-inputs qemu-headless)))
> +             ;; afl only supports using a single afl-qemu-trace executable, so
> +             ;; we only build qemu for the native target.
> +             (arguments
> +              `(#:configure-flags
> +                (list (string-append "--target-list=" ,machine "-linux-user"))
> +                ,@(substitute-keyword-arguments (package-arguments qemu-headless)
> +                    ((#:phases qemu-phases)
> +                     `(modify-phases ,qemu-phases
> +                        (add-after
> +                         'unpack 'apply-afl-patches
> +                         (lambda* (#:key inputs #:allow-other-keys)
> +                           (let* ((afl-dir (string-append "afl-" ,version))
> +                                  (patch-dir
> +                                   (string-append afl-dir
> +                                                  "/qemu_mode/patches")))
> +                             (system* "tar" "xf" (assoc-ref inputs "afl-src"))

Please check for an error here, with something like:

  (unless (zero? (system* ...))
    (error "tar failed to unpack afl-src"))

> +                             (copy-file (string-append patch-dir
> +                                                       "/afl-qemu-cpu-inl.h")
> +                                        "./afl-qemu-cpu-inl.h")
> +                             (copy-file (string-append afl-dir "/config.h")
> +                                        "./afl-config.h")
> +                             (copy-file (string-append afl-dir "/types.h")
> +                                        "./types.h")
> +                             (substitute* "afl-qemu-cpu-inl.h"
> +                               (("\\.\\./\\.\\./config.h") "afl-config.h"))
> +                             (substitute* (string-append patch-dir
> +                                                         "/cpu-exec.diff")
> +                               (("\\.\\./patches/") ""))
> +                             (for-each (lambda (patch-file)
> +                                         (system* "patch" "--force" "-p1"
> +                                                  "--input" patch-file))

Likewise, if these patches fail to apply, the failures will be ignored.
Please change 'for-each' to 'every', and wrap (zero? ...) around the
'system*' call.

> +                                       (find-files patch-dir
> +                                                   ".*\\.diff"))))))))))))))

"\\.diff$"

> +      (arguments
> +       `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
> +                            "CC=gcc")
> +         #:phases (modify-phases %standard-phases
> +                    (delete 'configure)
> +                    (add-after
> +                     ;; TODO: Build and install th afl-llvm tool.

s/th/the/

> +                     'install 'install-qemu
> +                     (lambda* (#:key inputs outputs #:allow-other-keys)
> +                       (let ((qemu (assoc-ref inputs "custom-qemu"))
> +                             (out  (assoc-ref %outputs "out")))

s/%outputs/outputs/

> +                         (copy-file (string-append qemu "/bin/qemu-" ,machine)
> +                                    (string-append out "/bin/afl-qemu-trace"))
> +                         #t)))
> +                    (delete 'check))))
> +      (supported-systems (fold delete
> +                               %supported-systems
> +                               '("armhf-linux" "mips64el-linux")))
> +      (home-page "http://lcamtuf.coredump.cx/afl")
> +      (synopsis "Security-oriented fuzzer")
> +      (description
> +       "American fuzzy lop is a security-oriented fuzzer that employs a novel
> +type of compile-time instrumentation and genetic algorithms to automatically
> +discover clean, interesting test cases that trigger new internal states in the
> +targeted binary.  This substantially improves the functional coverage for the
> +fuzzed code.  The compact synthesized corpora produced by the tool are also
> +useful for seeding other, more labor- or resource-intensive testing regimes
> +down the road.")
> +      (license asl2.0))))

Otherwise it looks good to me.

    Thanks!
      Mark

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-17  4:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-16 12:35 [PATCH 1/2] gnu: qemu: Honor #:configure-flags argument ericbavier
2015-08-16 12:35 ` [PATCH 2/2] gnu: Add American fuzzy lop ericbavier
2015-08-16 23:22   ` Mark H Weaver
2015-08-16 23:11     ` Eric Bavier
2015-08-16 18:56 ` [PATCH 1/2] gnu: qemu: Honor #:configure-flags argument Mark H Weaver

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).