sync with OpenBSD -current

This commit is contained in:
purplerain 2024-01-20 03:21:37 +00:00
parent fdad81bcfc
commit ed28f347da
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
53 changed files with 1138 additions and 405 deletions

View File

@ -1695,7 +1695,6 @@
./usr/share/man/man2/nfssvc.2 ./usr/share/man/man2/nfssvc.2
./usr/share/man/man2/open.2 ./usr/share/man/man2/open.2
./usr/share/man/man2/pathconf.2 ./usr/share/man/man2/pathconf.2
./usr/share/man/man2/pinsyscall.2
./usr/share/man/man2/pinsyscalls.2 ./usr/share/man/man2/pinsyscalls.2
./usr/share/man/man2/pipe.2 ./usr/share/man/man2/pipe.2
./usr/share/man/man2/pledge.2 ./usr/share/man/man2/pledge.2

View File

@ -1,9 +1,7 @@
# $OpenBSD: Makefile.inc,v 1.6 2023/02/27 15:00:17 deraadt Exp $ # $OpenBSD: Makefile.inc,v 1.7 2024/01/19 17:02:28 deraadt Exp $
.PATH: ${LIBCSRCDIR}/dlfcn .PATH: ${LIBCSRCDIR}/dlfcn
.include <bsd.own.mk> .include <bsd.own.mk>
SRCS+= dlfcn_stubs.c init.c tib.c SRCS+= dlfcn_stubs.c init.c tib.c
init.o init.po: _execvesize.c

View File

@ -1,4 +1,4 @@
/* $OpenBSD: init.c,v 1.20 2024/01/18 19:00:11 deraadt Exp $ */ /* $OpenBSD: init.c,v 1.21 2024/01/19 14:15:51 deraadt Exp $ */
/* /*
* Copyright (c) 2014,2015 Philip Guenther <guenther@openbsd.org> * Copyright (c) 2014,2015 Philip Guenther <guenther@openbsd.org>
* *
@ -71,9 +71,6 @@ extern Elf_Ehdr __executable_start[] __attribute__((weak));
/* provide definitions for these */ /* provide definitions for these */
const dl_cb *_dl_cb __relro = NULL; const dl_cb *_dl_cb __relro = NULL;
int pinsyscall(int, void *, size_t);
PROTO_NORMAL(pinsyscall);
int HIDDEN(execve)(const char *, char *const *, char *const *) int HIDDEN(execve)(const char *, char *const *, char *const *)
__attribute__((weak)); __attribute__((weak));
@ -141,23 +138,9 @@ _libc_preinit(int argc, char **argv, char **envp, dl_cb_cb *cb)
_static_phdr_info.dlpi_phnum = phnum; _static_phdr_info.dlpi_phnum = phnum;
/* static libc in a static link? */ /* static libc in a static link? */
if (cb == NULL) { if (cb == NULL)
setup_static_tib(phdr, phnum); setup_static_tib(phdr, phnum);
#if !defined(__hppa__)
if (&HIDDEN(execve)) {
extern const int _execve_size;
pinsyscall(SYS_execve, &HIDDEN(execve), _execve_size);
} else {
static const int not_syscall;
/* Static binary which does not use execve() */
pinsyscall(SYS_execve, (void *)&not_syscall, 1);
}
#endif
}
/* /*
* If a static binary has text relocations (DT_TEXT), then un-writeable * If a static binary has text relocations (DT_TEXT), then un-writeable
* segments were not made immutable by the kernel. Textrel and RELRO * segments were not made immutable by the kernel. Textrel and RELRO

View File

@ -1,4 +1,4 @@
/* $OpenBSD: stdlib.h,v 1.18 2023/05/27 04:33:00 otto Exp $ */ /* $OpenBSD: stdlib.h,v 1.19 2024/01/19 19:45:02 millert Exp $ */
/* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */ /* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */
/*- /*-
@ -38,6 +38,7 @@
#include_next <stdlib.h> #include_next <stdlib.h>
__BEGIN_HIDDEN_DECLS __BEGIN_HIDDEN_DECLS
int __mktemp4(char *, int, int, int (*)(const char *, int));
char *__findenv(const char *, int, int *); char *__findenv(const char *, int, int *);
void __atexit_register_cleanup(void (*)(void)); void __atexit_register_cleanup(void (*)(void));
__END_HIDDEN_DECLS __END_HIDDEN_DECLS

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile.inc,v 1.29 2016/03/30 06:38:41 jmc Exp $ # $OpenBSD: Makefile.inc,v 1.30 2024/01/19 16:30:28 millert Exp $
# stdio sources # stdio sources
.PATH: ${LIBCSRCDIR}/stdio .PATH: ${LIBCSRCDIR}/stdio
@ -9,7 +9,7 @@ SRCS+= asprintf.c clrerr.c fclose.c fdopen.c feof.c ferror.c fflush.c fgetc.c \
fgetln.c fgetpos.c fgets.c fileno.c findfp.c flags.c fmemopen.c \ fgetln.c fgetpos.c fgets.c fileno.c findfp.c flags.c fmemopen.c \
fopen.c fprintf.c fpurge.c fputc.c fputs.c fread.c freopen.c fscanf.c \ fopen.c fprintf.c fpurge.c fputc.c fputs.c fread.c freopen.c fscanf.c \
fseek.c fsetpos.c ftell.c funopen.c fvwrite.c fwalk.c fwrite.c \ fseek.c fsetpos.c ftell.c funopen.c fvwrite.c fwalk.c fwrite.c \
getc.c getchar.c getw.c makebuf.c mktemp.c open_memstream.c \ getc.c getchar.c getw.c makebuf.c open_memstream.c \
open_wmemstream.c perror.c printf.c putc.c putchar.c puts.c putw.c \ open_wmemstream.c perror.c printf.c putc.c putchar.c puts.c putw.c \
refill.c remove.c rewind.c rget.c scanf.c setbuf.c setbuffer.c \ refill.c remove.c rewind.c rget.c scanf.c setbuf.c setbuffer.c \
setvbuf.c snprintf.c sprintf.c sscanf.c stdio.c tempnam.c tmpfile.c \ setvbuf.c snprintf.c sprintf.c sscanf.c stdio.c tempnam.c tmpfile.c \
@ -22,7 +22,7 @@ SRCS+= asprintf.c clrerr.c fclose.c fdopen.c feof.c ferror.c fflush.c fgetc.c \
getdelim.c getline.c dprintf.c vdprintf.c getdelim.c getline.c dprintf.c vdprintf.c
MAN+= fclose.3 ferror.3 fflush.3 fgetln.3 fgets.3 fgetwln.3 fmemopen.3 \ MAN+= fclose.3 ferror.3 fflush.3 fgetln.3 fgets.3 fgetwln.3 fmemopen.3 \
fopen.3 fputs.3 fread.3 fseek.3 funopen.3 getc.3 mktemp.3 \ fopen.3 fputs.3 fread.3 fseek.3 funopen.3 getc.3 \
open_memstream.3 perror.3 printf.3 putc.3 remove.3 scanf.3 setbuf.3 \ open_memstream.3 perror.3 printf.3 putc.3 remove.3 scanf.3 setbuf.3 \
setvbuf.3 stdio.3 tmpnam.3 ungetc.3 fgetws.3 fputws.3 fwide.3 getwc.3 \ setvbuf.3 stdio.3 tmpnam.3 ungetc.3 fgetws.3 fputws.3 fwide.3 getwc.3 \
putwc.3 ungetwc.3 wprintf.3 wscanf.3 getdelim.3 putwc.3 ungetwc.3 wprintf.3 wscanf.3 getdelim.3

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile.inc,v 1.64 2017/12/16 20:06:55 guenther Exp $ # $OpenBSD: Makefile.inc,v 1.66 2024/01/19 19:45:02 millert Exp $
# stdlib sources # stdlib sources
.PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/stdlib ${LIBCSRCDIR}/stdlib .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/stdlib ${LIBCSRCDIR}/stdlib
@ -6,9 +6,9 @@
SRCS+= a64l.c abort.c atexit.c atoi.c atof.c atol.c atoll.c bsearch.c \ SRCS+= a64l.c abort.c atexit.c atoi.c atof.c atol.c atoll.c bsearch.c \
exit.c ecvt.c gcvt.c getenv.c getopt_long.c \ exit.c ecvt.c gcvt.c getenv.c getopt_long.c \
getsubopt.c hcreate.c heapsort.c imaxabs.c imaxdiv.c insque.c \ getsubopt.c hcreate.c heapsort.c imaxabs.c imaxdiv.c insque.c \
l64a.c llabs.c lldiv.c lsearch.c malloc.c reallocarray.c \ l64a.c llabs.c lldiv.c lsearch.c malloc.c __mktemp4.c mkdtemp.c \
merge.c posix_pty.c qsort.c radixsort.c rand.c random.c \ mkstemp.c mktemp.c reallocarray.c merge.c posix_pty.c qsort.c \
realpath.c remque.c setenv.c strtoimax.c \ radixsort.c rand.c random.c realpath.c remque.c setenv.c strtoimax.c \
strtol.c strtoll.c strtonum.c strtoul.c strtoull.c strtoumax.c \ strtol.c strtoll.c strtonum.c strtoul.c strtoull.c strtoumax.c \
system.c \ system.c \
tfind.c thread_atexit.c tsearch.c \ tfind.c thread_atexit.c tsearch.c \
@ -28,6 +28,6 @@ SRCS+= abs.c div.c labs.c ldiv.c
MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \ MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \
bsearch.3 div.3 ecvt.3 exit.3 getenv.3 getopt.3 getopt_long.3 \ bsearch.3 div.3 ecvt.3 exit.3 getenv.3 getopt.3 getopt_long.3 \
getsubopt.3 hcreate.3 imaxabs.3 imaxdiv.3 insque.3 labs.3 ldiv.3 \ getsubopt.3 hcreate.3 imaxabs.3 imaxdiv.3 insque.3 labs.3 ldiv.3 \
lldiv.3 lsearch.3 malloc.3 posix_memalign.3 posix_openpt.3 ptsname.3 \ lldiv.3 lsearch.3 malloc.3 mktemp.3 posix_memalign.3 posix_openpt.3 \
qsort.3 radixsort.3 rand48.3 rand.3 random.3 realpath.3 \ ptsname.3 qsort.3 radixsort.3 rand48.3 rand.3 random.3 realpath.3 \
strtod.3 strtonum.3 strtol.3 strtoul.3 system.3 tsearch.3 strtod.3 strtonum.3 strtol.3 strtoul.3 system.3 tsearch.3

View File

@ -1,7 +1,7 @@
/* $OpenBSD: mktemp.c,v 1.39 2017/11/28 06:55:49 tb Exp $ */ /* $OpenBSD: __mktemp4.c,v 1.1 2024/01/19 19:45:02 millert Exp $ */
/* /*
* Copyright (c) 1996-1998, 2008 Theo de Raadt * Copyright (c) 1996-1998, 2008 Theo de Raadt
* Copyright (c) 1997, 2008-2009 Todd C. Miller * Copyright (c) 1997, 2008-2009, 2024 Todd C. Miller
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -16,45 +16,37 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h>
#include <unistd.h>
#define MKTEMP_NAME 0
#define MKTEMP_FILE 1
#define MKTEMP_DIR 2
#define TEMPCHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" #define TEMPCHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
#define NUM_CHARS (sizeof(TEMPCHARS) - 1) #define NUM_CHARS (sizeof(TEMPCHARS) - 1)
#define MIN_X 6 #define MIN_X 6
#define MKOTEMP_FLAGS (O_APPEND | O_CLOEXEC | O_DSYNC | O_RSYNC | O_SYNC)
#ifndef nitems #ifndef nitems
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
#endif #endif
static int /*
mktemp_internal(char *path, int slen, int mode, int flags) * Internal driver for the mktemp(3) family of functions.
* The supplied callback does the actual work of testing or
* creating the file/directory.
*/
int
__mktemp4(char *path, int slen, int flags, int (*cb)(const char *, int))
{ {
char *start, *cp, *ep; char *start, *cp, *ep;
const char tempchars[] = TEMPCHARS; const char tempchars[] = TEMPCHARS;
unsigned int tries; unsigned int tries;
struct stat sb;
size_t len; size_t len;
int fd; int ret;
len = strlen(path); len = strlen(path);
if (len < MIN_X || slen < 0 || (size_t)slen > len - MIN_X) { if (len < MIN_X || slen < 0 || (size_t)slen > len - MIN_X) {
errno = EINVAL; errno = EINVAL;
return(-1); return -1;
} }
ep = path + len - slen; ep = path + len - slen;
@ -62,15 +54,9 @@ mktemp_internal(char *path, int slen, int mode, int flags)
; ;
if (ep - start < MIN_X) { if (ep - start < MIN_X) {
errno = EINVAL; errno = EINVAL;
return(-1); return -1;
} }
if (flags & ~MKOTEMP_FLAGS) {
errno = EINVAL;
return(-1);
}
flags |= O_CREAT | O_EXCL | O_RDWR;
tries = INT_MAX; tries = INT_MAX;
do { do {
cp = start; cp = start;
@ -87,77 +73,11 @@ mktemp_internal(char *path, int slen, int mode, int flags)
*cp++ = tempchars[rbuf[i] % NUM_CHARS]; *cp++ = tempchars[rbuf[i] % NUM_CHARS];
} while (cp != ep); } while (cp != ep);
switch (mode) { ret = cb(path, flags);
case MKTEMP_NAME: if (ret != -1 || errno != EEXIST)
if (lstat(path, &sb) != 0) return ret;
return(errno == ENOENT ? 0 : -1);
break;
case MKTEMP_FILE:
fd = open(path, flags, S_IRUSR|S_IWUSR);
if (fd != -1 || errno != EEXIST)
return(fd);
break;
case MKTEMP_DIR:
if (mkdir(path, S_IRUSR|S_IWUSR|S_IXUSR) == 0)
return(0);
if (errno != EEXIST)
return(-1);
break;
}
} while (--tries); } while (--tries);
errno = EEXIST; errno = EEXIST;
return(-1); return -1;
}
char *
_mktemp(char *path)
{
if (mktemp_internal(path, 0, MKTEMP_NAME, 0) == -1)
return(NULL);
return(path);
}
__warn_references(mktemp,
"mktemp() possibly used unsafely; consider using mkstemp()");
char *
mktemp(char *path)
{
return(_mktemp(path));
}
int
mkostemps(char *path, int slen, int flags)
{
return(mktemp_internal(path, slen, MKTEMP_FILE, flags));
}
int
mkstemp(char *path)
{
return(mktemp_internal(path, 0, MKTEMP_FILE, 0));
}
DEF_WEAK(mkstemp);
int
mkostemp(char *path, int flags)
{
return(mktemp_internal(path, 0, MKTEMP_FILE, flags));
}
DEF_WEAK(mkostemp);
int
mkstemps(char *path, int slen)
{
return(mktemp_internal(path, slen, MKTEMP_FILE, 0));
}
char *
mkdtemp(char *path)
{
int error;
error = mktemp_internal(path, 0, MKTEMP_DIR, 0);
return(error ? NULL : path);
} }

33
lib/libc/stdlib/mkdtemp.c Normal file
View File

@ -0,0 +1,33 @@
/* $OpenBSD: mkdtemp.c,v 1.1 2024/01/19 19:45:02 millert Exp $ */
/*
* Copyright (c) 2024 Todd C. Miller
*
* 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.
*/
#include <sys/stat.h>
#include <stdlib.h>
static int
mkdtemp_cb(const char *path, int flags)
{
return mkdir(path, S_IRUSR|S_IWUSR|S_IXUSR);
}
char *
mkdtemp(char *path)
{
if (__mktemp4(path, 0, 0, mkdtemp_cb) == 0)
return path;
return NULL;
}

64
lib/libc/stdlib/mkstemp.c Normal file
View File

@ -0,0 +1,64 @@
/* $OpenBSD: mkstemp.c,v 1.1 2024/01/19 19:45:02 millert Exp $ */
/*
* Copyright (c) 2024 Todd C. Miller
*
* 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.
*/
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#define MKOSTEMP_FLAGS (O_APPEND | O_CLOEXEC | O_DSYNC | O_RSYNC | O_SYNC)
static int
mkstemp_cb(const char *path, int flags)
{
flags |= O_CREAT | O_EXCL | O_RDWR;
return open(path, flags, S_IRUSR|S_IWUSR);
}
int
mkostemps(char *path, int slen, int flags)
{
if (flags & ~MKOSTEMP_FLAGS) {
errno = EINVAL;
return -1;
}
return __mktemp4(path, slen, flags, mkstemp_cb);
}
int
mkostemp(char *path, int flags)
{
if (flags & ~MKOSTEMP_FLAGS) {
errno = EINVAL;
return -1;
}
return __mktemp4(path, 0, flags, mkstemp_cb);
}
DEF_WEAK(mkostemp);
int
mkstemp(char *path)
{
return __mktemp4(path, 0, 0, mkstemp_cb);
}
DEF_WEAK(mkstemp);
int
mkstemps(char *path, int slen)
{
return __mktemp4(path, slen, 0, mkstemp_cb);
}

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: mktemp.3,v 1.56 2022/08/04 06:20:24 jsg Exp $ .\" $OpenBSD: mktemp.3,v 1.1 2024/01/19 16:30:28 millert Exp $
.\" .\"
.\" Copyright (c) 1989, 1991, 1993 .\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.Dd $Mdocdate: August 4 2022 $ .Dd $Mdocdate: January 19 2024 $
.Dt MKTEMP 3 .Dt MKTEMP 3
.Os .Os
.Sh NAME .Sh NAME

48
lib/libc/stdlib/mktemp.c Normal file
View File

@ -0,0 +1,48 @@
/* $OpenBSD: mktemp.c,v 1.2 2024/01/19 19:45:02 millert Exp $ */
/*
* Copyright (c) 2024 Todd C. Miller
*
* 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.
*/
#include <sys/stat.h>
#include <errno.h>
#include <stdlib.h>
static int
mktemp_cb(const char *path, int flags)
{
struct stat sb;
if (lstat(path, &sb) == 0)
errno = EEXIST;
return (errno == ENOENT ? 0 : -1);
}
/* Also called via tmpnam(3) and tempnam(3). */
char *
_mktemp(char *path)
{
if (__mktemp4(path, 0, 0, mktemp_cb) == 0)
return path;
return NULL;
}
__warn_references(mktemp,
"mktemp() possibly used unsafely; consider using mkstemp()");
char *
mktemp(char *path)
{
return _mktemp(path);
}

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile.inc,v 1.176 2023/12/12 15:30:55 deraadt Exp $ # $OpenBSD: Makefile.inc,v 1.177 2024/01/19 14:15:51 deraadt Exp $
# $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $ # $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $
# @(#)Makefile.inc 8.1 (Berkeley) 6/17/93 # @(#)Makefile.inc 8.1 (Berkeley) 6/17/93
@ -23,23 +23,6 @@ SRCS+= ptrace.c semctl.c \
# stack protector helper functions # stack protector helper functions
SRCS+= stack_protector.c SRCS+= stack_protector.c
# Extract execve stub size for static binary pinsyscall(2) in dlfcn/init.c
SRCS+= _execvesize.c
CLEANFILES+=_execvesize.c
_execvesize.c: execve.o execve.po
readelf -s execve.po | awk \
'/ execve$$/{ printf("#ifdef _PROFILE\nconst int _execve_size = %d;\n", $$3); }' > $@
readelf -s execve.o | awk \
'/ execve$$/{ printf("#else\nconst int _execve_size = %d;\n#endif\n", $$3); }' >> $@
# _libc_preinit() needs to know if compiled with or without profiling
_execvesize.po:
@echo "${COMPILE.c} -D_PROFILE ${.IMPSRC} -o ${.TARGET}"
@${COMPILE.c} ${DFLAGS} -D_PROFILE ${.IMPSRC} -o ${.TARGET}.o
@-mv $@.d $*.d
@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
@rm -f ${.TARGET}.o
# cancelation details # cancelation details
SRCS+= canceled.c SRCS+= canceled.c
@ -79,7 +62,7 @@ ASM= __semctl.o __thrsigdivert.o \
mknod.o mknodat.o mlock.o mlockall.o mmap.o mount.o mprotect.o \ mknod.o mknodat.o mlock.o mlockall.o mmap.o mount.o mprotect.o \
mquery.o msgctl.o msgget.o munlock.o munlockall.o munmap.o \ mquery.o msgctl.o msgget.o munlock.o munlockall.o munmap.o \
nfssvc.o \ nfssvc.o \
pathconf.o pipe.o pipe2.o pinsyscall.o pledge.o profil.o \ pathconf.o pipe.o pipe2.o pledge.o profil.o \
quotactl.o \ quotactl.o \
readlink.o readlinkat.o reboot.o \ readlink.o readlinkat.o reboot.o \
rename.o renameat.o revoke.o rmdir.o \ rename.o renameat.o revoke.o rmdir.o \
@ -208,7 +191,7 @@ MAN+= __get_tcb.2 __thrsigdivert.2 __thrsleep.2 _exit.2 accept.2 \
mimmutable.2 minherit.2 mkdir.2 mkfifo.2 mknod.2 mlock.2 \ mimmutable.2 minherit.2 mkdir.2 mkfifo.2 mknod.2 mlock.2 \
mlockall.2 mmap.2 mount.2 mprotect.2 mquery.2 msyscall.2 msgctl.2 \ mlockall.2 mmap.2 mount.2 mprotect.2 mquery.2 msyscall.2 msgctl.2 \
msgget.2 msgrcv.2 msgsnd.2 msync.2 munmap.2 nanosleep.2 \ msgget.2 msgrcv.2 msgsnd.2 msync.2 munmap.2 nanosleep.2 \
nfssvc.2 open.2 pathconf.2 pinsyscall.2 pinsyscalls.2 pipe.2 pledge.2 \ nfssvc.2 open.2 pathconf.2 pinsyscalls.2 pipe.2 pledge.2 \
poll.2 profil.2 ptrace.2 quotactl.2 read.2 readlink.2 reboot.2 recv.2 \ poll.2 profil.2 ptrace.2 quotactl.2 read.2 readlink.2 reboot.2 recv.2 \
rename.2 revoke.2 rmdir.2 sched_yield.2 select.2 semctl.2 semget.2 \ rename.2 revoke.2 rmdir.2 sched_yield.2 select.2 semctl.2 semget.2 \
semop.2 send.2 setgroups.2 setpgid.2 setregid.2 \ semop.2 send.2 setgroups.2 setpgid.2 setregid.2 \

View File

@ -1,4 +1,4 @@
/* $OpenBSD: radius.h,v 1.2 2023/07/08 08:53:26 yasuoka Exp $ */ /* $OpenBSD: radius.h,v 1.3 2024/01/19 06:32:28 yasuoka Exp $ */
/*- /*-
* Copyright (c) 2009 Internet Initiative Japan Inc. * Copyright (c) 2009 Internet Initiative Japan Inc.
@ -141,7 +141,14 @@
#define RADIUS_TYPE_FRAMED_IPV6_PREFIX 97 #define RADIUS_TYPE_FRAMED_IPV6_PREFIX 97
#define RADIUS_TYPE_LOGIN_IPV6_HOST 98 #define RADIUS_TYPE_LOGIN_IPV6_HOST 98
#define RADIUS_TYPE_FRAMED_IPV6_ROUTE 99 #define RADIUS_TYPE_FRAMED_IPV6_ROUTE 99
#define RADIUS_TYPE_FRAMED_IPV6_POOL 100 #define RADIUS_TYPE_FRAMED_IPV6_POOL 100
/* RFC 6911 3. Attributes */
#define RADIUS_TYPE_FRAMED_IPV6_ADDRESS 168
#define RADIUS_TYPE_DNS_SERVER_IPV6_ADDRESS 169
#define RADIUS_TYPE_ROUTE_IPV6_INFORMATION 170
#define RADIUS_TYPE_DELEGATED_IPV6_PREFIX_POOL 171
#define RADIUS_TYPE_STATEFUL_IPV6_ADDRESS_POOL 172
/* RFC 2865 5.7. Framed-Protocol */ /* RFC 2865 5.7. Framed-Protocol */

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.86 2023/12/20 14:54:29 deraadt Exp $ # $OpenBSD: Makefile,v 1.87 2024/01/19 14:16:41 deraadt Exp $
SUBDIR=ldconfig ldd SUBDIR=ldconfig ldd
MAN= ld.so.1 MAN= ld.so.1
@ -28,7 +28,7 @@ SRCS+= dl_uname.c dl_dirname.c strlcat.c strlen.c trace.c
SRCS+= malloc.c reallocarray.c tib.c ffs.c SRCS+= malloc.c reallocarray.c tib.c ffs.c
syscall=close exit fstat getdents getentropy getthrid issetugid kbind \ syscall=close exit fstat getdents getentropy getthrid issetugid kbind \
mimmutable mmap mprotect munmap msyscall open pledge pinsyscall \ mimmutable mmap mprotect munmap msyscall open pledge \
pinsyscalls read __realpath sendsyslog __set_tcb sysctl thrkill \ pinsyscalls read __realpath sendsyslog __set_tcb sysctl thrkill \
utrace write utrace write

View File

@ -1,4 +1,4 @@
/* $OpenBSD: loader.c,v 1.221 2024/01/17 13:00:05 deraadt Exp $ */ /* $OpenBSD: loader.c,v 1.222 2024/01/19 14:16:41 deraadt Exp $ */
/* /*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB * Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@ -317,7 +317,7 @@ _dl_setup_env(const char *argv0, char **envp)
int int
_dl_load_dep_libs(elf_object_t *object, int flags, int booting) _dl_load_dep_libs(elf_object_t *object, int flags, int booting)
{ {
elf_object_t *dynobj, *obj; elf_object_t *dynobj;
Elf_Dyn *dynp; Elf_Dyn *dynp;
unsigned int loop; unsigned int loop;
int libcount; int libcount;
@ -439,25 +439,6 @@ _dl_load_dep_libs(elf_object_t *object, int flags, int booting)
} }
_dl_cache_grpsym_list_setup(object); _dl_cache_grpsym_list_setup(object);
/*
* XXX pinsyscall(SYS_execve,...) can be removed once pinsyscalls()
* is fully operational
*/
for (obj = _dl_objects; booting && obj != NULL; obj = obj->next) {
struct sym_res sr;
if (!obj->islibc)
continue;
sr = _dl_find_symbol("execve",
SYM_SEARCH_SELF|SYM_PLT|SYM_WARNNOTFOUND, NULL, obj);
if (sr.sym)
_dl_pinsyscall(SYS_execve,
(void *)sr.obj->obj_base + sr.sym->st_value,
sr.sym->st_size);
_dl_memset(&sr, 0, sizeof sr);
break;
}
return(0); return(0);
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: syscall.h,v 1.6 2023/12/20 14:54:29 deraadt Exp $ */ /* $OpenBSD: syscall.h,v 1.7 2024/01/19 14:16:42 deraadt Exp $ */
/* /*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB * Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@ -51,7 +51,6 @@ void *_dl_mmap(void *, size_t, int, int, int, off_t);
int _dl_mprotect(const void *, size_t, int); int _dl_mprotect(const void *, size_t, int);
void *_dl_mquery(void *, size_t, int, int, int, off_t); void *_dl_mquery(void *, size_t, int, int, int, off_t);
int _dl_msyscall(void *addr, size_t len); int _dl_msyscall(void *addr, size_t len);
int _dl_pinsyscall(int, void *addr, size_t len);
int _dl_pinsyscalls(void *base, size_t len, u_int *pin, int pinlen); int _dl_pinsyscalls(void *base, size_t len, u_int *pin, int pinlen);
int _dl_munmap(const void *, size_t); int _dl_munmap(const void *, size_t);
int _dl_mimmutable(const void *, size_t); int _dl_mimmutable(const void *, size_t);

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.54 2023/07/15 19:32:54 tb Exp $ # $OpenBSD: Makefile,v 1.55 2024/01/19 08:29:26 jsing Exp $
SUBDIR += api SUBDIR += api
SUBDIR += asn1 SUBDIR += asn1
@ -14,6 +14,7 @@ SUBDIR += quic
SUBDIR += record SUBDIR += record
SUBDIR += record_layer SUBDIR += record_layer
SUBDIR += server SUBDIR += server
SUBDIR += shutdown
SUBDIR += ssl SUBDIR += ssl
SUBDIR += symbols SUBDIR += symbols
SUBDIR += tls SUBDIR += tls

View File

@ -0,0 +1,18 @@
# $OpenBSD: Makefile,v 1.1 2024/01/19 08:29:08 jsing Exp $
PROG= shutdowntest
LDADD= -lssl -lcrypto
DPADD= ${LIBSSL} ${LIBCRYPTO}
WARNINGS= Yes
CFLAGS+= -DLIBRESSL_INTERNAL -Werror
REGRESS_TARGETS= \
regress-shutdowntest
regress-shutdowntest: ${PROG}
./shutdowntest \
${.CURDIR}/../../libssl/certs/server.pem \
${.CURDIR}/../../libssl/certs/server.pem \
${.CURDIR}/../../libssl/certs/ca.pem
.include <bsd.regress.mk>

View File

@ -0,0 +1,528 @@
/* $OpenBSD: shutdowntest.c,v 1.1 2024/01/19 08:29:08 jsing Exp $ */
/*
* Copyright (c) 2020, 2021, 2024 Joel Sing <jsing@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.
*/
#include <err.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
const char *server_ca_file;
const char *server_cert_file;
const char *server_key_file;
int debug = 0;
static void
hexdump(const unsigned char *buf, size_t len)
{
size_t i;
for (i = 1; i <= len; i++)
fprintf(stderr, " 0x%02hhx,%s", buf[i - 1], i % 8 ? "" : "\n");
if (len % 8)
fprintf(stderr, "\n");
}
static SSL *
tls_client(BIO *rbio, BIO *wbio)
{
SSL_CTX *ssl_ctx = NULL;
SSL *ssl = NULL;
if ((ssl_ctx = SSL_CTX_new(TLS_method())) == NULL)
errx(1, "client context");
if ((ssl = SSL_new(ssl_ctx)) == NULL)
errx(1, "client ssl");
BIO_up_ref(rbio);
BIO_up_ref(wbio);
SSL_set_bio(ssl, rbio, wbio);
SSL_CTX_free(ssl_ctx);
return ssl;
}
static SSL *
tls_server(BIO *rbio, BIO *wbio)
{
SSL_CTX *ssl_ctx = NULL;
SSL *ssl = NULL;
if ((ssl_ctx = SSL_CTX_new(TLS_method())) == NULL)
errx(1, "server context");
SSL_CTX_set_dh_auto(ssl_ctx, 2);
if (SSL_CTX_use_certificate_file(ssl_ctx, server_cert_file,
SSL_FILETYPE_PEM) != 1) {
fprintf(stderr, "FAIL: Failed to load server certificate");
goto failure;
}
if (SSL_CTX_use_PrivateKey_file(ssl_ctx, server_key_file,
SSL_FILETYPE_PEM) != 1) {
fprintf(stderr, "FAIL: Failed to load server private key");
goto failure;
}
if ((ssl = SSL_new(ssl_ctx)) == NULL)
errx(1, "server ssl");
BIO_up_ref(rbio);
BIO_up_ref(wbio);
SSL_set_bio(ssl, rbio, wbio);
failure:
SSL_CTX_free(ssl_ctx);
return ssl;
}
static int
ssl_error(SSL *ssl, const char *name, const char *desc, int ssl_ret)
{
int ssl_err;
ssl_err = SSL_get_error(ssl, ssl_ret);
if (ssl_err == SSL_ERROR_WANT_READ) {
return 1;
} else if (ssl_err == SSL_ERROR_WANT_WRITE) {
return 1;
} else if (ssl_err == SSL_ERROR_SYSCALL && errno == 0) {
/* Yup, this is apparently a thing... */
return 1;
} else {
fprintf(stderr, "FAIL: %s %s failed - ssl err = %d, errno = %d\n",
name, desc, ssl_err, errno);
ERR_print_errors_fp(stderr);
return 0;
}
}
static int
do_connect(SSL *ssl, const char *name, int *done)
{
int ssl_ret;
if ((ssl_ret = SSL_connect(ssl)) == 1) {
fprintf(stderr, "INFO: %s connect done\n", name);
*done = 1;
return 1;
}
return ssl_error(ssl, name, "connect", ssl_ret);
}
static int
do_accept(SSL *ssl, const char *name, int *done)
{
int ssl_ret;
if ((ssl_ret = SSL_accept(ssl)) == 1) {
fprintf(stderr, "INFO: %s accept done\n", name);
*done = 1;
return 1;
}
return ssl_error(ssl, name, "accept", ssl_ret);
}
static int
do_read(SSL *ssl, const char *name, int *done)
{
uint8_t buf[512];
int ssl_ret;
if ((ssl_ret = SSL_read(ssl, buf, sizeof(buf))) > 0) {
fprintf(stderr, "INFO: %s read done\n", name);
if (debug > 1)
hexdump(buf, ssl_ret);
*done = 1;
return 1;
}
return ssl_error(ssl, name, "read", ssl_ret);
}
static int
do_write(SSL *ssl, const char *name, int *done)
{
const uint8_t buf[] = "Hello, World!\n";
int ssl_ret;
if ((ssl_ret = SSL_write(ssl, buf, sizeof(buf))) > 0) {
fprintf(stderr, "INFO: %s write done\n", name);
*done = 1;
return 1;
}
return ssl_error(ssl, name, "write", ssl_ret);
}
static int
do_shutdown(SSL *ssl, const char *name, int *done)
{
int ssl_ret;
ssl_ret = SSL_shutdown(ssl);
if (ssl_ret == 1) {
fprintf(stderr, "INFO: %s shutdown done\n", name);
*done = 1;
return 1;
}
/* The astounding EOF condition. */
if (ssl_ret == -1 &&
SSL_get_error(ssl, ssl_ret) == SSL_ERROR_SYSCALL && errno == 0) {
fprintf(stderr, "INFO: %s shutdown encountered EOF\n", name);
*done = 1;
return 1;
}
return ssl_error(ssl, name, "shutdown", ssl_ret);
}
typedef int (*ssl_func)(SSL *ssl, const char *name, int *done);
static int
do_client_server_loop(SSL *client, ssl_func client_func, SSL *server,
ssl_func server_func)
{
int client_done = 0, server_done = 0;
int i = 0;
do {
if (!client_done) {
if (debug)
fprintf(stderr, "DEBUG: client loop\n");
if (!client_func(client, "client", &client_done))
return 0;
}
if (!server_done) {
if (debug)
fprintf(stderr, "DEBUG: server loop\n");
if (!server_func(server, "server", &server_done))
return 0;
}
} while (i++ < 100 && (!client_done || !server_done));
if (!client_done || !server_done)
fprintf(stderr, "FAIL: gave up\n");
return client_done && server_done;
}
static int
do_shutdown_loop(SSL *client, SSL *server)
{
int client_done = 0, server_done = 0;
int i = 0;
do {
if (!client_done) {
if (debug)
fprintf(stderr, "DEBUG: client loop\n");
if (!do_shutdown(client, "client", &client_done))
return 0;
if (client_done)
BIO_set_mem_eof_return(SSL_get_wbio(client), 0);
}
if (!server_done) {
if (debug)
fprintf(stderr, "DEBUG: server loop\n");
if (!do_shutdown(server, "server", &server_done))
return 0;
if (server_done)
BIO_set_mem_eof_return(SSL_get_wbio(server), 0);
}
} while (i++ < 100 && (!client_done || !server_done));
if (!client_done || !server_done)
fprintf(stderr, "FAIL: gave up\n");
return client_done && server_done;
}
static void
ssl_msg_callback(int is_write, int version, int content_type, const void *buf,
size_t len, SSL *ssl, void *arg)
{
const uint8_t *msg = buf;
int *close_notify = arg;
if (is_write || content_type != SSL3_RT_ALERT)
return;
if (len == 2 && msg[0] == SSL3_AL_WARNING && msg[1] == SSL_AD_CLOSE_NOTIFY)
*close_notify = 1;
}
struct shutdown_test {
const unsigned char *desc;
int client_quiet_shutdown;
int client_set_shutdown;
int want_client_shutdown;
int want_client_close_notify;
int server_quiet_shutdown;
int server_set_shutdown;
int want_server_shutdown;
int want_server_close_notify;
};
static const struct shutdown_test shutdown_tests[] = {
{
.desc = "bidirectional shutdown",
.want_client_close_notify = 1,
.want_client_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
.want_server_close_notify = 1,
.want_server_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
},
{
.desc = "client quiet shutdown",
.client_quiet_shutdown = 1,
.want_client_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
.want_server_shutdown = SSL_SENT_SHUTDOWN,
},
{
.desc = "server quiet shutdown",
.server_quiet_shutdown = 1,
.want_client_shutdown = SSL_SENT_SHUTDOWN,
.want_server_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
},
{
.desc = "both quiet shutdown",
.client_quiet_shutdown = 1,
.server_quiet_shutdown = 1,
.want_client_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
.want_server_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
},
{
.desc = "client set sent shutdown",
.client_set_shutdown = SSL_SENT_SHUTDOWN,
.want_client_close_notify = 1,
.want_client_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
.want_server_shutdown = SSL_SENT_SHUTDOWN,
},
{
.desc = "client set received shutdown",
.client_set_shutdown = SSL_RECEIVED_SHUTDOWN,
.want_client_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
.want_server_close_notify = 1,
.want_server_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
},
{
.desc = "client set sent/received shutdown",
.client_set_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
.want_client_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
.want_server_shutdown = SSL_SENT_SHUTDOWN,
},
{
.desc = "server set sent shutdown",
.server_set_shutdown = SSL_SENT_SHUTDOWN,
.want_client_shutdown = SSL_SENT_SHUTDOWN,
.want_server_close_notify = 1,
.want_server_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
},
{
.desc = "server set received shutdown",
.server_set_shutdown = SSL_RECEIVED_SHUTDOWN,
.want_client_close_notify = 1,
.want_client_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
.want_server_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
},
{
.desc = "server set sent/received shutdown",
.server_set_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
.want_client_shutdown = SSL_SENT_SHUTDOWN,
.want_server_shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN,
},
};
#define N_TLS_TESTS (sizeof(shutdown_tests) / sizeof(*shutdown_tests))
static int
shutdowntest(uint16_t ssl_version, const char *ssl_version_name,
const struct shutdown_test *st)
{
BIO *client_wbio = NULL, *server_wbio = NULL;
SSL *client = NULL, *server = NULL;
int client_close_notify = 0, server_close_notify = 0;
int shutdown, ssl_err;
int failed = 1;
fprintf(stderr, "\n== Testing %s, %s... ==\n", ssl_version_name,
st->desc);
if ((client_wbio = BIO_new(BIO_s_mem())) == NULL)
goto failure;
if (BIO_set_mem_eof_return(client_wbio, -1) <= 0)
goto failure;
if ((server_wbio = BIO_new(BIO_s_mem())) == NULL)
goto failure;
if (BIO_set_mem_eof_return(server_wbio, -1) <= 0)
goto failure;
if ((client = tls_client(server_wbio, client_wbio)) == NULL)
goto failure;
if (!SSL_set_min_proto_version(client, ssl_version))
goto failure;
if (!SSL_set_max_proto_version(client, ssl_version))
goto failure;
if ((server = tls_server(client_wbio, server_wbio)) == NULL)
goto failure;
if (!SSL_set_min_proto_version(server, ssl_version))
goto failure;
if (!SSL_set_max_proto_version(server, ssl_version))
goto failure;
if (!do_client_server_loop(client, do_connect, server, do_accept)) {
fprintf(stderr, "FAIL: client and server handshake failed\n");
goto failure;
}
if (!do_client_server_loop(client, do_write, server, do_read)) {
fprintf(stderr, "FAIL: client write and server read I/O failed\n");
goto failure;
}
if (!do_client_server_loop(client, do_read, server, do_write)) {
fprintf(stderr, "FAIL: client read and server write I/O failed\n");
goto failure;
}
/* Seemingly this is the only way to find out about alerts... */
SSL_set_msg_callback(client, ssl_msg_callback);
SSL_set_msg_callback_arg(client, &client_close_notify);
SSL_set_msg_callback(server, ssl_msg_callback);
SSL_set_msg_callback_arg(server, &server_close_notify);
SSL_set_shutdown(client, st->client_set_shutdown);
SSL_set_shutdown(server, st->server_set_shutdown);
SSL_set_quiet_shutdown(client, st->client_quiet_shutdown);
SSL_set_quiet_shutdown(server, st->server_quiet_shutdown);
if (!do_shutdown_loop(client, server)) {
fprintf(stderr, "FAIL: client and server shutdown failed\n");
goto failure;
}
if ((shutdown = SSL_get_shutdown(client)) != st->want_client_shutdown) {
fprintf(stderr, "FAIL: client shutdown flags = %x, want %x\n",
shutdown, st->want_client_shutdown);
goto failure;
}
if ((shutdown = SSL_get_shutdown(server)) != st->want_server_shutdown) {
fprintf(stderr, "FAIL: server shutdown flags = %x, want %x\n",
shutdown, st->want_server_shutdown);
goto failure;
}
if (client_close_notify != st->want_client_close_notify) {
fprintf(stderr, "FAIL: client close notify = %d, want %d\n",
client_close_notify, st->want_client_close_notify);
goto failure;
}
if (server_close_notify != st->want_server_close_notify) {
fprintf(stderr, "FAIL: server close notify = %d, want %d\n",
server_close_notify, st->want_server_close_notify);
goto failure;
}
if (st->want_client_close_notify) {
if ((ssl_err = SSL_get_error(client, 0)) != SSL_ERROR_ZERO_RETURN) {
fprintf(stderr, "FAIL: client ssl error = %d, want %d\n",
ssl_err, SSL_ERROR_ZERO_RETURN);
goto failure;
}
}
if (st->want_server_close_notify) {
if ((ssl_err = SSL_get_error(server, 0)) != SSL_ERROR_ZERO_RETURN) {
fprintf(stderr, "FAIL: server ssl error = %d, want %d\n",
ssl_err, SSL_ERROR_ZERO_RETURN);
goto failure;
}
}
fprintf(stderr, "INFO: Done!\n");
failed = 0;
failure:
BIO_free(client_wbio);
BIO_free(server_wbio);
SSL_free(client);
SSL_free(server);
return failed;
}
struct ssl_version {
uint16_t version;
const char *name;
};
struct ssl_version ssl_versions[] = {
{
.version = TLS1_2_VERSION,
.name = SSL_TXT_TLSV1_2,
},
#if 0
{
.version = TLS1_3_VERSION,
.name = SSL_TXT_TLSV1_3,
},
#endif
};
#define N_SSL_VERSIONS (sizeof(ssl_versions) / sizeof(*ssl_versions))
int
main(int argc, char **argv)
{
const struct ssl_version *sv;
int failed = 0;
size_t i, j;
if (argc != 4) {
fprintf(stderr, "usage: %s keyfile certfile cafile\n",
argv[0]);
exit(1);
}
server_key_file = argv[1];
server_cert_file = argv[2];
server_ca_file = argv[3];
for (i = 0; i < N_SSL_VERSIONS; i++) {
sv = &ssl_versions[i];
for (j = 0; j < N_TLS_TESTS; j++) {
failed |= shutdowntest(sv->version, sv->name,
&shutdown_tests[j]);
}
}
return failed;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.69 2020/10/01 17:29:39 kettenis Exp $ */ /* $OpenBSD: util.c,v 1.70 2024/01/19 17:51:15 kettenis Exp $ */
/* $NetBSD: util.c,v 1.8 2000/03/14 08:11:53 sato Exp $ */ /* $NetBSD: util.c,v 1.8 2000/03/14 08:11:53 sato Exp $ */
/*- /*-
@ -171,7 +171,7 @@ static const struct nameint dpytype_tab[] = {
{ WSDISPLAY_TYPE_INTELDRM, "inteldrm" }, { WSDISPLAY_TYPE_INTELDRM, "inteldrm" },
{ WSDISPLAY_TYPE_RADEONDRM, "radeondrm" }, { WSDISPLAY_TYPE_RADEONDRM, "radeondrm" },
{ WSDISPLAY_TYPE_EFIFB, "efifb" }, { WSDISPLAY_TYPE_EFIFB, "efifb" },
{ WSDISPLAY_TYPE_RKDRM, "rkdrm" }, { WSDISPLAY_TYPE_KMS, "kms" },
{ WSDISPLAY_TYPE_ASTFB, "astfb" } { WSDISPLAY_TYPE_ASTFB, "astfb" }
}; };

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: extent.9,v 1.19 2015/11/01 21:26:48 jmc Exp $ .\" $OpenBSD: extent.9,v 1.20 2024/01/19 22:12:24 kettenis Exp $
.\" $NetBSD: extent.9,v 1.15 1999/03/16 00:40:47 garbled Exp $ .\" $NetBSD: extent.9,v 1.15 1999/03/16 00:40:47 garbled Exp $
.\" .\"
.\" Copyright (c) 1996, 1998 The NetBSD Foundation, Inc. .\" Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@ -28,7 +28,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE. .\" POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd $Mdocdate: November 1 2015 $ .Dd $Mdocdate: January 19 2024 $
.Dt EXTENT 9 .Dt EXTENT 9
.Os .Os
.Sh NAME .Sh NAME
@ -39,6 +39,7 @@
.Nm extent_alloc_subregion , .Nm extent_alloc_subregion ,
.Nm extent_alloc_subregion_with_descr , .Nm extent_alloc_subregion_with_descr ,
.Nm extent_alloc_region , .Nm extent_alloc_region ,
.Nm extent_alloc_region_with_descr ,
.Nm extent_free , .Nm extent_free ,
.Nm extent_print .Nm extent_print
.Nd general purpose extent manager .Nd general purpose extent manager
@ -83,6 +84,8 @@
.Ft int .Ft int
.Fn extent_alloc_region "struct extent *ex" "u_long start" "u_long size" "int flags" .Fn extent_alloc_region "struct extent *ex" "u_long start" "u_long size" "int flags"
.Ft int .Ft int
.Fn extent_alloc_region_with_descr "struct extent *ex" "u_long start" "u_long size" "int flags" "struct extent_region *rp"
.Ft int
.Fn extent_free "struct extent *ex" "u_long start" "u_long size" "int flags" .Fn extent_free "struct extent *ex" "u_long start" "u_long size" "int flags"
.Ft void .Ft void
.Fn extent_print "struct extent *ex" .Fn extent_print "struct extent *ex"
@ -290,6 +293,15 @@ nor
is set, the allocation will fail if the request cannot be is set, the allocation will fail if the request cannot be
satisfied without sleeping. satisfied without sleeping.
.Pp .Pp
.Fn extent_alloc_region_with_descr
is similar to
.Fn extent_alloc_region
but allows the caller to provide a pre-allocated region descriptor instead
of having the function allocate one.
This function can only be used with extents that have the
.Dv EX_NOCOALESCE
property.
.Pp
.Fn extent_free .Fn extent_free
frees a region of frees a region of
.Fa size .Fa size

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: malloc.9,v 1.71 2023/12/19 14:40:04 deraadt Exp $ .\" $OpenBSD: malloc.9,v 1.72 2024/01/19 15:10:27 deraadt Exp $
.\" $NetBSD: malloc.9,v 1.2 1996/10/30 05:29:54 lukem Exp $ .\" $NetBSD: malloc.9,v 1.2 1996/10/30 05:29:54 lukem Exp $
.\" .\"
.\" Copyright (c) 1996 The NetBSD Foundation, Inc. .\" Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -28,7 +28,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE. .\" POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd $Mdocdate: December 19 2023 $ .Dd $Mdocdate: January 19 2024 $
.Dt MALLOC 9 .Dt MALLOC 9
.Os .Os
.Sh NAME .Sh NAME
@ -239,7 +239,7 @@ Miscellaneous FS mount structures.
.It Dv M_FUSEFS .It Dv M_FUSEFS
FUSE FS mount structures. FUSE FS mount structures.
.It Dv M_PINSYSCALL .It Dv M_PINSYSCALL
.Xr pinsyscall 2 .Xr pinsyscalls 2
related data. related data.
.It Dv M_PFKEY .It Dv M_PFKEY
Pfkey data. Pfkey data.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: i8259.c,v 1.11 2018/07/27 21:11:31 kettenis Exp $ */ /* $OpenBSD: i8259.c,v 1.12 2024/01/19 18:38:16 kettenis Exp $ */
/* $NetBSD: i8259.c,v 1.2 2003/03/02 18:27:15 fvdl Exp $ */ /* $NetBSD: i8259.c,v 1.2 2003/03/02 18:27:15 fvdl Exp $ */
/* /*
@ -100,6 +100,7 @@ struct pic i8259_pic = {
i8259_hwunmask, i8259_hwunmask,
i8259_setup, i8259_setup,
i8259_setup, i8259_setup,
NULL,
i8259_stubs, i8259_stubs,
i8259_stubs, i8259_stubs,
}; };

View File

@ -1,4 +1,4 @@
/* $OpenBSD: intr.c,v 1.55 2020/12/28 14:23:30 mpi Exp $ */ /* $OpenBSD: intr.c,v 1.56 2024/01/19 18:38:16 kettenis Exp $ */
/* $NetBSD: intr.c,v 1.3 2003/03/03 22:16:20 fvdl Exp $ */ /* $NetBSD: intr.c,v 1.3 2003/03/03 22:16:20 fvdl Exp $ */
/* /*
@ -310,9 +310,16 @@ other:
} }
return EBUSY; return EBUSY;
found: found:
idtvec = idt_vec_alloc(APIC_LEVEL(level), IDT_INTR_HIGH); if (pic->pic_allocidtvec) {
idtvec = pic->pic_allocidtvec(pic, pin,
APIC_LEVEL(level), IDT_INTR_HIGH);
} else {
idtvec = idt_vec_alloc(APIC_LEVEL(level),
IDT_INTR_HIGH);
}
if (idtvec == 0) { if (idtvec == 0) {
free(ci->ci_isources[slot], M_DEVBUF, sizeof (struct intrsource)); free(ci->ci_isources[slot], M_DEVBUF,
sizeof (struct intrsource));
ci->ci_isources[slot] = NULL; ci->ci_isources[slot] = NULL;
return EBUSY; return EBUSY;
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: machdep.c,v 1.288 2023/09/08 20:47:22 kn Exp $ */ /* $OpenBSD: machdep.c,v 1.289 2024/01/19 18:38:16 kettenis Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*- /*-
@ -1918,6 +1918,29 @@ idt_vec_alloc(int low, int high)
return 0; return 0;
} }
int
idt_vec_alloc_range(int low, int high, int num)
{
int i, vec;
KASSERT(powerof2(num));
low = (low + num - 1) & ~(num - 1);
high = ((high + 1) & ~(num - 1)) - 1;
for (vec = low; vec <= high; vec += num) {
for (i = 0; i < num; i++) {
if (idt_allocmap[vec + i] != 0)
break;
}
if (i == num) {
for (i = 0; i < num; i++)
idt_allocmap[vec + i] = 1;
return vec;
}
}
return 0;
}
void void
idt_vec_set(int vec, void (*function)(void)) idt_vec_set(int vec, void (*function)(void))
{ {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pci_machdep.h,v 1.30 2020/10/27 02:39:07 jordan Exp $ */ /* $OpenBSD: pci_machdep.h,v 1.31 2024/01/19 18:38:16 kettenis Exp $ */
/* $NetBSD: pci_machdep.h,v 1.1 2003/02/26 21:26:11 fvdl Exp $ */ /* $NetBSD: pci_machdep.h,v 1.1 2003/02/26 21:26:11 fvdl Exp $ */
/* /*
@ -79,8 +79,11 @@ int pci_conf_size(pci_chipset_tag_t, pcitag_t);
pcireg_t pci_conf_read(pci_chipset_tag_t, pcitag_t, int); pcireg_t pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
void pci_conf_write(pci_chipset_tag_t, pcitag_t, int, void pci_conf_write(pci_chipset_tag_t, pcitag_t, int,
pcireg_t); pcireg_t);
int pci_intr_enable_msivec(struct pci_attach_args *, int);
int pci_intr_map_msi(struct pci_attach_args *, int pci_intr_map_msi(struct pci_attach_args *,
pci_intr_handle_t *); pci_intr_handle_t *);
int pci_intr_map_msivec(struct pci_attach_args *,
int, pci_intr_handle_t *);
int pci_intr_map_msix(struct pci_attach_args *, int pci_intr_map_msix(struct pci_attach_args *,
int, pci_intr_handle_t *); int, pci_intr_handle_t *);
int pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *); int pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pic.h,v 1.7 2014/12/16 21:20:23 tedu Exp $ */ /* $OpenBSD: pic.h,v 1.8 2024/01/19 18:38:16 kettenis Exp $ */
/* $NetBSD: pic.h,v 1.1 2003/02/26 21:26:11 fvdl Exp $ */ /* $NetBSD: pic.h,v 1.1 2003/02/26 21:26:11 fvdl Exp $ */
#ifndef _X86_PIC_H #ifndef _X86_PIC_H
@ -22,6 +22,7 @@ struct pic {
void (*pic_hwunmask)(struct pic *, int); void (*pic_hwunmask)(struct pic *, int);
void (*pic_addroute)(struct pic *, struct cpu_info *, int, int, int); void (*pic_addroute)(struct pic *, struct cpu_info *, int, int, int);
void (*pic_delroute)(struct pic *, struct cpu_info *, int, int, int); void (*pic_delroute)(struct pic *, struct cpu_info *, int, int, int);
int (*pic_allocidtvec)(struct pic *, int, int, int);
struct intrstub *pic_level_stubs; struct intrstub *pic_level_stubs;
struct intrstub *pic_edge_stubs; struct intrstub *pic_edge_stubs;
}; };

View File

@ -1,4 +1,4 @@
/* $OpenBSD: segments.h,v 1.15 2018/03/29 01:21:02 guenther Exp $ */ /* $OpenBSD: segments.h,v 1.16 2024/01/19 18:38:16 kettenis Exp $ */
/* $NetBSD: segments.h,v 1.1 2003/04/26 18:39:47 fvdl Exp $ */ /* $NetBSD: segments.h,v 1.1 2003/04/26 18:39:47 fvdl Exp $ */
/*- /*-
@ -160,6 +160,7 @@ void set_sys_segment(struct sys_segment_descriptor *, void *, size_t,
void set_mem_segment(struct mem_segment_descriptor *, void *, size_t, void set_mem_segment(struct mem_segment_descriptor *, void *, size_t,
int, int, int, int, int); int, int, int, int, int);
int idt_vec_alloc(int, int); int idt_vec_alloc(int, int);
int idt_vec_alloc_range(int, int, int);
void idt_vec_set(int, void (*)(void)); void idt_vec_set(int, void (*)(void));
void idt_vec_free(int); void idt_vec_free(int);
void cpu_init_idt(void); void cpu_init_idt(void);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pci_machdep.c,v 1.77 2021/03/11 11:16:55 jsg Exp $ */ /* $OpenBSD: pci_machdep.c,v 1.78 2024/01/19 18:38:16 kettenis Exp $ */
/* $NetBSD: pci_machdep.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */ /* $NetBSD: pci_machdep.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */
/*- /*-
@ -315,10 +315,21 @@ pci_msix_table_unmap(pci_chipset_tag_t pc, pcitag_t tag,
_bus_space_unmap(memt, memh, tblsz * 16, NULL); _bus_space_unmap(memt, memh, tblsz * 16, NULL);
} }
/*
* We pack the MSI vector number into the lower 8 bits of the PCI tag
* and use that as the MSI/MSI-X "PIC" pin number. This allows us to
* address 256 MSI vectors which ought to be enough for anybody.
*/
#define PCI_MSI_VEC_MASK 0xff
#define PCI_MSI_VEC(pin) ((pin) & PCI_MSI_VEC_MASK)
#define PCI_MSI_TAG(pin) ((pin) & ~PCI_MSI_VEC_MASK)
#define PCI_MSI_PIN(tag, vec) ((tag) | (vec))
void msi_hwmask(struct pic *, int); void msi_hwmask(struct pic *, int);
void msi_hwunmask(struct pic *, int); void msi_hwunmask(struct pic *, int);
void msi_addroute(struct pic *, struct cpu_info *, int, int, int); void msi_addroute(struct pic *, struct cpu_info *, int, int, int);
void msi_delroute(struct pic *, struct cpu_info *, int, int, int); void msi_delroute(struct pic *, struct cpu_info *, int, int, int);
int msi_allocidtvec(struct pic *, int, int, int);
struct pic msi_pic = { struct pic msi_pic = {
{0, {NULL}, NULL, 0, "msi", NULL, 0, 0}, {0, {NULL}, NULL, 0, "msi", NULL, 0, 0},
@ -330,6 +341,7 @@ struct pic msi_pic = {
msi_hwunmask, msi_hwunmask,
msi_addroute, msi_addroute,
msi_delroute, msi_delroute,
msi_allocidtvec,
NULL, NULL,
ioapic_edge_stubs ioapic_edge_stubs
}; };
@ -345,57 +357,157 @@ msi_hwunmask(struct pic *pic, int pin)
} }
void void
msi_addroute(struct pic *pic, struct cpu_info *ci, int pin, int vec, int type) msi_addroute(struct pic *pic, struct cpu_info *ci, int pin, int idtvec,
int type)
{ {
pci_chipset_tag_t pc = NULL; /* XXX */ pci_chipset_tag_t pc = NULL; /* XXX */
pcitag_t tag = pin; pcitag_t tag = PCI_MSI_TAG(pin);
int vec = PCI_MSI_VEC(pin);
pcireg_t reg, addr; pcireg_t reg, addr;
int off; int off;
if (pci_get_capability(pc, tag, PCI_CAP_MSI, &off, &reg) == 0) if (pci_get_capability(pc, tag, PCI_CAP_MSI, &off, &reg) == 0)
panic("%s: no msi capability", __func__); panic("%s: no msi capability", __func__);
if (vec != 0)
return;
addr = 0xfee00000UL | (ci->ci_apicid << 12); addr = 0xfee00000UL | (ci->ci_apicid << 12);
if (reg & PCI_MSI_MC_C64) { if (reg & PCI_MSI_MC_C64) {
pci_conf_write(pc, tag, off + PCI_MSI_MA, addr); pci_conf_write(pc, tag, off + PCI_MSI_MA, addr);
pci_conf_write(pc, tag, off + PCI_MSI_MAU32, 0); pci_conf_write(pc, tag, off + PCI_MSI_MAU32, 0);
pci_conf_write(pc, tag, off + PCI_MSI_MD64, vec); pci_conf_write(pc, tag, off + PCI_MSI_MD64, idtvec);
} else { } else {
pci_conf_write(pc, tag, off + PCI_MSI_MA, addr); pci_conf_write(pc, tag, off + PCI_MSI_MA, addr);
pci_conf_write(pc, tag, off + PCI_MSI_MD32, vec); pci_conf_write(pc, tag, off + PCI_MSI_MD32, idtvec);
} }
pci_conf_write(pc, tag, off, reg | PCI_MSI_MC_MSIE); pci_conf_write(pc, tag, off, reg | PCI_MSI_MC_MSIE);
} }
void void
msi_delroute(struct pic *pic, struct cpu_info *ci, int pin, int vec, int type) msi_delroute(struct pic *pic, struct cpu_info *ci, int pin, int idtvec,
int type)
{ {
pci_chipset_tag_t pc = NULL; /* XXX */ pci_chipset_tag_t pc = NULL; /* XXX */
pcitag_t tag = pin; pcitag_t tag = PCI_MSI_TAG(pin);
int vec = PCI_MSI_VEC(pin);
pcireg_t reg; pcireg_t reg;
int off; int off;
if (vec != 0)
return;
if (pci_get_capability(pc, tag, PCI_CAP_MSI, &off, &reg)) if (pci_get_capability(pc, tag, PCI_CAP_MSI, &off, &reg))
pci_conf_write(pc, tag, off, reg & ~PCI_MSI_MC_MSIE); pci_conf_write(pc, tag, off, reg & ~PCI_MSI_MC_MSIE);
} }
int
msi_allocidtvec(struct pic *pic, int pin, int low, int high)
{
pci_chipset_tag_t pc = NULL; /* XXX */
pcitag_t tag = PCI_MSI_TAG(pin);
int vec = PCI_MSI_VEC(pin);
int idtvec, mme, off;
pcireg_t reg;
if (pci_get_capability(pc, tag, PCI_CAP_MSI, &off, &reg) == 0)
panic("%s: no msi capability", __func__);
reg = pci_conf_read(pc, tag, off);
mme = ((reg & PCI_MSI_MC_MME_MASK) >> PCI_MSI_MC_MME_SHIFT);
if (vec >= (1 << mme))
return 0;
if (vec == 0) {
idtvec = idt_vec_alloc_range(low, high, (1 << mme));
if (reg & PCI_MSI_MC_C64)
pci_conf_write(pc, tag, off + PCI_MSI_MD64, idtvec);
else
pci_conf_write(pc, tag, off + PCI_MSI_MD32, idtvec);
} else {
if (reg & PCI_MSI_MC_C64)
reg = pci_conf_read(pc, tag, off + PCI_MSI_MD64);
else
reg = pci_conf_read(pc, tag, off + PCI_MSI_MD32);
KASSERT(reg > 0);
idtvec = reg + vec;
}
return idtvec;
}
int
pci_intr_enable_msivec(struct pci_attach_args *pa, int num_vec)
{
pci_chipset_tag_t pc = pa->pa_pc;
pcitag_t tag = pa->pa_tag;
pcireg_t reg;
int mmc, mme, off;
if ((pa->pa_flags & PCI_FLAGS_MSI_ENABLED) == 0 || mp_busses == NULL ||
pci_get_capability(pc, tag, PCI_CAP_MSI, &off, &reg) == 0)
return 1;
mmc = ((reg & PCI_MSI_MC_MMC_MASK) >> PCI_MSI_MC_MMC_SHIFT);
if (num_vec > (1 << mmc))
return 1;
mme = ((reg & PCI_MSI_MC_MME_MASK) >> PCI_MSI_MC_MME_SHIFT);
while ((1 << mme) < num_vec)
mme++;
reg &= ~PCI_MSI_MC_MME_MASK;
reg |= (mme << PCI_MSI_MC_MME_SHIFT);
pci_conf_write(pc, tag, off, reg);
return 0;
}
int int
pci_intr_map_msi(struct pci_attach_args *pa, pci_intr_handle_t *ihp) pci_intr_map_msi(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
{ {
pci_chipset_tag_t pc = pa->pa_pc; pci_chipset_tag_t pc = pa->pa_pc;
pcitag_t tag = pa->pa_tag; pcitag_t tag = pa->pa_tag;
pcireg_t reg;
int off;
if ((pa->pa_flags & PCI_FLAGS_MSI_ENABLED) == 0 || mp_busses == NULL || if ((pa->pa_flags & PCI_FLAGS_MSI_ENABLED) == 0 || mp_busses == NULL ||
pci_get_capability(pc, tag, PCI_CAP_MSI, NULL, NULL) == 0) pci_get_capability(pc, tag, PCI_CAP_MSI, &off, &reg) == 0)
return 1; return 1;
/* Make sure we only enable one MSI vector. */
reg &= ~PCI_MSI_MC_MME_MASK;
pci_conf_write(pc, tag, off, reg);
ihp->tag = tag; ihp->tag = tag;
ihp->line = APIC_INT_VIA_MSG; ihp->line = APIC_INT_VIA_MSG;
ihp->pin = 0; ihp->pin = 0;
return 0; return 0;
} }
int
pci_intr_map_msivec(struct pci_attach_args *pa, int vec,
pci_intr_handle_t *ihp)
{
pci_chipset_tag_t pc = pa->pa_pc;
pcitag_t tag = pa->pa_tag;
pcireg_t reg;
int mme, off;
if ((pa->pa_flags & PCI_FLAGS_MSI_ENABLED) == 0 || mp_busses == NULL ||
pci_get_capability(pc, tag, PCI_CAP_MSI, &off, &reg) == 0)
return 1;
mme = ((reg & PCI_MSI_MC_MME_MASK) >> PCI_MSI_MC_MME_SHIFT);
if (vec > (1 << mme))
return 0;
ihp->tag = PCI_MSI_PIN(tag, vec);
ihp->line = APIC_INT_VIA_MSG;
ihp->pin = 0;
return 0;
}
void msix_hwmask(struct pic *, int); void msix_hwmask(struct pic *, int);
void msix_hwunmask(struct pic *, int); void msix_hwunmask(struct pic *, int);
void msix_addroute(struct pic *, struct cpu_info *, int, int, int); void msix_addroute(struct pic *, struct cpu_info *, int, int, int);
@ -412,19 +524,10 @@ struct pic msix_pic = {
msix_addroute, msix_addroute,
msix_delroute, msix_delroute,
NULL, NULL,
NULL,
ioapic_edge_stubs ioapic_edge_stubs
}; };
/*
* We pack the MSI-X vector number into the lower 8 bits of the PCI
* tag and use that as the MSI-X "PIC" pin number. This allows us to
* address 256 MSI-X vectors which ought to be enough for anybody.
*/
#define PCI_MSIX_VEC_MASK 0xff
#define PCI_MSIX_VEC(pin) ((pin) & PCI_MSIX_VEC_MASK)
#define PCI_MSIX_TAG(pin) ((pin) & ~PCI_MSIX_VEC_MASK)
#define PCI_MSIX_PIN(tag, vec) ((tag) | (vec))
void void
msix_hwmask(struct pic *pic, int pin) msix_hwmask(struct pic *pic, int pin)
{ {
@ -436,13 +539,14 @@ msix_hwunmask(struct pic *pic, int pin)
} }
void void
msix_addroute(struct pic *pic, struct cpu_info *ci, int pin, int vec, int type) msix_addroute(struct pic *pic, struct cpu_info *ci, int pin, int idtvec,
int type)
{ {
pci_chipset_tag_t pc = NULL; /* XXX */ pci_chipset_tag_t pc = NULL; /* XXX */
bus_space_tag_t memt = X86_BUS_SPACE_MEM; /* XXX */ bus_space_tag_t memt = X86_BUS_SPACE_MEM; /* XXX */
bus_space_handle_t memh; bus_space_handle_t memh;
pcitag_t tag = PCI_MSIX_TAG(pin); pcitag_t tag = PCI_MSI_TAG(pin);
int entry = PCI_MSIX_VEC(pin); int entry = PCI_MSI_VEC(pin);
pcireg_t reg, addr; pcireg_t reg, addr;
uint32_t ctrl; uint32_t ctrl;
int off; int off;
@ -459,7 +563,7 @@ msix_addroute(struct pic *pic, struct cpu_info *ci, int pin, int vec, int type)
bus_space_write_4(memt, memh, PCI_MSIX_MA(entry), addr); bus_space_write_4(memt, memh, PCI_MSIX_MA(entry), addr);
bus_space_write_4(memt, memh, PCI_MSIX_MAU32(entry), 0); bus_space_write_4(memt, memh, PCI_MSIX_MAU32(entry), 0);
bus_space_write_4(memt, memh, PCI_MSIX_MD(entry), vec); bus_space_write_4(memt, memh, PCI_MSIX_MD(entry), idtvec);
bus_space_barrier(memt, memh, PCI_MSIX_MA(entry), 16, bus_space_barrier(memt, memh, PCI_MSIX_MA(entry), 16,
BUS_SPACE_BARRIER_WRITE); BUS_SPACE_BARRIER_WRITE);
ctrl = bus_space_read_4(memt, memh, PCI_MSIX_VC(entry)); ctrl = bus_space_read_4(memt, memh, PCI_MSIX_VC(entry));
@ -472,13 +576,14 @@ msix_addroute(struct pic *pic, struct cpu_info *ci, int pin, int vec, int type)
} }
void void
msix_delroute(struct pic *pic, struct cpu_info *ci, int pin, int vec, int type) msix_delroute(struct pic *pic, struct cpu_info *ci, int pin, int idtvec,
int type)
{ {
pci_chipset_tag_t pc = NULL; /* XXX */ pci_chipset_tag_t pc = NULL; /* XXX */
bus_space_tag_t memt = X86_BUS_SPACE_MEM; /* XXX */ bus_space_tag_t memt = X86_BUS_SPACE_MEM; /* XXX */
bus_space_handle_t memh; bus_space_handle_t memh;
pcitag_t tag = PCI_MSIX_TAG(pin); pcitag_t tag = PCI_MSI_TAG(pin);
int entry = PCI_MSIX_VEC(pin); int entry = PCI_MSI_VEC(pin);
pcireg_t reg; pcireg_t reg;
uint32_t ctrl; uint32_t ctrl;
@ -504,7 +609,7 @@ pci_intr_map_msix(struct pci_attach_args *pa, int vec, pci_intr_handle_t *ihp)
pcitag_t tag = pa->pa_tag; pcitag_t tag = pa->pa_tag;
pcireg_t reg; pcireg_t reg;
KASSERT(PCI_MSIX_VEC(vec) == vec); KASSERT(PCI_MSI_VEC(vec) == vec);
if ((pa->pa_flags & PCI_FLAGS_MSI_ENABLED) == 0 || mp_busses == NULL || if ((pa->pa_flags & PCI_FLAGS_MSI_ENABLED) == 0 || mp_busses == NULL ||
pci_get_capability(pc, tag, PCI_CAP_MSIX, NULL, &reg) == 0) pci_get_capability(pc, tag, PCI_CAP_MSIX, NULL, &reg) == 0)
@ -513,7 +618,7 @@ pci_intr_map_msix(struct pci_attach_args *pa, int vec, pci_intr_handle_t *ihp)
if (vec > PCI_MSIX_MC_TBLSZ(reg)) if (vec > PCI_MSIX_MC_TBLSZ(reg))
return 1; return 1;
ihp->tag = PCI_MSIX_PIN(tag, vec); ihp->tag = PCI_MSI_PIN(tag, vec);
ihp->line = APIC_INT_VIA_MSGX; ihp->line = APIC_INT_VIA_MSGX;
ihp->pin = 0; ihp->pin = 0;
return 0; return 0;

View File

@ -1,4 +1,4 @@
# $OpenBSD: GENERIC,v 1.279 2023/12/28 17:36:29 stsp Exp $ # $OpenBSD: GENERIC,v 1.280 2024/01/19 06:59:10 mlarkin Exp $
# #
# GENERIC machine description file # GENERIC machine description file
# #
@ -393,6 +393,7 @@ vmx* at pci? # VMware VMXNET3 virtual interface
# PCI WiFi # PCI WiFi
athn* at pci? # Atheros AR9k (802.11a/g/n) athn* at pci? # Atheros AR9k (802.11a/g/n)
bwfm* at pci? # Broadcom FullMAC bwfm* at pci? # Broadcom FullMAC
iwn* at pci? # Intel WiFi Link 4965/5000/1000/6000
iwx* at pci? # Intel WiFi Link 22xxx iwx* at pci? # Intel WiFi Link 22xxx
#qwx* at pci? # Qualcomm 802.11ax #qwx* at pci? # Qualcomm 802.11ax

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_re_cardbus.c,v 1.30 2022/04/06 18:59:28 naddy Exp $ */ /* $OpenBSD: if_re_cardbus.c,v 1.31 2024/01/19 03:46:15 dlg Exp $ */
/* /*
* Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org> * Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org>
@ -232,19 +232,8 @@ re_cardbus_detach(struct device *self, int flags)
struct re_cardbus_softc *csc = (void *)self; struct re_cardbus_softc *csc = (void *)self;
struct rl_softc *sc = &csc->sc_rl; struct rl_softc *sc = &csc->sc_rl;
struct cardbus_devfunc *ct = csc->ct; struct cardbus_devfunc *ct = csc->ct;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
/* Remove timeout handler */ re_detach(sc);
timeout_del(&sc->timer_handle);
/* Detach PHY */
if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL)
mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
/* Delete media stuff */
ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
ether_ifdetach(ifp);
if_detach(ifp);
/* Disable interrupts */ /* Disable interrupts */
if (sc->sc_ih != NULL) if (sc->sc_ih != NULL)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rkdrm.c,v 1.19 2024/01/16 23:37:50 jsg Exp $ */ /* $OpenBSD: rkdrm.c,v 1.20 2024/01/19 17:51:15 kettenis Exp $ */
/* $NetBSD: rk_drm.c,v 1.3 2019/12/15 01:00:58 mrg Exp $ */ /* $NetBSD: rk_drm.c,v 1.3 2019/12/15 01:00:58 mrg Exp $ */
/*- /*-
* Copyright (c) 2019 Jared D. McNeill <jmcneill@invisible.ca> * Copyright (c) 2019 Jared D. McNeill <jmcneill@invisible.ca>
@ -266,7 +266,7 @@ rkdrm_wsioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
return ws_set_param(dp); return ws_set_param(dp);
return -1; return -1;
case WSDISPLAYIO_GTYPE: case WSDISPLAYIO_GTYPE:
*(u_int *)data = WSDISPLAY_TYPE_RKDRM; *(u_int *)data = WSDISPLAY_TYPE_KMS;
return 0; return 0;
case WSDISPLAYIO_GINFO: case WSDISPLAYIO_GINFO:
wdf = (struct wsdisplay_fbinfo *)data; wdf = (struct wsdisplay_fbinfo *)data;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: re.c,v 1.216 2023/11/10 15:51:20 bluhm Exp $ */ /* $OpenBSD: re.c,v 1.217 2024/01/19 03:46:14 dlg Exp $ */
/* $FreeBSD: if_re.c,v 1.31 2004/09/04 07:54:05 ru Exp $ */ /* $FreeBSD: if_re.c,v 1.31 2004/09/04 07:54:05 ru Exp $ */
/* /*
* Copyright (c) 1997, 1998-2003 * Copyright (c) 1997, 1998-2003
@ -199,6 +199,7 @@ int re_wol(struct ifnet*, int);
#endif #endif
#if NKSTAT > 0 #if NKSTAT > 0
void re_kstat_attach(struct rl_softc *); void re_kstat_attach(struct rl_softc *);
void re_kstat_detach(struct rl_softc *);
#endif #endif
void in_delayed_cksum(struct mbuf *); void in_delayed_cksum(struct mbuf *);
@ -1128,6 +1129,27 @@ fail_0:
return (1); return (1);
} }
void
re_detach(struct rl_softc *sc)
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
#if NKSTAT > 0
re_kstat_detach(sc);
#endif
/* Remove timeout handler */
timeout_del(&sc->timer_handle);
/* Detach PHY */
if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL)
mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
/* Delete media stuff */
ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
ether_ifdetach(ifp);
if_detach(ifp);
}
int int
re_newbuf(struct rl_softc *sc) re_newbuf(struct rl_softc *sc)
@ -2604,10 +2626,33 @@ unmap:
bus_dmamem_unmap(sc->sc_dmat, bus_dmamem_unmap(sc->sc_dmat,
(caddr_t)re_ks_sc->re_ks_sc_stats, sizeof(struct re_stats)); (caddr_t)re_ks_sc->re_ks_sc_stats, sizeof(struct re_stats));
freedma: freedma:
bus_dmamem_free(sc->sc_dmat, &re_ks_sc->re_ks_sc_seg, 1); bus_dmamem_free(sc->sc_dmat, &re_ks_sc->re_ks_sc_seg,
re_ks_sc->re_ks_sc_nsegs);
destroy: destroy:
bus_dmamap_destroy(sc->sc_dmat, re_ks_sc->re_ks_sc_map); bus_dmamap_destroy(sc->sc_dmat, re_ks_sc->re_ks_sc_map);
free: free:
free(re_ks_sc, M_DEVBUF, sizeof(*re_ks_sc)); free(re_ks_sc, M_DEVBUF, sizeof(*re_ks_sc));
} }
void
re_kstat_detach(struct rl_softc *sc)
{
struct kstat *ks = sc->rl_kstat;
struct re_kstat_softc *re_ks_sc;
if (ks == NULL)
return;
kstat_remove(ks);
re_ks_sc = ks->ks_ptr;
kstat_destroy(ks);
bus_dmamap_unload(sc->sc_dmat, re_ks_sc->re_ks_sc_map);
bus_dmamem_unmap(sc->sc_dmat,
(caddr_t)re_ks_sc->re_ks_sc_stats, sizeof(struct re_stats));
bus_dmamem_free(sc->sc_dmat, &re_ks_sc->re_ks_sc_seg,
re_ks_sc->re_ks_sc_nsegs);
bus_dmamap_destroy(sc->sc_dmat, re_ks_sc->re_ks_sc_map);
free(re_ks_sc, M_DEVBUF, sizeof(*re_ks_sc));
}
#endif /* NKSTAT > 0 */ #endif /* NKSTAT > 0 */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: revar.h,v 1.7 2010/07/27 20:53:39 kettenis Exp $ */ /* $OpenBSD: revar.h,v 1.8 2024/01/19 03:46:15 dlg Exp $ */
/* /*
* Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org> * Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org>
@ -18,6 +18,7 @@
int re_intr(void *); int re_intr(void *);
int re_attach(struct rl_softc *, const char *); int re_attach(struct rl_softc *, const char *);
void re_detach(struct rl_softc *);
void re_reset(struct rl_softc *); void re_reset(struct rl_softc *);
int re_init(struct ifnet *); int re_init(struct ifnet *);
void re_stop(struct ifnet *); void re_stop(struct ifnet *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_bnxt.c,v 1.44 2024/01/15 08:56:45 jmatthew Exp $ */ /* $OpenBSD: if_bnxt.c,v 1.45 2024/01/19 03:25:13 jmatthew Exp $ */
/*- /*-
* Broadcom NetXtreme-C/E network driver. * Broadcom NetXtreme-C/E network driver.
* *
@ -68,6 +68,7 @@
#include <net/if.h> #include <net/if.h>
#include <net/if_media.h> #include <net/if_media.h>
#include <net/route.h>
#include <net/toeplitz.h> #include <net/toeplitz.h>
#if NBPFILTER > 0 #if NBPFILTER > 0
@ -75,7 +76,12 @@
#endif #endif
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/if_ether.h> #include <netinet/if_ether.h>
#include <netinet/tcp.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
#define BNXT_HWRM_BAR 0x10 #define BNXT_HWRM_BAR 0x10
#define BNXT_DOORBELL_BAR 0x18 #define BNXT_DOORBELL_BAR 0x18
@ -642,6 +648,7 @@ bnxt_attach(struct device *parent, struct device *self, void *aux)
ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_CSUM_IPv4 | ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_CSUM_IPv4 |
IFCAP_CSUM_UDPv4 | IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv6 | IFCAP_CSUM_UDPv4 | IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv6 |
IFCAP_CSUM_TCPv6; IFCAP_CSUM_TCPv6;
ifp->if_capabilities |= IFCAP_TSOv4 | IFCAP_TSOv6;
#if NVLAN > 0 #if NVLAN > 0
ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING; ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING;
#endif #endif
@ -929,7 +936,7 @@ bnxt_queue_up(struct bnxt_softc *sc, struct bnxt_queue *bq)
for (i = 0; i < tx->tx_ring.ring_size; i++) { for (i = 0; i < tx->tx_ring.ring_size; i++) {
bs = &tx->tx_slots[i]; bs = &tx->tx_slots[i];
if (bus_dmamap_create(sc->sc_dmat, BNXT_MAX_MTU, BNXT_MAX_TX_SEGS, if (bus_dmamap_create(sc->sc_dmat, MAXMCLBYTES, BNXT_MAX_TX_SEGS,
BNXT_MAX_MTU, 0, BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW, BNXT_MAX_MTU, 0, BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW,
&bs->bs_map) != 0) { &bs->bs_map) != 0) {
printf("%s: failed to allocate tx dma maps\n", printf("%s: failed to allocate tx dma maps\n",
@ -1337,11 +1344,12 @@ bnxt_start(struct ifqueue *ifq)
struct bnxt_tx_queue *tx = ifq->ifq_softc; struct bnxt_tx_queue *tx = ifq->ifq_softc;
struct bnxt_softc *sc = tx->tx_softc; struct bnxt_softc *sc = tx->tx_softc;
struct bnxt_slot *bs; struct bnxt_slot *bs;
struct ether_extracted ext;
bus_dmamap_t map; bus_dmamap_t map;
struct mbuf *m; struct mbuf *m;
u_int idx, free, used, laststart; u_int idx, free, used, laststart;
uint16_t txflags; uint16_t txflags, lflags;
int i; int i, slen;
txring = (struct tx_bd_short *)BNXT_DMA_KVA(tx->tx_ring_mem); txring = (struct tx_bd_short *)BNXT_DMA_KVA(tx->tx_ring_mem);
@ -1385,12 +1393,16 @@ bnxt_start(struct ifqueue *ifq)
txring[idx].len = htole16(map->dm_segs[0].ds_len); txring[idx].len = htole16(map->dm_segs[0].ds_len);
txring[idx].opaque = tx->tx_prod; txring[idx].opaque = tx->tx_prod;
txring[idx].addr = htole64(map->dm_segs[0].ds_addr); txring[idx].addr = htole64(map->dm_segs[0].ds_addr);
if (m->m_pkthdr.csum_flags & M_TCP_TSO)
slen = m->m_pkthdr.ph_mss;
else
slen = map->dm_mapsize;
if (map->dm_mapsize < 512) if (slen < 512)
txflags = TX_BD_LONG_FLAGS_LHINT_LT512; txflags = TX_BD_LONG_FLAGS_LHINT_LT512;
else if (map->dm_mapsize < 1024) else if (slen < 1024)
txflags = TX_BD_LONG_FLAGS_LHINT_LT1K; txflags = TX_BD_LONG_FLAGS_LHINT_LT1K;
else if (map->dm_mapsize < 2048) else if (slen < 2048)
txflags = TX_BD_LONG_FLAGS_LHINT_LT2K; txflags = TX_BD_LONG_FLAGS_LHINT_LT2K;
else else
txflags = TX_BD_LONG_FLAGS_LHINT_GTE2K; txflags = TX_BD_LONG_FLAGS_LHINT_GTE2K;
@ -1409,12 +1421,44 @@ bnxt_start(struct ifqueue *ifq)
/* long tx descriptor */ /* long tx descriptor */
txhi = (struct tx_bd_long_hi *)&txring[idx]; txhi = (struct tx_bd_long_hi *)&txring[idx];
memset(txhi, 0, sizeof(*txhi)); memset(txhi, 0, sizeof(*txhi));
txflags = 0;
if (m->m_pkthdr.csum_flags & (M_UDP_CSUM_OUT | M_TCP_CSUM_OUT)) lflags = 0;
txflags |= TX_BD_LONG_LFLAGS_TCP_UDP_CHKSUM; if (m->m_pkthdr.csum_flags & M_TCP_TSO) {
if (m->m_pkthdr.csum_flags & M_IPV4_CSUM_OUT) uint16_t hdrsize;
txflags |= TX_BD_LONG_LFLAGS_IP_CHKSUM; uint32_t outlen;
txhi->lflags = htole16(txflags); uint32_t paylen;
ether_extract_headers(m, &ext);
if (ext.tcp) {
lflags |= TX_BD_LONG_LFLAGS_LSO;
hdrsize = sizeof(*ext.eh);
if (ext.ip4)
hdrsize += ext.ip4->ip_hl << 2;
else if (ext.ip6)
hdrsize += sizeof(*ext.ip6);
else
tcpstat_inc(tcps_outbadtso);
hdrsize += ext.tcp->th_off << 2;
txhi->hdr_size = htole16(hdrsize / 2);
outlen = m->m_pkthdr.ph_mss;
txhi->mss = htole32(outlen);
paylen = m->m_pkthdr.len - hdrsize;
tcpstat_add(tcps_outpkttso,
(paylen + outlen + 1) / outlen);
} else {
tcpstat_inc(tcps_outbadtso);
}
} else {
if (m->m_pkthdr.csum_flags & (M_UDP_CSUM_OUT |
M_TCP_CSUM_OUT))
lflags |= TX_BD_LONG_LFLAGS_TCP_UDP_CHKSUM;
if (m->m_pkthdr.csum_flags & M_IPV4_CSUM_OUT)
lflags |= TX_BD_LONG_LFLAGS_IP_CHKSUM;
}
txhi->lflags = htole16(lflags);
#if NVLAN > 0 #if NVLAN > 0
if (m->m_flags & M_VLANTAG) { if (m->m_flags & M_VLANTAG) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_re_pci.c,v 1.56 2022/03/11 18:00:48 mpi Exp $ */ /* $OpenBSD: if_re_pci.c,v 1.57 2024/01/19 03:46:15 dlg Exp $ */
/* /*
* Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org> * Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org>
@ -223,19 +223,8 @@ re_pci_detach(struct device *self, int flags)
{ {
struct re_pci_softc *psc = (struct re_pci_softc *)self; struct re_pci_softc *psc = (struct re_pci_softc *)self;
struct rl_softc *sc = &psc->sc_rl; struct rl_softc *sc = &psc->sc_rl;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
/* Remove timeout handler */ re_detach(sc);
timeout_del(&sc->timer_handle);
/* Detach PHY */
if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL)
mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
/* Delete media stuff */
ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
ether_ifdetach(ifp);
if_detach(ifp);
/* Disable interrupts */ /* Disable interrupts */
if (sc->sc_ih != NULL) if (sc->sc_ih != NULL)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pcireg.h,v 1.61 2022/06/17 10:08:36 kettenis Exp $ */ /* $OpenBSD: pcireg.h,v 1.62 2024/01/19 18:38:16 kettenis Exp $ */
/* $NetBSD: pcireg.h,v 1.26 2000/05/10 16:58:42 thorpej Exp $ */ /* $NetBSD: pcireg.h,v 1.26 2000/05/10 16:58:42 thorpej Exp $ */
/* /*
@ -516,8 +516,10 @@ typedef u_int8_t pci_revision_t;
*/ */
#define PCI_MSI_MC 0x00 #define PCI_MSI_MC 0x00
#define PCI_MSI_MC_C64 0x00800000 #define PCI_MSI_MC_C64 0x00800000
#define PCI_MSI_MC_MME 0x00700000 #define PCI_MSI_MC_MME_MASK 0x00700000
#define PCI_MSI_MC_MMC 0x000e0000 #define PCI_MSI_MC_MME_SHIFT 20
#define PCI_MSI_MC_MMC_MASK 0x000e0000
#define PCI_MSI_MC_MMC_SHIFT 17
#define PCI_MSI_MC_MSIE 0x00010000 #define PCI_MSI_MC_MSIE 0x00010000
#define PCI_MSI_MA 0x04 #define PCI_MSI_MA 0x04
#define PCI_MSI_MAU32 0x08 #define PCI_MSI_MAU32 0x08

View File

@ -1,4 +1,4 @@
/* $OpenBSD: wsconsio.h,v 1.100 2023/07/02 21:44:04 bru Exp $ */ /* $OpenBSD: wsconsio.h,v 1.101 2024/01/19 17:51:15 kettenis Exp $ */
/* $NetBSD: wsconsio.h,v 1.74 2005/04/28 07:15:44 martin Exp $ */ /* $NetBSD: wsconsio.h,v 1.74 2005/04/28 07:15:44 martin Exp $ */
/* /*
@ -461,7 +461,7 @@ struct wsmouse_parameters {
#define WSDISPLAY_TYPE_INTELDRM 69 /* Intel KMS framebuffer */ #define WSDISPLAY_TYPE_INTELDRM 69 /* Intel KMS framebuffer */
#define WSDISPLAY_TYPE_RADEONDRM 70 /* ATI Radeon KMS framebuffer */ #define WSDISPLAY_TYPE_RADEONDRM 70 /* ATI Radeon KMS framebuffer */
#define WSDISPLAY_TYPE_EFIFB 71 /* EFI framebuffer */ #define WSDISPLAY_TYPE_EFIFB 71 /* EFI framebuffer */
#define WSDISPLAY_TYPE_RKDRM 72 /* Rockchip KMS framebuffer */ #define WSDISPLAY_TYPE_KMS 72 /* Generic KMS framebuffer */
#define WSDISPLAY_TYPE_ASTFB 73 /* AST framebuffer */ #define WSDISPLAY_TYPE_ASTFB 73 /* AST framebuffer */
#define WSDISPLAY_TYPE_VIOGPU 74 /* VirtIO GPU */ #define WSDISPLAY_TYPE_VIOGPU 74 /* VirtIO GPU */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_exit.c,v 1.219 2024/01/16 19:05:01 deraadt Exp $ */ /* $OpenBSD: kern_exit.c,v 1.220 2024/01/19 01:43:26 bluhm Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/* /*
@ -165,8 +165,6 @@ exit1(struct proc *p, int xexit, int xsig, int flags)
/* main thread gotta wait because it has the pid, et al */ /* main thread gotta wait because it has the pid, et al */
while (pr->ps_threadcnt > 1) while (pr->ps_threadcnt > 1)
tsleep_nsec(&pr->ps_threads, PWAIT, "thrdeath", INFSLP); tsleep_nsec(&pr->ps_threads, PWAIT, "thrdeath", INFSLP);
LIST_REMOVE(pr, ps_list);
refcnt_finalize(&pr->ps_refcnt, "psdtor");
} }
rup = pr->ps_ru; rup = pr->ps_ru;
@ -259,6 +257,7 @@ exit1(struct proc *p, int xexit, int xsig, int flags)
if ((p->p_flag & P_THREAD) == 0) { if ((p->p_flag & P_THREAD) == 0) {
LIST_REMOVE(pr, ps_hash); LIST_REMOVE(pr, ps_hash);
LIST_REMOVE(pr, ps_list);
if ((pr->ps_flags & PS_NOZOMBIE) == 0) if ((pr->ps_flags & PS_NOZOMBIE) == 0)
LIST_INSERT_HEAD(&zombprocess, pr, ps_list); LIST_INSERT_HEAD(&zombprocess, pr, ps_list);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_fork.c,v 1.255 2024/01/16 19:05:01 deraadt Exp $ */ /* $OpenBSD: kern_fork.c,v 1.256 2024/01/19 01:43:26 bluhm Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/* /*
@ -197,7 +197,6 @@ process_initialize(struct process *pr, struct proc *p)
LIST_INIT(&pr->ps_sigiolst); LIST_INIT(&pr->ps_sigiolst);
TAILQ_INIT(&pr->ps_tslpqueue); TAILQ_INIT(&pr->ps_tslpqueue);
refcnt_init(&pr->ps_refcnt);
rw_init(&pr->ps_lock, "pslock"); rw_init(&pr->ps_lock, "pslock");
mtx_init(&pr->ps_mtx, IPL_HIGH); mtx_init(&pr->ps_mtx, IPL_HIGH);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_proc.c,v 1.96 2024/01/15 15:47:37 mvs Exp $ */ /* $OpenBSD: kern_proc.c,v 1.97 2024/01/19 01:43:27 bluhm Exp $ */
/* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */ /* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */
/* /*
@ -231,26 +231,6 @@ prfind(pid_t pid)
return (NULL); return (NULL);
} }
struct process *
priterator(struct process *ps)
{
struct process *nps;
KERNEL_ASSERT_LOCKED();
if (ps == NULL)
nps = LIST_FIRST(&allprocess);
else
nps = LIST_NEXT(ps, ps_list);
if (nps)
refcnt_take(&nps->ps_refcnt);
if (ps)
refcnt_rele_wake(&ps->ps_refcnt);
return nps;
}
/* /*
* Locate a process group by number * Locate a process group by number
*/ */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_sysctl.c,v 1.423 2024/01/18 08:48:32 mvs Exp $ */ /* $OpenBSD: kern_sysctl.c,v 1.424 2024/01/19 01:43:27 bluhm Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*- /*-
@ -1529,7 +1529,7 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep,
break; break;
} }
matched = 0; matched = 0;
for (pr = priterator(NULL); pr != NULL; pr = priterator(pr)) { LIST_FOREACH(pr, &allprocess, ps_list) {
/* /*
* skip system, exiting, embryonic and undead * skip system, exiting, embryonic and undead
* processes * processes
@ -1561,7 +1561,7 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep,
error = ESRCH; error = ESRCH;
break; break;
case KERN_FILE_BYUID: case KERN_FILE_BYUID:
for (pr = priterator(NULL); pr != NULL; pr = priterator(pr)) { LIST_FOREACH(pr, &allprocess, ps_list) {
/* /*
* skip system, exiting, embryonic and undead * skip system, exiting, embryonic and undead
* processes * processes

View File

@ -1,4 +1,4 @@
/* $OpenBSD: subr_extent.c,v 1.64 2022/12/05 23:18:37 deraadt Exp $ */ /* $OpenBSD: subr_extent.c,v 1.65 2024/01/19 22:12:24 kettenis Exp $ */
/* $NetBSD: subr_extent.c,v 1.7 1996/11/21 18:46:34 cgd Exp $ */ /* $NetBSD: subr_extent.c,v 1.7 1996/11/21 18:46:34 cgd Exp $ */
/*- /*-
@ -398,9 +398,10 @@ extent_insert_and_optimize(struct extent *ex, u_long start, u_long size,
* Allocate a specific region in an extent map. * Allocate a specific region in an extent map.
*/ */
int int
extent_alloc_region(struct extent *ex, u_long start, u_long size, int flags) extent_do_alloc_region(struct extent *ex, u_long start, u_long size,
int flags, struct extent_region *myrp)
{ {
struct extent_region *rp, *last, *myrp; struct extent_region *rp, *last;
u_long end = start + (size - 1); u_long end = start + (size - 1);
int error; int error;
@ -435,23 +436,11 @@ extent_alloc_region(struct extent *ex, u_long start, u_long size, int flags)
__func__, start, end); __func__, start, end);
panic("%s: region lies outside extent", __func__); panic("%s: region lies outside extent", __func__);
#else #else
extent_free_region_descriptor(ex, myrp);
return (EINVAL); return (EINVAL);
#endif #endif
} }
/*
* Allocate the region descriptor. It will be freed later
* if we can coalesce with another region.
*/
myrp = extent_alloc_region_descriptor(ex, flags);
if (myrp == NULL) {
#ifdef DIAGNOSTIC
printf(
"%s: can't allocate region descriptor\n", __func__);
#endif
return (ENOMEM);
}
alloc_start: alloc_start:
/* /*
* Attempt to place ourselves in the desired area of the * Attempt to place ourselves in the desired area of the
@ -567,6 +556,39 @@ extent_alloc_region(struct extent *ex, u_long start, u_long size, int flags)
return (0); return (0);
} }
int
extent_alloc_region(struct extent *ex, u_long start, u_long size, int flags)
{
struct extent_region *rp;
/*
* Allocate the region descriptor. It will be freed later
* if we can coalesce with another region.
*/
rp = extent_alloc_region_descriptor(ex, flags);
if (rp == NULL) {
#ifdef DIAGNOSTIC
printf("%s: can't allocate region descriptor\n", __func__);
#endif
return (ENOMEM);
}
return extent_do_alloc_region(ex, start, size, flags, rp);
}
int
extent_alloc_region_with_descr(struct extent *ex, u_long start,
u_long size, int flags, struct extent_region *rp)
{
#ifdef DIAGNOSTIC
if ((ex->ex_flags & EXF_NOCOALESCE) == 0)
panic("%s: EX_NOCOALESCE not set", __func__);
#endif
rp->er_flags = ER_DISCARD;
return extent_do_alloc_region(ex, start, size, flags, rp);
}
/* /*
* Macro to check (x + y) <= z. This check is designed to fail * Macro to check (x + y) <= z. This check is designed to fail
* if an overflow occurs. * if an overflow occurs.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: in_pcb.c,v 1.285 2024/01/18 11:03:16 claudio Exp $ */ /* $OpenBSD: in_pcb.c,v 1.286 2024/01/19 02:24:07 bluhm Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/* /*
@ -517,7 +517,7 @@ in_pcbconnect(struct inpcb *inp, struct mbuf *nam)
#ifdef INET6 #ifdef INET6
if (ISSET(inp->inp_flags, INP_IPV6)) if (ISSET(inp->inp_flags, INP_IPV6))
return (in6_pcbconnect(inp, nam)); return (in6_pcbconnect(inp, nam));
#endif /* INET6 */ #endif
if ((error = in_nam2sin(nam, &sin))) if ((error = in_nam2sin(nam, &sin)))
return (error); return (error);
@ -652,6 +652,13 @@ in_setsockaddr(struct inpcb *inp, struct mbuf *nam)
{ {
struct sockaddr_in *sin; struct sockaddr_in *sin;
#ifdef INET6
if (ISSET(inp->inp_flags, INP_IPV6)) {
in6_setsockaddr(inp, nam);
return;
}
#endif
nam->m_len = sizeof(*sin); nam->m_len = sizeof(*sin);
sin = mtod(nam, struct sockaddr_in *); sin = mtod(nam, struct sockaddr_in *);
memset(sin, 0, sizeof(*sin)); memset(sin, 0, sizeof(*sin));
@ -671,7 +678,7 @@ in_setpeeraddr(struct inpcb *inp, struct mbuf *nam)
in6_setpeeraddr(inp, nam); in6_setpeeraddr(inp, nam);
return; return;
} }
#endif /* INET6 */ #endif
nam->m_len = sizeof(*sin); nam->m_len = sizeof(*sin);
sin = mtod(nam, struct sockaddr_in *); sin = mtod(nam, struct sockaddr_in *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_usrreq.c,v 1.228 2024/01/11 13:49:49 bluhm Exp $ */ /* $OpenBSD: tcp_usrreq.c,v 1.229 2024/01/19 02:24:07 bluhm Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/* /*
@ -502,7 +502,7 @@ tcp_detach(struct socket *so)
{ {
struct inpcb *inp; struct inpcb *inp;
struct tcpcb *otp = NULL, *tp; struct tcpcb *otp = NULL, *tp;
int error = 0; int error;
short ostate; short ostate;
soassertlocked(so); soassertlocked(so);
@ -526,7 +526,7 @@ tcp_detach(struct socket *so)
if (otp) if (otp)
tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_DETACH, 0); tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_DETACH, 0);
return (error); return (0);
} }
/* /*
@ -685,26 +685,17 @@ tcp_accept(struct socket *so, struct mbuf *nam)
struct inpcb *inp; struct inpcb *inp;
struct tcpcb *tp; struct tcpcb *tp;
int error; int error;
short ostate;
soassertlocked(so); soassertlocked(so);
if ((error = tcp_sogetpcb(so, &inp, &tp))) if ((error = tcp_sogetpcb(so, &inp, &tp)))
return (error); return (error);
if (so->so_options & SO_DEBUG) in_setpeeraddr(inp, nam);
ostate = tp->t_state;
#ifdef INET6
if (inp->inp_flags & INP_IPV6)
in6_setpeeraddr(inp, nam);
else
#endif
in_setpeeraddr(inp, nam);
if (so->so_options & SO_DEBUG) if (so->so_options & SO_DEBUG)
tcp_trace(TA_USER, ostate, tp, tp, NULL, PRU_ACCEPT, 0); tcp_trace(TA_USER, tp->t_state, tp, tp, NULL, PRU_ACCEPT, 0);
return (error); return (0);
} }
/* /*
@ -994,12 +985,7 @@ tcp_sockaddr(struct socket *so, struct mbuf *nam)
if ((error = tcp_sogetpcb(so, &inp, &tp))) if ((error = tcp_sogetpcb(so, &inp, &tp)))
return (error); return (error);
#ifdef INET6 in_setsockaddr(inp, nam);
if (inp->inp_flags & INP_IPV6)
in6_setsockaddr(inp, nam);
else
#endif
in_setsockaddr(inp, nam);
if (so->so_options & SO_DEBUG) if (so->so_options & SO_DEBUG)
tcp_trace(TA_USER, tp->t_state, tp, tp, NULL, tcp_trace(TA_USER, tp->t_state, tp, tp, NULL,
@ -1019,16 +1005,10 @@ tcp_peeraddr(struct socket *so, struct mbuf *nam)
if ((error = tcp_sogetpcb(so, &inp, &tp))) if ((error = tcp_sogetpcb(so, &inp, &tp)))
return (error); return (error);
#ifdef INET6 in_setpeeraddr(inp, nam);
if (inp->inp_flags & INP_IPV6)
in6_setpeeraddr(inp, nam);
else
#endif
in_setpeeraddr(inp, nam);
if (so->so_options & SO_DEBUG) if (so->so_options & SO_DEBUG)
tcp_trace(TA_USER, tp->t_state, tp, tp, NULL, tcp_trace(TA_USER, tp->t_state, tp, tp, NULL, PRU_PEERADDR, 0);
PRU_PEERADDR, 0);
return (0); return (0);
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: udp_usrreq.c,v 1.313 2024/01/10 16:44:30 bluhm Exp $ */ /* $OpenBSD: udp_usrreq.c,v 1.314 2024/01/19 02:24:07 bluhm Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/* /*
@ -936,9 +936,9 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct mbuf *addr,
struct in_addr laddr; struct in_addr laddr;
int error = 0; int error = 0;
#ifdef DIAGNOSTIC #ifdef INET6
if ((inp->inp_flags & INP_IPV6) != 0) if (ISSET(inp->inp_flags, INP_IPV6))
panic("IPv6 inpcb to %s", __func__); return (udp6_output(inp, m, addr, control));
#endif #endif
/* /*
@ -1230,7 +1230,6 @@ udp_send(struct socket *so, struct mbuf *m, struct mbuf *addr,
struct mbuf *control) struct mbuf *control)
{ {
struct inpcb *inp = sotoinpcb(so); struct inpcb *inp = sotoinpcb(so);
int error;
soassertlocked(so); soassertlocked(so);
@ -1265,14 +1264,7 @@ udp_send(struct socket *so, struct mbuf *m, struct mbuf *addr,
} }
#endif #endif
#ifdef INET6 return (udp_output(inp, m, addr, control));
if (inp->inp_flags & INP_IPV6)
error = udp6_output(inp, m, addr, control);
else
#endif
error = udp_output(inp, m, addr, control);
return (error);
} }
/* /*

View File

@ -1,4 +1,4 @@
/* $OpenBSD: extent.h,v 1.14 2014/02/08 20:29:01 kettenis Exp $ */ /* $OpenBSD: extent.h,v 1.15 2024/01/19 22:12:24 kettenis Exp $ */
/* $NetBSD: extent.h,v 1.6 1997/10/09 07:43:05 jtc Exp $ */ /* $NetBSD: extent.h,v 1.6 1997/10/09 07:43:05 jtc Exp $ */
/*- /*-
@ -110,6 +110,8 @@ int extent_alloc_subregion_with_descr(struct extent *, u_long, u_long,
u_long, u_long, u_long, u_long, int, struct extent_region *, u_long, u_long, u_long, u_long, int, struct extent_region *,
u_long *); u_long *);
int extent_alloc_region(struct extent *, u_long, u_long, int); int extent_alloc_region(struct extent *, u_long, u_long, int);
int extent_alloc_region_with_descr(struct extent *, u_long, u_long,
int, struct extent_region *);
int extent_free(struct extent *, u_long, u_long, int); int extent_free(struct extent *, u_long, u_long, int);
void extent_print(struct extent *); void extent_print(struct extent *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.h,v 1.354 2024/01/16 19:05:00 deraadt Exp $ */ /* $OpenBSD: proc.h,v 1.355 2024/01/19 01:43:27 bluhm Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*- /*-
@ -50,7 +50,6 @@
#include <sys/resource.h> /* For struct rusage */ #include <sys/resource.h> /* For struct rusage */
#include <sys/rwlock.h> /* For struct rwlock */ #include <sys/rwlock.h> /* For struct rwlock */
#include <sys/sigio.h> /* For struct sigio */ #include <sys/sigio.h> /* For struct sigio */
#include <sys/refcnt.h>
#ifdef _KERNEL #ifdef _KERNEL
#include <sys/atomic.h> #include <sys/atomic.h>
@ -172,7 +171,6 @@ struct process {
struct futex_list ps_ftlist; /* futexes attached to this process */ struct futex_list ps_ftlist; /* futexes attached to this process */
struct tslpqueue ps_tslpqueue; /* [p] queue of threads in thrsleep */ struct tslpqueue ps_tslpqueue; /* [p] queue of threads in thrsleep */
struct refcnt ps_refcnt;
struct rwlock ps_lock; /* per-process rwlock */ struct rwlock ps_lock; /* per-process rwlock */
struct mutex ps_mtx; /* per-process mutex */ struct mutex ps_mtx; /* per-process mutex */
@ -540,7 +538,6 @@ void freepid(pid_t);
struct process *prfind(pid_t); /* Find process by id. */ struct process *prfind(pid_t); /* Find process by id. */
struct process *zombiefind(pid_t); /* Find zombie process by id. */ struct process *zombiefind(pid_t); /* Find zombie process by id. */
struct process *priterator(struct process *);
struct proc *tfind(pid_t); /* Find thread by id. */ struct proc *tfind(pid_t); /* Find thread by id. */
struct pgrp *pgfind(pid_t); /* Find process group by id. */ struct pgrp *pgfind(pid_t); /* Find process group by id. */
struct proc *tfind_user(pid_t, struct process *); struct proc *tfind_user(pid_t, struct process *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ffs_vfsops.c,v 1.196 2024/01/09 03:16:00 guenther Exp $ */ /* $OpenBSD: ffs_vfsops.c,v 1.197 2024/01/19 18:58:17 deraadt Exp $ */
/* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */
/* /*
@ -886,7 +886,7 @@ ffs_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p)
strlcpy(fs->fs_fsmnt, mp->mnt_stat.f_mntonname, sizeof(fs->fs_fsmnt)); strlcpy(fs->fs_fsmnt, mp->mnt_stat.f_mntonname, sizeof(fs->fs_fsmnt));
#if 0 #if 0
if( mp->mnt_flag & MNT_ROOTFS) { if (mp->mnt_flag & MNT_ROOTFS) {
/* /*
* Root mount; update timestamp in mount structure. * Root mount; update timestamp in mount structure.
* this will be used by the common root mount code * this will be used by the common root mount code

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uvm_extern.h,v 1.172 2024/01/17 22:22:25 kurt Exp $ */ /* $OpenBSD: uvm_extern.h,v 1.173 2024/01/19 21:20:35 deraadt Exp $ */
/* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */ /* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */
/* /*
@ -214,8 +214,6 @@ struct vmspace {
caddr_t vm_daddr; /* [I] user virtual address of data */ caddr_t vm_daddr; /* [I] user virtual address of data */
caddr_t vm_maxsaddr; /* [I] user VA at max stack growth */ caddr_t vm_maxsaddr; /* [I] user VA at max stack growth */
caddr_t vm_minsaddr; /* [I] user VA at top of stack */ caddr_t vm_minsaddr; /* [I] user VA at top of stack */
vaddr_t vm_execve; /* [v] execve systemcall stub region */
vaddr_t vm_execve_end; /* [v] execve systemcall stub region */
}; };
/* /*

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uvm_mmap.c,v 1.184 2024/01/16 19:05:01 deraadt Exp $ */ /* $OpenBSD: uvm_mmap.c,v 1.185 2024/01/19 21:20:35 deraadt Exp $ */
/* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */ /* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */
/* /*
@ -618,29 +618,6 @@ sys_msyscall(struct proc *p, void *v, register_t *retval)
int int
sys_pinsyscall(struct proc *p, void *v, register_t *retval) sys_pinsyscall(struct proc *p, void *v, register_t *retval)
{ {
struct sys_pinsyscall_args /* {
syscallarg(int) syscall;
syscallarg(void *) addr;
syscallarg(size_t) len;
} */ *uap = v;
struct vmspace *vm = p->p_vmspace;
vm_map_t map = &p->p_vmspace->vm_map;
vaddr_t start, end;
if (SCARG(uap, syscall) != SYS_execve)
return (EINVAL);
start = (vaddr_t)SCARG(uap, addr);
end = start + (vsize_t)SCARG(uap, len);
if (start >= end || start < map->min_offset || end > map->max_offset)
return (EFAULT);
vm_map_lock(map);
if (vm->vm_execve) {
vm_map_unlock(map);
return (EPERM);
}
vm->vm_execve = start;
vm->vm_execve_end = end;
vm_map_unlock(map);
return (0); return (0);
} }

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: lastcomm.1,v 1.26 2023/12/11 00:40:31 deraadt Exp $ .\" $OpenBSD: lastcomm.1,v 1.27 2024/01/19 14:25:03 deraadt Exp $
.\" $NetBSD: lastcomm.1,v 1.5 1995/10/22 01:43:41 ghudson Exp $ .\" $NetBSD: lastcomm.1,v 1.5 1995/10/22 01:43:41 ghudson Exp $
.\" .\"
.\" Copyright (c) 1980, 1990, 1993 .\" Copyright (c) 1980, 1990, 1993
@ -30,7 +30,7 @@
.\" .\"
.\" @(#)lastcomm.1 8.1 (Berkeley) 6/6/93 .\" @(#)lastcomm.1 8.1 (Berkeley) 6/6/93
.\" .\"
.Dd $Mdocdate: December 11 2023 $ .Dd $Mdocdate: January 19 2024 $
.Dt LASTCOMM 1 .Dt LASTCOMM 1
.Os .Os
.Sh NAME .Sh NAME
@ -105,12 +105,6 @@ The flags are encoded as follows:
The command terminated with the generation of a The command terminated with the generation of a
.Pa core .Pa core
file. file.
.It Li E
The command terminated because it tried to
.Xr execve 2
in violation of
.Xr pinsyscall 2
policy.
.It Li F .It Li F
The command ran after The command ran after
a fork, but without a following a fork, but without a following

View File

@ -1,4 +1,4 @@
/* $OpenBSD: lastcomm.c,v 1.34 2023/12/11 00:40:31 deraadt Exp $ */ /* $OpenBSD: lastcomm.c,v 1.35 2024/01/19 14:25:03 deraadt Exp $ */
/* $NetBSD: lastcomm.c,v 1.9 1995/10/22 01:43:42 ghudson Exp $ */ /* $NetBSD: lastcomm.c,v 1.9 1995/10/22 01:43:42 ghudson Exp $ */
/* /*
@ -177,7 +177,6 @@ flagbits(int f)
BIT(APLEDGE, 'P'); BIT(APLEDGE, 'P');
BIT(ATRAP, 'T'); BIT(ATRAP, 'T');
BIT(AUNVEIL, 'U'); BIT(AUNVEIL, 'U');
BIT(AEXECVE, 'E');
BIT(APINSYS, 'S'); BIT(APINSYS, 'S');
*p = '\0'; *p = '\0';
return (flags); return (flags);