Open florian-pe opened 1 year ago
Note that the payload line should be:
$str=~ m/^(.{1250})(?{ $_=$1; say $1; })/; # bug
(It appeared slightly different in the emailed original, but I assume the ticket has been edited to correct it.)
With my system perl (Ubuntu, 5.26.1) I do not see a problem at 1250 characters, but I do if I increase string length to 20000 and ask for 12500 characters.
Not sure if I'll have time to investigate this, but it sounds interesting.
==170770== Invalid read of size 8
==170770== at 0x483F7DF: memmove (vg_replace_strmem.c:1270)
==170770== by 0x524B9B: Perl_sv_setpvn (sv.c:4720)
==170770== by 0x496317: Perl_reg_numbered_buff_fetch (regcomp.c:7466)
==170770== by 0x4DA687: Perl_magic_get (mg.c:805)
==170770== by 0x4DF0FA: Perl_mg_get (mg.c:201)
==170770== by 0x522344: Perl_sv_2pv_flags (sv.c:2821)
==170770== by 0x59EF8F: Perl_do_print (doio.c:1305)
==170770== by 0x4FB83E: Perl_pp_print (pp_hot.c:838)
==170770== by 0x4CE2B8: Perl_runops_debug (dump.c:2427)
==170770== by 0x5AD2BD: S_regmatch (regexec.c:5332)
==170770== by 0x5AD2BD: S_regtry (regexec.c:3200)
==170770== by 0x5BCCD1: Perl_regexec_flags (regexec.c:2688)
==170770== by 0x4FDC8D: Perl_pp_match (pp_hot.c:1446)
==170770== Address 0x4c55328 is 24 bytes inside a block of size 2,026 free'd
==170770== at 0x48399AB: free (vg_replace_malloc.c:538)
==170770== by 0x5105B8: Perl_sv_setsv_flags (sv.c:4489)
==170770== by 0x4F8BF9: Perl_pp_sassign (pp_hot.c:224)
==170770== by 0x4CE2B8: Perl_runops_debug (dump.c:2427)
==170770== by 0x5AD2BD: S_regmatch (regexec.c:5332)
==170770== by 0x5AD2BD: S_regtry (regexec.c:3200)
==170770== by 0x5BCCD1: Perl_regexec_flags (regexec.c:2688)
==170770== by 0x4FDC8D: Perl_pp_match (pp_hot.c:1446)
==170770== by 0x4CE2B8: Perl_runops_debug (dump.c:2427)
==170770== by 0x44CB9A: S_run_body (perl.c:2456)
==170770== by 0x44CB9A: perl_run (perl.c:2372)
==170770== by 0x41F636: main (perlmain.c:114)
==170770== Block was alloc'd at
==170770== at 0x483877F: malloc (vg_replace_malloc.c:307)
==170770== by 0x4D0587: Perl_safesysmalloc (util.c:130)
==170770== by 0x51E37F: Perl_sv_grow (sv.c:1595)
==170770== by 0x51176A: Perl_sv_setsv_flags (sv.c:4525)
==170770== by 0x4F8BF9: Perl_pp_sassign (pp_hot.c:224)
==170770== by 0x4CE2B8: Perl_runops_debug (dump.c:2427)
==170770== by 0x44CB9A: S_run_body (perl.c:2456)
==170770== by 0x44CB9A: perl_run (perl.c:2372)
==170770== by 0x41F636: main (perlmain.c:114)
My theory: Inside {?{ ... })
blocks $_
is aliased to the string being matched, the assignment here ends up assigning to $str
, releasing the old PV, so $1
returns data from a freed buffer.
On Mon, 5 Dec 2022 at 01:23, Tony Cook @.***> wrote:
==170770== Invalid read of size 8 ==170770== at 0x483F7DF: memmove (vg_replace_strmem.c:1270) ==170770== by 0x524B9B: Perl_sv_setpvn (sv.c:4720) ==170770== by 0x496317: Perl_reg_numbered_buff_fetch (regcomp.c:7466) ==170770== by 0x4DA687: Perl_magic_get (mg.c:805) ==170770== by 0x4DF0FA: Perl_mg_get (mg.c:201) ==170770== by 0x522344: Perl_sv_2pv_flags (sv.c:2821) ==170770== by 0x59EF8F: Perl_do_print (doio.c:1305) ==170770== by 0x4FB83E: Perl_pp_print (pp_hot.c:838) ==170770== by 0x4CE2B8: Perl_runops_debug (dump.c:2427) ==170770== by 0x5AD2BD: S_regmatch (regexec.c:5332) ==170770== by 0x5AD2BD: S_regtry (regexec.c:3200) ==170770== by 0x5BCCD1: Perl_regexec_flags (regexec.c:2688) ==170770== by 0x4FDC8D: Perl_pp_match (pp_hot.c:1446) ==170770== Address 0x4c55328 is 24 bytes inside a block of size 2,026 free'd ==170770== at 0x48399AB: free (vg_replace_malloc.c:538) ==170770== by 0x5105B8: Perl_sv_setsv_flags (sv.c:4489) ==170770== by 0x4F8BF9: Perl_pp_sassign (pp_hot.c:224) ==170770== by 0x4CE2B8: Perl_runops_debug (dump.c:2427) ==170770== by 0x5AD2BD: S_regmatch (regexec.c:5332) ==170770== by 0x5AD2BD: S_regtry (regexec.c:3200) ==170770== by 0x5BCCD1: Perl_regexec_flags (regexec.c:2688) ==170770== by 0x4FDC8D: Perl_pp_match (pp_hot.c:1446) ==170770== by 0x4CE2B8: Perl_runops_debug (dump.c:2427) ==170770== by 0x44CB9A: S_run_body (perl.c:2456) ==170770== by 0x44CB9A: perl_run (perl.c:2372) ==170770== by 0x41F636: main (perlmain.c:114) ==170770== Block was alloc'd at ==170770== at 0x483877F: malloc (vg_replace_malloc.c:307) ==170770== by 0x4D0587: Perl_safesysmalloc (util.c:130) ==170770== by 0x51E37F: Perl_sv_grow (sv.c:1595) ==170770== by 0x51176A: Perl_sv_setsv_flags (sv.c:4525) ==170770== by 0x4F8BF9: Perl_pp_sassign (pp_hot.c:224) ==170770== by 0x4CE2B8: Perl_runops_debug (dump.c:2427) ==170770== by 0x44CB9A: S_run_body (perl.c:2456) ==170770== by 0x44CB9A: perl_run (perl.c:2372) ==170770== by 0x41F636: main (perlmain.c:114)
My theory: Inside {?{ ... }) blocks $_ is aliased to the string being matched, the assignment here ends up assigning to $str, releasing the old PV, so $1 returns data from a freed buffer.
Wow. My brain exploded when I saw this. I had never noticed this (mis)feature before. Assigning to $ like this violates many assumptions in the regex engine. I am a bit shocked this is the only breakage related to it, although I guess most people wouldn't do this. I cannot find code to defend against malicious modification of the matched strings contents during matching so I am a little surprised we can't make horrible things happen by setting $ to an empty string or whatnot during matching. I suspect I just havent tried enough.
Anyway, this is related to COW, the difference at 1250 bytes and 1249 bytes comes from the config for when to COW a string during copy. I made the regex engine show the eval_state->sv before and after the callback and you can see that the issue involves COW, if you change the .{1250} to .{1249} the corruption in $x will go away,
$ ./perl -Ilib -MDevel::Peek -le'($s="a"x1250)=~/(.{1250})(?{ $ = $1; $x="$1."; Dump($); Dump($x)})/;' SV = PV(0x55bc98dcdff0) at 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-Mre=debug -e "/just|another|perl|hacker/"
This is still a bug in blead.
A memory corruption of
$1
is happening inside a regex embedded code block, during a regex match, in specific conditions :$1
is assigned to$_
specifically$1
inside the embedded code blockWhen those conditions are met we can see garbage bytes at the start of
$1
(different ones each time) and$1
vary in length each time. Even with those conditions, no memory corruption appears when we print$1
again after the match.The bug does not appear if we assign another value than
$1
to$_
or if we assign$1
to another variable than$_
. The bug also does not appear if the length of the captured substring is < 1250 bytes.Here is the golfed test .
Example output
I hope that this bug doesn't cause too much headeache. Florian.
Perl configuration