FAQ
# New Ticket Created by Dan Collins
# Please include the string: [perl #128171]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=128171 >


Greetings Porters,

I have compiled bleadperl with the afl-gcc compiler using:

./Configure -Dusedevel -Dprefix='/usr/local/perl-afl' -Dcc='ccache afl-gcc' -Uuselongdouble -Duse64bitall -Doptimize=-g -Uversiononly -Uman1dir -Uman3dir -Dusequadmath -des
AFL_HARDEN=1 make && make test

And then fuzzed the resulting binary using:

AFL_NO_VAR_CHECK=1 afl-fuzz -i in -o out bin/perl @@

After reducing testcases using `afl-tmin` and performing additional minimization by hand, I have located the following testcase that triggers an assert fail in debugging builds of the perl interpreter. The testcase is the 6-character file:

/@0{0*->@/*0

On normal builds, this exits with the expected error. On debug builds, this returns an assert fail.

dcollins@nightshade64:~$ ./perldebug/miniperl -e '/@0{0*->@/*0'
miniperl: toke.c:1935: S_postderef: Assertion `strchr("*[{", next)' failed.
Aborted
dcollins@nightshade64:~$ ./perl/miniperl -e '/@0{0*->@/*0'
Number found where operator expected at -e line 1, near "*0"
         (Missing operator before 0?)
syntax error at -e line 1, near "*->"
Execution of -e aborted due to compilation errors.

Debugging tool output is below. A bisect was performed, but it appears that this bug has existed since the feature was initally committed (and is only appearing now because "use feature postderef" was a bit too much to expect a fuzzer to stumble on easily).


**GDB**

dcollins@nightshade64:~/perldebug$ gdb --args ./miniperl -e '/@0{0*->@/*0'
GNU gdb (GDB) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./miniperl...done.
(gdb) run
Starting program: /home/dcollins/perldebug/miniperl -e /@0\{0\*-\>@/\*0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
miniperl: toke.c:1935: S_postderef: Assertion `strchr("*[{", next)' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff6cf9478 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0 0x00007ffff6cf9478 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff6cfa8fa in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff6cf23a7 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007ffff6cf2452 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x000000000047c77f in S_postderef (funny=42, next=48 '0') at toke.c:1935
#5 0x000000000048f4e1 in Perl_yylex () at toke.c:5373
#6 0x00000000004b9f00 in Perl_yyparse (gramtype=258) at perly.c:332
#7 0x0000000000447469 in S_parse_body (env=0x0, xsinit=0x728923 <xs_init>) at perl.c:2365
#8 0x0000000000445f07 in perl_parse (my_perl=0xa80010, xsinit=0x728923 <xs_init>, argc=3, argv=0x7fffffffe628, env=0x0) at perl.c:1681
#9 0x0000000000728882 in main (argc=3, argv=0x7fffffffe628, env=0x7fffffffe648) at miniperlmain.c:120
(gdb) f 4
#4 0x000000000047c77f in S_postderef (funny=42, next=48 '0') at toke.c:1935
1935 assert(strchr("*[{", next));
(gdb) l
1930
1931 static int
1932 S_postderef(pTHX_ int const funny, char const next)
1933 {
1934 assert(funny == DOLSHARP || strchr("$@%&*", funny));
1935 assert(strchr("*[{", next));
1936 if (next == '*') {
1937 PL_expect = XOPERATOR;
1938 if (PL_lex_state == LEX_INTERPNORMAL && !PL_lex_brackets) {
1939 assert('@' == funny || '$' == funny || DOLSHARP == funny);
(gdb) info locals
__PRETTY_FUNCTION__ = "S_postderef"



**PERL -V**

dcollins@nightshade64:~/perl$ ./perl -Ilib -V
Summary of my perl5 (revision 5 version 25 subversion 1) configuration:
   Commit id: 8255316ac82c0fbd7ae49f2f9a217ce063d7bbfb
   Platform:
     osname=linux, osvers=4.5.0-2-amd64, archname=x86_64-linux-ld
     uname='linux nightshade64 4.5.0-2-amd64 #1 smp debian 4.5.3-2 (2016-05-08) x86_64 gnulinux '
     config_args='-Dusedevel -Dprefix=/usr/local/perl-afl -Dcc=ccache afl-gcc -Duselongdouble -Duse64bitall -Doptimize=-g -Uversiononly -Uman1dir -Uman3dir -des'
     hint=recommended, useposix=true, d_sigaction=define
     useithreads=undef, usemultiplicity=undef
     use64bitint=define, use64bitall=define, uselongdouble=define
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='ccache afl-gcc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
     optimize='-g',
     cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
     ccversion='', gccversion='6.1.0', gccosandvers=''
     intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
     ivtype='long', ivsize=8, nvtype='long double', nvsize=16, Off_t='off_t', lseeksize=8
     alignbytes=16, prototype=define
   Linker and Libraries:
     ld='ccache afl-gcc', ldflags =' -fstack-protector-strong -L/usr/local/lib'
     libpth=/usr/local/lib /usr/local/lib/gcc/x86_64-pc-linux-gnu/6.1.0/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
     libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
     perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
     libc=libc-2.22.so, so=so, useshrplib=false, libperl=libperl.a
     gnulibc_version='2.22'
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
     cccdlflags='-fPIC', lddlflags='-shared -g -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl):
   Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_COPY_ON_WRITE
                         PERL_DONT_CREATE_GVSV
                         PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP
                         PERL_OP_PARENT PERL_PRESERVE_IVUV PERL_USE_DEVEL
                         USE_64_BIT_ALL USE_64_BIT_INT USE_LARGE_FILES
                         USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                         USE_LOCALE_NUMERIC USE_LOCALE_TIME USE_LONG_DOUBLE
                         USE_PERLIO USE_PERL_ATOF
   Built under linux
   Compiled at May 16 2016 07:45:27
   @INC:
     lib
     /usr/local/perl-afl/lib/site_perl/5.25.1/x86_64-linux-ld
     /usr/local/perl-afl/lib/site_perl/5.25.1
     /usr/local/perl-afl/lib/5.25.1/x86_64-linux-ld
     /usr/local/perl-afl/lib/5.25.1
     /usr/local/perl-afl/lib/site_perl/5.24.0
     /usr/local/perl-afl/lib/site_perl
     .

Search Discussions

  • Father Chrysostomos via RT at May 18, 2016 at 3:30 am

    On Tue May 17 17:00:26 2016, dcollinsn@gmail.com wrote:
    Greetings Porters,

    I have compiled bleadperl with the afl-gcc compiler using:

    ./Configure -Dusedevel -Dprefix='/usr/local/perl-afl' -Dcc='ccache
    afl-gcc' -Uuselongdouble -Duse64bitall -Doptimize=-g -Uversiononly
    -Uman1dir -Uman3dir -Dusequadmath -des
    AFL_HARDEN=1 make && make test

    And then fuzzed the resulting binary using:

    AFL_NO_VAR_CHECK=1 afl-fuzz -i in -o out bin/perl @@

    After reducing testcases using `afl-tmin` and performing additional
    minimization by hand, I have located the following testcase that
    triggers an assert fail in debugging builds of the perl interpreter.
    The testcase is the 6-character file:

    /@0{0*->@/*0
    Thank you. This is fixed in d6744494.

    --

    Father Chrysostomos


    ---
    via perlbug: queue: perl5 status: new
    https://rt.perl.org/Ticket/Display.html?id=128171

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedMay 18, '16 at 12:00a
activeMay 18, '16 at 3:30a
posts2
users1
websiteperl.org

1 user in discussion

Father Chrysostomos via RT: 2 posts

People

Translate

site design / logo © 2022 Grokbase