Skip to content

Commit

Permalink
fix crash in ecp_nistz256_point_add_affine()
Browse files Browse the repository at this point in the history
The .rodata section with precomputed constant `ecp_nistz256_precomputed` needs to be
terminated by .text, because the ecp_nistz256_precomputed' happens to be the
first section in the file. The lack of .text makes code to arrive into the same
.rodata section where ecp_nistz256_precomputed is found. The exception is raised
as soon as CPU attempts to execute the code from read only section.

Fixes #24184
  • Loading branch information
Sashan committed Apr 22, 2024
1 parent 24d16d3 commit a13a053
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion crypto/perlasm/x86_64-xlate.pl
Expand Up @@ -909,29 +909,54 @@
# to deal with nasm/masm assembly.
#
$self->{value} =~ s/(.+)\s+align\s*=.*$/$1/;
$current_segment = pop(@segment_stack);
if (not $current_segment) {
# if no previous section is defined, then assume .text
# so code does not land in .data section by accident.
# this deals with inconsistency of perl-assembly files.
push(@segment_stack, ".text");
}
#
# $$line may still contains align= option. We do care
# about section type here.
#
$current_segment = $$line;
$current_segment =~ s/([^\s]+).*$/$1/;
push(@segment_stack, $current_segment);
if (!$elf && $current_segment eq ".rodata") {
if ($flavour eq "macosx") { $self->{value} = ".section\t__DATA,__const"; }
elsif ($flavour eq "mingw64") { $self->{value} = ".section\t.rodata"; }
}
if (!$elf && $current_segment eq ".init") {
if ($flavour eq "macosx") { $self->{value} = ".mod_init_func"; }
elsif ($flavour eq "mingw64") { $self->{value} = ".section\t.ctors"; }
}
} elsif ($dir =~ /\.(text|data)/) {
$current_segment = pop(@segment_stack);
if (not $current_segment) {
# if no previous section is defined, then assume .text
# so code does not land in .data section by accident.
# this deals with inconsistency of perl-assembly files.
push(@segment_stack, ".text");
}
$current_segment=".$1";
push(@segment_stack, $current_segment);
} elsif ($dir =~ /\.hidden/) {
if ($flavour eq "macosx") { $self->{value} = ".private_extern\t$prefix$$line"; }
elsif ($flavour eq "mingw64") { $self->{value} = ""; }
} elsif ($dir =~ /\.comm/) {
$self->{value} = "$dir\t$prefix$$line";
$self->{value} =~ s|,([0-9]+),([0-9]+)$|",$1,".log($2)/log(2)|e if ($flavour eq "macosx");
} elsif ($dir =~ /\.previous/) {
$self->{value} = "" if ($flavour eq "mingw64");
pop(@segment_stack); #pop ourselves
$current_segment = pop(@segment_stack); #pop previous section
if (not $current_segment) {
# if no previous segment was defined assume .text so
# the code does not accidentally land in .data section.
$current_segment = ".text"
}
push(@segment_stack, $current_segment);
$self->{value} = $current_segment if ($flavour eq "mingw64");
}
$$line = "";
return $self;
Expand Down

0 comments on commit a13a053

Please sign in to comment.