sync code with last improvements from OpenBSD
This commit is contained in:
parent
151b4b8168
commit
e70dd78b1d
19 changed files with 587 additions and 31 deletions
|
@ -6610,6 +6610,7 @@ t/op/svleak.pl Test file for svleak.t
|
|||
t/op/svleak.t See if stuff leaks SVs
|
||||
t/op/switch.t See if switches (given/when) work
|
||||
t/op/symbolcache.t See if undef/delete works on stashes with functions
|
||||
t/op/syscall_emulator.t Tests that syscall works via the emulator
|
||||
t/op/sysio.t See if sysread and syswrite work
|
||||
t/op/taint.t See if tainting works
|
||||
t/op/threads.t Misc. tests for perl features with threads
|
||||
|
|
|
@ -541,7 +541,7 @@ c1 = av.c scope.c op.c doop.c doio.c dump.c gv.c hv.c mg.c reentr.c mro_core.c p
|
|||
c2 = perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c utf8.c sv.c
|
||||
c3 = taint.c toke.c util.c deb.c run.c builtin.c universal.c pad.c globals.c keywords.c
|
||||
c4 = perlio.c numeric.c mathoms.c locale.c pp_pack.c pp_sort.c caretx.c dquote.c time64.c
|
||||
c5 = $(mallocsrc)
|
||||
c5 = $(mallocsrc) syscall_emulator.c
|
||||
|
||||
!NO!SUBS!
|
||||
|
||||
|
@ -557,7 +557,7 @@ c = $(c1) $(c2) $(c3) $(c4) $(c5) miniperlmain.c $(mini_only_src)
|
|||
|
||||
obj1 = $(mallocobj) gv$(OBJ_EXT) toke$(OBJ_EXT) perly$(OBJ_EXT) pad$(OBJ_EXT) regcomp$(OBJ_EXT) dump$(OBJ_EXT) util$(OBJ_EXT) mg$(OBJ_EXT) reentr$(OBJ_EXT) mro_core$(OBJ_EXT) keywords$(OBJ_EXT) builtin$(OBJ_EXT)
|
||||
obj2 = hv$(OBJ_EXT) av$(OBJ_EXT) run$(OBJ_EXT) pp_hot$(OBJ_EXT) sv$(OBJ_EXT) pp$(OBJ_EXT) scope$(OBJ_EXT) pp_ctl$(OBJ_EXT) pp_sys$(OBJ_EXT)
|
||||
obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) utf8$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) globals$(OBJ_EXT) perlio$(OBJ_EXT) numeric$(OBJ_EXT) mathoms$(OBJ_EXT) locale$(OBJ_EXT) pp_pack$(OBJ_EXT) pp_sort$(OBJ_EXT) caretx$(OBJ_EXT) dquote$(OBJ_EXT) time64$(OBJ_EXT)
|
||||
obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) utf8$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) globals$(OBJ_EXT) perlio$(OBJ_EXT) numeric$(OBJ_EXT) mathoms$(OBJ_EXT) locale$(OBJ_EXT) pp_pack$(OBJ_EXT) pp_sort$(OBJ_EXT) caretx$(OBJ_EXT) dquote$(OBJ_EXT) time64$(OBJ_EXT) syscall_emulator$(OBJ_EXT)
|
||||
|
||||
# split the objects into 3 exclusive sets: those used by both miniperl and
|
||||
# perl, and those used by just one or the other. Doesn't include the
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $OpenBSD: Makefile.bsd-wrapper,v 1.113 2023/02/15 01:38:20 afresh1 Exp $
|
||||
# $OpenBSD: Makefile.bsd-wrapper,v 1.114 2023/09/03 01:43:09 afresh1 Exp $
|
||||
#
|
||||
# Build wrapper for Perl
|
||||
#
|
||||
|
@ -39,11 +39,18 @@ cleandir:
|
|||
fi
|
||||
cd ${.CURDIR} && ${MAKE} -f Makefile.bsd-wrapper1 cleandir
|
||||
|
||||
all: config.sh
|
||||
all: syscall_emulator.c config.sh
|
||||
cd ${.CURDIR} && exec ${MAKE} -f Makefile.bsd-wrapper1 perl.build
|
||||
cd ${.CURDIR} && exec ${MAKE} -f Makefile.bsd-wrapper1 mansrc.build
|
||||
|
||||
install:
|
||||
cd ${.CURDIR} && exec ${MAKE} -f Makefile.bsd-wrapper1 install
|
||||
|
||||
|
||||
syscall_emulator.c: gen_syscall_emulator.pl syscall_emulator.h /usr/include/sys/syscall.h /usr/include/sys/syscallargs.h
|
||||
/usr/bin/perl $(.CURDIR)/gen_syscall_emulator.pl > $@
|
||||
|
||||
syscall_emulator.h:
|
||||
ln -sf $(.CURDIR)/$@ $@
|
||||
|
||||
.include <bsd.obj.mk>
|
||||
|
|
|
@ -103,12 +103,19 @@ Perl_av_extend_guts(pTHX_ AV *av, SSize_t key, SSize_t *maxp, SV ***allocp,
|
|||
"panic: av_extend_guts() negative count (%" IVdf ")", (IV)key);
|
||||
|
||||
if (key > *maxp) {
|
||||
SSize_t ary_offset = *maxp + 1;
|
||||
SSize_t to_null = 0;
|
||||
SSize_t ary_offset = *maxp + 1; /* Start NULL initialization
|
||||
* from this element */
|
||||
SSize_t to_null = 0; /* How many elements to Zero */
|
||||
SSize_t newmax = 0;
|
||||
|
||||
if (av && *allocp != *arrayp) { /* a shifted SV* array exists */
|
||||
|
||||
/* to_null will contain the number of elements currently
|
||||
* shifted and about to be unshifted. If the array has not
|
||||
* been shifted to the maximum possible extent, this will be
|
||||
* a smaller number than (*maxp - AvFILLp(av)). */
|
||||
to_null = *arrayp - *allocp;
|
||||
|
||||
*maxp += to_null;
|
||||
ary_offset = AvFILLp(av) + 1;
|
||||
|
||||
|
@ -116,6 +123,13 @@ Perl_av_extend_guts(pTHX_ AV *av, SSize_t key, SSize_t *maxp, SV ***allocp,
|
|||
|
||||
if (key > *maxp - 10) {
|
||||
newmax = key + *maxp;
|
||||
|
||||
/* Zero everything above AvFILLp(av), which could be more
|
||||
* elements than have actually been shifted. If we don't
|
||||
* do this, trailing elements at the end of the resized
|
||||
* array may not be correctly initialized. */
|
||||
to_null = *maxp - AvFILLp(av);
|
||||
|
||||
goto resize;
|
||||
}
|
||||
} else if (*allocp) { /* a full SV* array exists */
|
||||
|
@ -167,7 +181,9 @@ Perl_av_extend_guts(pTHX_ AV *av, SSize_t key, SSize_t *maxp, SV ***allocp,
|
|||
#ifdef Perl_safesysmalloc_size
|
||||
resized:
|
||||
#endif
|
||||
to_null += newmax - *maxp;
|
||||
to_null += newmax - *maxp; /* Initialize all new elements
|
||||
* (newmax - *maxp) in addition to
|
||||
* any previously specified */
|
||||
*maxp = newmax;
|
||||
|
||||
/* See GH#18014 for discussion of when this might be needed: */
|
||||
|
@ -193,7 +209,7 @@ Perl_av_extend_guts(pTHX_ AV *av, SSize_t key, SSize_t *maxp, SV ***allocp,
|
|||
* don't get any special treatment here.
|
||||
* See https://github.com/Perl/perl5/pull/18690 for more detail */
|
||||
ary_offset = 0;
|
||||
to_null = *maxp+1;
|
||||
to_null = *maxp+1; /* Initialize all new array elements */
|
||||
goto zero;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
# Override default paths when building in the SecBSD src tree
|
||||
#
|
||||
# $OpenBSD: config.over,v 1.22 2017/02/05 00:33:38 afresh1 Exp $
|
||||
# $OpenBSD: config.over,v 1.23 2023/09/03 01:43:09 afresh1 Exp $
|
||||
#
|
||||
|
||||
# We use a different architecture name than the default
|
||||
|
@ -64,3 +64,9 @@ myuname='secbsd'
|
|||
|
||||
# force to use ranlib
|
||||
ranlib='ranlib'
|
||||
|
||||
# Enable the syscall emulator,
|
||||
# enabling syscall even if we don't have it
|
||||
d_syscall=define
|
||||
d_syscallproto=define
|
||||
|
||||
|
|
360
gnu/usr.bin/perl/gen_syscall_emulator.pl
Executable file
360
gnu/usr.bin/perl/gen_syscall_emulator.pl
Executable file
|
@ -0,0 +1,360 @@
|
|||
#!/usr/bin/perl
|
||||
# $OpenBSD: gen_syscall_emulator.pl,v 1.1 2023/09/03 01:43:09 afresh1 Exp $ #
|
||||
use v5.36;
|
||||
use autodie;
|
||||
|
||||
# Copyright (c) 2023 Andrew Hewus Fresh <afresh1@openbsd.org>
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
my $includes = '/usr/include';
|
||||
|
||||
# Because perl uses a long for every syscall argument,
|
||||
# if we are building a syscall_emulator for use by perl,
|
||||
# taking that into account make things work more consistently
|
||||
# across different OpenBSD architectures.
|
||||
# Unfortunately there doesn't appear to be an easy way
|
||||
# to make everything work "the way it was".
|
||||
use constant PERL_LONG_ARGS => 1;
|
||||
|
||||
# See also /usr/src/sys/kern/syscalls.master
|
||||
my %syscalls = parse_syscalls(
|
||||
"$includes/sys/syscall.h",
|
||||
"$includes/sys/syscallargs.h",
|
||||
)->%*;
|
||||
delete $syscalls{MAXSYSCALL}; # not an actual function
|
||||
|
||||
# The ordered list of all the headers we need
|
||||
my @headers = qw<
|
||||
sys/syscall.h
|
||||
stdarg.h
|
||||
errno.h
|
||||
|
||||
sys/socket.h
|
||||
sys/event.h
|
||||
sys/futex.h
|
||||
sys/ioctl.h
|
||||
sys/ktrace.h
|
||||
sys/mman.h
|
||||
sys/mount.h
|
||||
sys/msg.h
|
||||
sys/poll.h
|
||||
sys/ptrace.h
|
||||
sys/resource.h
|
||||
sys/select.h
|
||||
sys/sem.h
|
||||
sys/shm.h
|
||||
sys/stat.h
|
||||
sys/sysctl.h
|
||||
sys/time.h
|
||||
sys/uio.h
|
||||
sys/wait.h
|
||||
|
||||
dirent.h
|
||||
fcntl.h
|
||||
sched.h
|
||||
signal.h
|
||||
stdlib.h
|
||||
stdio.h
|
||||
syslog.h
|
||||
tib.h
|
||||
time.h
|
||||
unistd.h
|
||||
>;
|
||||
|
||||
foreach my $header (@headers) {
|
||||
my $filename = "$includes/$header";
|
||||
open my $fh, '<', $filename;
|
||||
my $content = do { local $/; readline $fh };
|
||||
close $fh;
|
||||
|
||||
foreach my $name (sort keys %syscalls) {
|
||||
my $s = $syscalls{$name};
|
||||
my $func_sig = find_func_sig($content, $name, $s);
|
||||
|
||||
if (ref $func_sig) {
|
||||
die "Multiple defs for $name <$header> <$s->{header}>"
|
||||
if $s->{header};
|
||||
$s->{func} = $func_sig;
|
||||
$s->{header} = $header;
|
||||
} elsif ($func_sig) {
|
||||
$s->{mismatched_sig} = "$func_sig <$header>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
say "/*\n * Generated from gen_syscall_emulator.pl\n */";
|
||||
say "#include <$_>" for @headers;
|
||||
print <<"EOL";
|
||||
#include "syscall_emulator.h"
|
||||
|
||||
long
|
||||
syscall_emulator(int syscall, ...)
|
||||
{
|
||||
long ret = 0;
|
||||
va_list args;
|
||||
va_start(args, syscall);
|
||||
|
||||
switch(syscall) {
|
||||
EOL
|
||||
|
||||
foreach my $name (
|
||||
sort { $syscalls{$a}{id} <=> $syscalls{$b}{id} } keys %syscalls
|
||||
) {
|
||||
my %s = %{ $syscalls{$name} };
|
||||
|
||||
# Some syscalls we can't emulate, so we comment those out.
|
||||
$s{skip} //= "Indirect syscalls not supported"
|
||||
if !$s{argtypes} && ($s{args}[-1] || '') eq '...';
|
||||
$s{skip} //= "Mismatched func: $s{mismatched_sig}"
|
||||
if $s{mismatched_sig} and not $s{func};
|
||||
$s{skip} //= "No signature found in headers"
|
||||
unless $s{header};
|
||||
|
||||
my $ret = $s{ret} eq 'void' ? '' : 'ret = ';
|
||||
$ret .= '(long)' if $s{ret} eq 'void *';
|
||||
|
||||
my (@args, @defines);
|
||||
my $argname = '';
|
||||
if ($s{argtypes}) {
|
||||
if (@{ $s{argtypes} } > 1) {
|
||||
@defines = map {
|
||||
my $t = $_->{type};
|
||||
my $n = $_->{name};
|
||||
$n = "_$n" if $n eq $name; # link :-/
|
||||
push @args, $n;
|
||||
PERL_LONG_ARGS
|
||||
? "$t $n = ($t)va_arg(args, long);"
|
||||
: "$t $n = va_arg(args, $t);"
|
||||
} @{ $s{argtypes} };
|
||||
} else {
|
||||
if (@{ $s{argtypes} }) {
|
||||
$argname = " // " . join ', ',
|
||||
map { $_->{name} }
|
||||
@{ $s{argtypes} };
|
||||
}
|
||||
@args = map { "va_arg(args, $_->{type})" }
|
||||
@{ $s{argtypes} };
|
||||
}
|
||||
} else {
|
||||
@args = @{ $s{args} };
|
||||
|
||||
# If we didn't find args in syscallargs.h but have args
|
||||
# we don't know how to write our function.
|
||||
$s{skip} //= "Not found in sys/syscallargs.h"
|
||||
if @args;
|
||||
}
|
||||
|
||||
#my $header = $s{header} ? " <$s{header}>" : '';
|
||||
|
||||
my $indent = "\t";
|
||||
say "$indent/* $s{skip}" if $s{skip};
|
||||
|
||||
$indent .= ' *' if $s{skip};
|
||||
say "${indent} $s{signature} <sys/syscall.h>"
|
||||
if $s{skip} && $s{skip} =~ /Mismatch/;
|
||||
|
||||
my $brace = @defines ? " {" : "";
|
||||
say "${indent}case $s{define}:$brace"; # // $s{id}";
|
||||
say "${indent}\t$_" for @defines;
|
||||
#say "${indent}\t// $s{signature}$header";
|
||||
say "${indent}\t$ret$name(" . join(', ', @args) . ");$argname";
|
||||
say "${indent}\tbreak;";
|
||||
say "${indent}}" if $brace;
|
||||
|
||||
say "\t */" if $s{skip};
|
||||
}
|
||||
|
||||
print <<"EOL";
|
||||
default:
|
||||
ret = -1;
|
||||
errno = ENOSYS;
|
||||
}
|
||||
va_end(args);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EOL
|
||||
|
||||
|
||||
sub parse_syscalls($syscall, $args)
|
||||
{
|
||||
my %s = parse_syscall_h($syscall)->%*;
|
||||
|
||||
my %a = parse_syscallargs_h($args)->%*;
|
||||
$s{$_}{argtypes} = $a{$_} for grep { $a{$_} } keys %s;
|
||||
|
||||
return \%s;
|
||||
}
|
||||
|
||||
sub parse_syscall_h($filename)
|
||||
{
|
||||
my %s;
|
||||
open my $fh, '<', $filename;
|
||||
while (readline $fh) {
|
||||
if (m{^/\*
|
||||
\s+ syscall: \s+ "(?<name>[^"]+)"
|
||||
\s+ ret: \s+ "(?<ret> [^"]+)"
|
||||
\s+ args: \s+ (?<args>.*?)
|
||||
\s* \*/
|
||||
|
|
||||
^\#define \s+ (?<define>SYS_(?<name>\S+)) \s+ (?<id>\d+)
|
||||
}x)
|
||||
{
|
||||
my $name = $+{name};
|
||||
$s{$name}{$_} = $+{$_} for keys %+;
|
||||
$s{$name}{args} = [ $+{args} =~ /"(.*?)"/g ]
|
||||
if exists $+{args};
|
||||
}
|
||||
}
|
||||
close $fh;
|
||||
|
||||
foreach my $name (keys %s) {
|
||||
my %d = %{ $s{$name} };
|
||||
next unless $d{ret}; # the MAXSYSCALL
|
||||
|
||||
my $ret = $d{ret};
|
||||
my @args = @{ $d{args} || [] };
|
||||
@args = 'void' unless @args;
|
||||
|
||||
if ($args[-1] ne '...') {
|
||||
my @a;
|
||||
for (@args) {
|
||||
push @a, $_;
|
||||
last if $_ eq '...';
|
||||
}
|
||||
@args = @a;
|
||||
}
|
||||
|
||||
my $args = join ", ", @args;
|
||||
$s{$name}{signature} = "$ret\t$name($args);" =~ s/\s+/ /gr;
|
||||
#print " $s{$name}{signature}\n";
|
||||
}
|
||||
|
||||
return \%s;
|
||||
}
|
||||
|
||||
sub parse_syscallargs_h($filename)
|
||||
{
|
||||
my %args;
|
||||
|
||||
open my $fh, '<', $filename;
|
||||
while (readline $fh) {
|
||||
if (my ($syscall) = /^struct \s+ sys_(\w+)_args \s+ \{/x) {
|
||||
$args{$syscall} = [];
|
||||
while (readline $fh) {
|
||||
last if /^\s*\};\s*$/;
|
||||
if (/syscallarg
|
||||
\( (?<type> [^)]+ ) \)
|
||||
\s+ (?<name> \w+ ) \s* ;
|
||||
/x) {
|
||||
push @{$args{$syscall}}, {%+};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
close $fh;
|
||||
|
||||
return \%args;
|
||||
}
|
||||
|
||||
sub find_func_sig($content, $name, $s)
|
||||
{
|
||||
my $re = $s->{re} //= qr{^
|
||||
(?<ret> \S+ (?: [^\S\n]+ \S+)? ) [^\S\n]* \n?
|
||||
\b \Q$name\E \( (?<args> [^)]* ) \)
|
||||
[^;]*;
|
||||
}xms;
|
||||
|
||||
$content =~ /$re/ || return !!0;
|
||||
my $ret = $+{ret};
|
||||
my $args = $+{args};
|
||||
|
||||
for ($ret, $args) {
|
||||
s/^\s+//;
|
||||
s/\s+$//;
|
||||
s/\s+/ /g;
|
||||
}
|
||||
|
||||
# The actual functions may have this extra annotation
|
||||
$args =~ s/\*\s*__restrict/*/g;
|
||||
|
||||
my %func_sig = ( ret => $ret, args => [ split /\s*,\s*/, $args ] );
|
||||
|
||||
return "$ret $name($args);" =~ s/\s+/ /gr
|
||||
unless sigs_match($s, \%func_sig);
|
||||
|
||||
return \%func_sig;
|
||||
}
|
||||
|
||||
# Tests whether two types are equivalent.
|
||||
# Sometimes there are two ways to represent the same thing
|
||||
# and it seems the functions and the syscalls
|
||||
# differ a fair amount.
|
||||
sub types_match($l, $r)
|
||||
{
|
||||
state %m = (
|
||||
caddr_t => 'char *',
|
||||
idtype_t => 'int',
|
||||
nfds_t => 'u_int',
|
||||
__off_t => 'off_t',
|
||||
pid_t => 'int',
|
||||
__size_t => 'u_long',
|
||||
size_t => 'u_long',
|
||||
'unsigned int' => 'u_int',
|
||||
'unsigned long' => 'u_long',
|
||||
);
|
||||
|
||||
$l //= '__undef__';
|
||||
$r //= '__undef__';
|
||||
|
||||
s/\b volatile \s+//x for $l, $r;
|
||||
s/\b const \s+//x for $l, $r;
|
||||
s/\s* \[\d*\] $/ \*/x for $l, $r;
|
||||
|
||||
my ($f, $s) = sort { length($a) <=> length($b) } $l, $r;
|
||||
if (index($s, $f) == 0) {
|
||||
$s =~ s/^\Q$f\E\s*//;
|
||||
if ( $s && $s =~ /^\w+$/ ) {
|
||||
#warn "prefix ['$f', '$s']\n";
|
||||
s/\s*\Q$s\E$// for $l, $r;
|
||||
}
|
||||
}
|
||||
|
||||
$l = $m{$l} //= $l;
|
||||
$r = $m{$r} //= $r;
|
||||
|
||||
return $l eq $r;
|
||||
}
|
||||
|
||||
|
||||
# Tests whether two function signatures match,
|
||||
# expected to be left from syscall.h, right from the appopriate header.
|
||||
sub sigs_match($l, $r)
|
||||
{
|
||||
return !!0 unless types_match( $l->{ret}, $l->{ret} );
|
||||
|
||||
my @l_args = @{ $l->{args} || [] };
|
||||
my @r_args = @{ $r->{args} || [] };
|
||||
|
||||
for (\@l_args, \@r_args) {
|
||||
@{$_} = 'void' unless @{$_};
|
||||
}
|
||||
|
||||
for my $i ( 0 .. $#l_args ) {
|
||||
return !!0 unless types_match($l_args[$i], $r_args[$i]);
|
||||
last if $l_args[$i] eq '...';
|
||||
}
|
||||
|
||||
return !!1;
|
||||
}
|
|
@ -30,6 +30,8 @@
|
|||
#define PERL_IN_PP_SYS_C
|
||||
#include "perl.h"
|
||||
#include "time64.h"
|
||||
#include "syscall_emulator.h"
|
||||
#define syscall syscall_emulator
|
||||
|
||||
#ifdef I_SHADOW
|
||||
/* Shadow password support for solaris - pdo@cs.umd.edu
|
||||
|
|
1
gnu/usr.bin/perl/syscall_emulator.h
Normal file
1
gnu/usr.bin/perl/syscall_emulator.h
Normal file
|
@ -0,0 +1 @@
|
|||
long syscall_emulator(int, ...);
|
|
@ -6,7 +6,7 @@ BEGIN {
|
|||
set_up_inc('.', '../lib');
|
||||
}
|
||||
|
||||
plan (194);
|
||||
plan (195);
|
||||
|
||||
#
|
||||
# @foo, @bar, and @ary are also used from tie-stdarray after tie-ing them
|
||||
|
@ -686,4 +686,8 @@ $#a = -1; $#a++;
|
|||
'holes passed to sub do not lose their position (aelem, mg)';
|
||||
}
|
||||
|
||||
# GH #21235
|
||||
fresh_perl_is('my @x;$x[0] = 1;shift @x;$x[22] = 1;$x[25] = 1;','',
|
||||
{}, 'unshifting and growing an array initializes trailing elements');
|
||||
|
||||
"We're included by lib/Tie/Array/std.t so we need to return something true";
|
||||
|
|
148
gnu/usr.bin/perl/t/op/syscall_emulator.t
Normal file
148
gnu/usr.bin/perl/t/op/syscall_emulator.t
Normal file
|
@ -0,0 +1,148 @@
|
|||
#!/usr/bin/perl
|
||||
# $OpenBSD: syscall_emulator.t,v 1.1 2023/09/03 01:43:09 afresh1 Exp $ #
|
||||
|
||||
# Copyright (c) 2023 Andrew Hewus Fresh <afresh1@openbsd.org>
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
BEGIN {
|
||||
chdir 't' if -d 't';
|
||||
require "./test.pl";
|
||||
set_up_inc( qw(. ../lib lib ../dist/base/lib) );
|
||||
}
|
||||
|
||||
use v5.36;
|
||||
|
||||
use File::Temp;
|
||||
use POSIX qw< S_IRUSR S_IWUSR S_IRGRP S_IROTH O_CREAT O_WRONLY O_RDONLY >;
|
||||
|
||||
use constant {
|
||||
PROT_READ => 0x01,
|
||||
MAP_PRIVATE => 0x0002,
|
||||
MAP_FAILED => -1,
|
||||
};
|
||||
|
||||
my $dir = File::Temp->newdir("syscall_emulator-XXXXXXXXX");
|
||||
{
|
||||
local $ENV{PERL5LIB} = join ':', @INC;
|
||||
open(my $fh, '-|', $^X, "../utils/h2ph", '-d', $dir,
|
||||
"/usr/include/sys/syscall.h") or die "h2ph: $!";
|
||||
note <$fh>;
|
||||
close($fh) or die $! ? "h2ph: $!" : "h2ph: $?";
|
||||
local @INC = ("$dir/usr/include", "$dir");
|
||||
require 'sys/syscall.ph';
|
||||
}
|
||||
|
||||
my $filename = "test.txt";
|
||||
my $file = "$dir/$filename";
|
||||
my $fd;
|
||||
my $out = "Hello World\n";
|
||||
my $in = "\0" x 32;
|
||||
my ($in_p, $in_v);
|
||||
my $sb = "\0" x 4096;
|
||||
my $st_mode;
|
||||
|
||||
my $perms = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;
|
||||
|
||||
plan tests => 17;
|
||||
|
||||
ok(!
|
||||
(($fd = syscall(SYS_open(), $file, O_CREAT|O_WRONLY, $perms)) < 0),
|
||||
"Opened $filename for write/create"
|
||||
);
|
||||
ok(!
|
||||
(syscall(SYS_write(), $fd, $out, length $out) <= 0),
|
||||
"Wrote out to $filename"
|
||||
);
|
||||
ok(!
|
||||
(syscall(SYS_close(), $fd) != 0),
|
||||
"closed $filename"
|
||||
);
|
||||
|
||||
|
||||
ok(!
|
||||
(syscall(SYS_stat(), $file, $sb) != 0),
|
||||
"stat $filename"
|
||||
);
|
||||
|
||||
# fortunately st_mode is the first unsigned long in stat struct
|
||||
$st_mode = unpack "L", $sb;
|
||||
|
||||
ok( ($st_mode & 0777) == ($perms & 0777),
|
||||
sprintf "new file %s has correct permissions (%o)",
|
||||
$filename, $st_mode & 0777
|
||||
);
|
||||
|
||||
ok(!
|
||||
(($fd = syscall(SYS_open(), $file, O_RDONLY)) < 0),
|
||||
"Opened $filename for read"
|
||||
);
|
||||
ok(!
|
||||
(syscall(SYS_read(), $fd, $in, length $in) <= 0),
|
||||
"read from $filename"
|
||||
);
|
||||
|
||||
$in = unpack 'Z*', $in;
|
||||
|
||||
ok( length($in) == length($out) && ($in eq $out),
|
||||
"Read written content from $filename"
|
||||
);
|
||||
|
||||
ok(!
|
||||
(syscall(SYS_lseek(), $fd, 0, SEEK_SET) < 0),
|
||||
"lseek on fd"
|
||||
);
|
||||
|
||||
ok(!
|
||||
(syscall(SYS_pread(), $fd, $in = "\0" x 32, 5, 3) < 0),
|
||||
"pread on fd"
|
||||
);
|
||||
|
||||
$in = unpack 'Z*', $in;
|
||||
|
||||
ok( length($in) == 5 && ($in eq substr $out, 3, 5),
|
||||
"Read written content from $filename ($in)"
|
||||
);
|
||||
|
||||
ok(!
|
||||
(syscall(SYS_lseek(), $fd, 0, SEEK_SET) < 0),
|
||||
"lseek on fd"
|
||||
);
|
||||
|
||||
ok(!
|
||||
(syscall(SYS_lseek(), $fd, 0, SEEK_SET) < 0),
|
||||
"lseek on fd"
|
||||
);
|
||||
|
||||
ok(!
|
||||
(($in_p = syscall(SYS_mmap(), undef, length($out), PROT_READ, MAP_PRIVATE,
|
||||
$fd, 0)) == MAP_FAILED),
|
||||
"mmap fd"
|
||||
);
|
||||
|
||||
# From ingy's Pointer module
|
||||
$in_v = unpack "p*", pack "L!", $in_p;
|
||||
|
||||
ok( length($in_v) == length($out) && ($in_v eq $out),
|
||||
"Read written content from $filename"
|
||||
);
|
||||
|
||||
ok(!
|
||||
(syscall(SYS_munmap(), $in_p, length($out)) != 0),
|
||||
"munmap fd"
|
||||
);
|
||||
|
||||
ok(!
|
||||
(syscall(SYS_close(), $fd) != 0),
|
||||
"closed $filename"
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
.\" $OpenBSD: bsd.port.mk.5,v 1.583 2023/09/02 17:19:57 espie Exp $
|
||||
.\" $OpenBSD: bsd.port.mk.5,v 1.585 2023/09/03 12:24:16 espie Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2000-2008 Marc Espie
|
||||
.\"
|
||||
|
@ -24,7 +24,7 @@
|
|||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: September 2 2023 $
|
||||
.Dd $Mdocdate: September 3 2023 $
|
||||
.Dt BSD.PORT.MK 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -2151,6 +2151,7 @@ Defaults to
|
|||
If set, points to a local directory common for all instances of
|
||||
concurrent ports builds.
|
||||
.It Ev LOCK_CMD
|
||||
User settings.
|
||||
Expands to a command that will acquire a lock, namely
|
||||
.Xr portlock 1 .
|
||||
See also
|
||||
|
@ -2808,6 +2809,10 @@ derived from the
|
|||
Do not override without very good reasons,
|
||||
namely software that coexist as different incompatible versions with the
|
||||
same stem, e.g., already a mess.
|
||||
Also See the description of
|
||||
.Fl P
|
||||
in
|
||||
.Xr pkg_create 1
|
||||
.It Ev PKGSTEM
|
||||
Base for the package name without any version number.
|
||||
Used in
|
||||
|
@ -2840,12 +2845,6 @@ plists actually get saved into
|
|||
.Pa ${PLIST_REPOSITORY}/${MACHINE_ARCH}
|
||||
.Pc .
|
||||
If set to empty, will not register anything: very much unsafe.
|
||||
.It Ev PORTS_BUILD_XENOCARA_TOO
|
||||
EXPERIMENTAL.
|
||||
Set to
|
||||
.Sq Yes
|
||||
to build xenocara through ports.
|
||||
This is highly experimental and not recommended.
|
||||
.It Ev PORTROACH
|
||||
Controls the behavior of
|
||||
.Pa misc/portroach
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: identcpu.c,v 1.137 2023/08/16 04:07:37 jsg Exp $ */
|
||||
/* $OpenBSD: identcpu.c,v 1.138 2023/09/03 09:30:43 mlarkin Exp $ */
|
||||
/* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -228,6 +228,7 @@ const struct {
|
|||
}, cpu_cpuid_perf_eax[] = {
|
||||
{ CPUIDEAX_VERID, "PERF" },
|
||||
}, cpu_cpuid_apmi_edx[] = {
|
||||
{ CPUIDEDX_HWPSTATE, "HWPSTATE" },
|
||||
{ CPUIDEDX_ITSC, "ITSC" },
|
||||
}, cpu_amdspec_ebxfeatures[] = {
|
||||
{ CPUIDEBX_INVLPGB, "INVLPGB" },
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: vmm_machdep.c,v 1.5 2023/08/15 08:27:29 miod Exp $ */
|
||||
/* $OpenBSD: vmm_machdep.c,v 1.6 2023/09/03 09:30:43 mlarkin Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
|
||||
*
|
||||
|
@ -6319,7 +6319,7 @@ vmm_handle_cpuid(struct vcpu *vcpu)
|
|||
*rax = eax;
|
||||
*rbx = ebx;
|
||||
*rcx = ecx;
|
||||
*rdx = edx;
|
||||
*rdx = edx & VMM_APMI_EDX_MASK;
|
||||
break;
|
||||
case 0x80000008: /* Phys bits info and topology (AMD) */
|
||||
*rax = eax;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: specialreg.h,v 1.108 2023/08/16 04:07:37 jsg Exp $ */
|
||||
/* $OpenBSD: specialreg.h,v 1.109 2023/09/03 09:30:43 mlarkin Exp $ */
|
||||
/* $NetBSD: specialreg.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */
|
||||
/* $NetBSD: x86/specialreg.h,v 1.2 2003/04/25 21:54:30 fvdl Exp $ */
|
||||
|
||||
|
@ -329,6 +329,7 @@
|
|||
* "Advanced Power Management Information" bits (CPUID function 0x80000007):
|
||||
* EDX bits.
|
||||
*/
|
||||
#define CPUIDEDX_HWPSTATE (1 << 7) /* Hardware P State Control */
|
||||
#define CPUIDEDX_ITSC (1 << 8) /* Invariant TSC */
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: vmmvar.h,v 1.91 2023/04/26 15:11:21 mlarkin Exp $ */
|
||||
/* $OpenBSD: vmmvar.h,v 1.92 2023/09/03 09:30:43 mlarkin Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
|
||||
*
|
||||
|
@ -559,6 +559,7 @@ struct vm_mprotect_ept_params {
|
|||
CPUIDEBX_STIBP | CPUIDEBX_IBRS_ALWAYSON | CPUIDEBX_STIBP_ALWAYSON | \
|
||||
CPUIDEBX_IBRS_PREF | CPUIDEBX_SSBD | CPUIDEBX_VIRT_SSBD | \
|
||||
CPUIDEBX_SSBD_NOTREQ)
|
||||
#define VMM_APMI_EDX_MASK ~(CPUIDEDX_HWPSTATE)
|
||||
|
||||
/*
|
||||
* SEFF flags - copy from host minus:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: map.c,v 1.22 2023/08/13 09:48:27 mpi Exp $ */
|
||||
/* $OpenBSD: map.c,v 1.23 2023/09/03 10:26:35 mpi Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020 Martin Pieuchot <mpi@openbsd.org>
|
||||
|
@ -176,6 +176,7 @@ map_insert(struct map *map, const char *key, struct bt_arg *bval,
|
|||
val += ba2long(bval->ba_value, dtev);
|
||||
mep->mval->ba_value = (void *)val;
|
||||
break;
|
||||
case B_AT_BI_COMM:
|
||||
case B_AT_BI_KSTACK:
|
||||
case B_AT_BI_USTACK:
|
||||
free(mep->mval);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: server.c,v 1.127 2023/07/12 12:37:27 tb Exp $ */
|
||||
/* $OpenBSD: server.c,v 1.128 2023/09/03 10:18:18 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
|
||||
|
@ -1461,7 +1461,7 @@ server_bufferevent_write_chunk(struct client *clt,
|
|||
struct evbuffer *buf, size_t size)
|
||||
{
|
||||
int ret;
|
||||
ret = server_bufferevent_write(clt, buf->buffer, size);
|
||||
ret = server_bufferevent_write(clt, EVBUFFER_DATA(buf), size);
|
||||
if (ret != -1)
|
||||
evbuffer_drain(buf, size);
|
||||
return (ret);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: relay.c,v 1.256 2023/06/06 15:16:52 beck Exp $ */
|
||||
/* $OpenBSD: relay.c,v 1.257 2023/09/03 10:22:03 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
|
||||
|
@ -2629,7 +2629,7 @@ relay_bufferevent_write_chunk(struct ctl_relay_event *cre,
|
|||
struct evbuffer *buf, size_t size)
|
||||
{
|
||||
int ret;
|
||||
ret = relay_bufferevent_write(cre, buf->buffer, size);
|
||||
ret = relay_bufferevent_write(cre, EVBUFFER_DATA(buf), size);
|
||||
if (ret != -1)
|
||||
evbuffer_drain(buf, size);
|
||||
return (ret);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: mft.c,v 1.96 2023/06/29 10:28:25 tb Exp $ */
|
||||
/* $OpenBSD: mft.c,v 1.97 2023/09/03 10:48:50 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
|
@ -233,6 +233,7 @@ mft_parse_filehash(struct parse *p, const FileAndHash *fh)
|
|||
int rc = 0;
|
||||
struct mftfile *fent;
|
||||
enum rtype type;
|
||||
size_t new_idx = 0;
|
||||
|
||||
if (!valid_mft_filename(fh->file->data, fh->file->length)) {
|
||||
warnx("%s: RFC 6486 section 4.2.2: bad filename", p->fn);
|
||||
|
@ -256,8 +257,15 @@ mft_parse_filehash(struct parse *p, const FileAndHash *fh)
|
|||
p->found_crl = 1;
|
||||
}
|
||||
|
||||
/* Insert the filename and hash value. */
|
||||
if (filemode)
|
||||
fent = &p->res->files[p->res->filesz++];
|
||||
else {
|
||||
/* Fisher-Yates shuffle */
|
||||
new_idx = arc4random_uniform(p->res->filesz + 1);
|
||||
p->res->files[p->res->filesz++] = p->res->files[new_idx];
|
||||
fent = &p->res->files[new_idx];
|
||||
}
|
||||
|
||||
fent->type = type;
|
||||
fent->file = fn;
|
||||
fn = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue