diff --git a/bin/pax/cpio.1 b/bin/pax/cpio.1 index 89a6e3675..341afe1e1 100644 --- a/bin/pax/cpio.1 +++ b/bin/pax/cpio.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cpio.1,v 1.36 2020/01/16 16:46:46 schwarze Exp $ +.\" $OpenBSD: cpio.1,v 1.37 2023/12/09 23:00:11 jca Exp $ .\" .\" Copyright (c) 1997 SigmaSoft, Th. Lockert .\" All rights reserved. @@ -23,7 +23,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: January 16 2020 $ +.Dd $Mdocdate: December 9 2023 $ .Dt CPIO 1 .Os .Sh NAME @@ -98,6 +98,8 @@ format. Old octal character .Nm format. +.It Ar pax +POSIX pax format. .It Ar sv4cpio SVR4 hex .Nm @@ -173,6 +175,8 @@ format. Old octal character .Nm format. +.It Ar pax +POSIX pax format. .It Ar sv4cpio SVR4 hex .Nm @@ -298,6 +302,8 @@ be used for larger files. .It bcpio Ta "4 Gigabytes" .It sv4cpio Ta "4 Gigabytes" .It cpio Ta "8 Gigabytes" +.\" XXX should be "unlimited" +.It pax Ta "8 Gigabytes" .It tar Ta "8 Gigabytes" .It ustar Ta "8 Gigabytes" .El diff --git a/bin/pax/extern.h b/bin/pax/extern.h index 3d7303c42..9730b8db8 100644 --- a/bin/pax/extern.h +++ b/bin/pax/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.61 2023/11/26 16:04:17 espie Exp $ */ +/* $OpenBSD: extern.h,v 1.62 2023/12/09 23:00:11 jca Exp $ */ /* $NetBSD: extern.h,v 1.5 1996/03/26 23:54:16 mrg Exp $ */ /*- @@ -284,6 +284,7 @@ int tar_wr(ARCHD *); int ustar_id(char *, int); int ustar_rd(ARCHD *, char *); int ustar_wr(ARCHD *); +int pax_wr(ARCHD *); /* * tty_subs.c diff --git a/bin/pax/options.c b/bin/pax/options.c index 835c38f00..454c8409a 100644 --- a/bin/pax/options.c +++ b/bin/pax/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.106 2023/11/26 16:04:17 espie Exp $ */ +/* $OpenBSD: options.c,v 1.107 2023/12/09 23:00:11 jca Exp $ */ /* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */ /*- @@ -216,6 +216,8 @@ FSUB fsub[] = { { }, /* 9: gzip, to detect failure to use -z */ { }, +/* 10: POSIX PAX */ + { }, #else /* 6: compress, to detect failure to use -Z */ {NULL, 0, 4, 0, 0, 0, 0, compress_id}, @@ -225,6 +227,10 @@ FSUB fsub[] = { {NULL, 0, 4, 0, 0, 0, 0, bzip2_id}, /* 9: gzip, to detect failure to use -z */ {NULL, 0, 4, 0, 0, 0, 0, gzip_id}, +/* 10: POSIX PAX */ + {"pax", 5120, BLKMULT, 0, 1, BLKMULT, 0, ustar_id, no_op, + ustar_rd, tar_endrd, no_op, pax_wr, tar_endwr, tar_trail, + tar_opt}, #endif }; #define F_OCPIO 0 /* format when called as cpio -6 */ diff --git a/bin/pax/pax.1 b/bin/pax/pax.1 index dda8e2abf..ce3670216 100644 --- a/bin/pax/pax.1 +++ b/bin/pax/pax.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pax.1,v 1.76 2022/03/31 17:27:14 naddy Exp $ +.\" $OpenBSD: pax.1,v 1.77 2023/12/09 23:00:11 jca Exp $ .\" $NetBSD: pax.1,v 1.3 1995/03/21 09:07:37 cgd Exp $ .\" .\" Copyright (c) 1992 Keith Muller. @@ -34,7 +34,7 @@ .\" .\" @(#)pax.1 8.4 (Berkeley) 4/18/94 .\" -.Dd $Mdocdate: March 31 2022 $ +.Dd $Mdocdate: December 9 2023 $ .Dt PAX 1 .Os .Sh NAME @@ -868,6 +868,11 @@ standard. The default blocksize for this format is 10240 bytes. Filenames stored by this format must be 100 characters or less in length; the total pathname must be 256 characters or less. +.It Cm pax +The pax interchange format specified in the +.St -p1003.1-2001 +standard. +The default blocksize for this format is 5120 bytes. .El .Pp .Nm @@ -1081,9 +1086,10 @@ utility is compliant with the specification, except that the .Cm pax -archive format and the +archive format is only partially supported, +and the .Cm listopt -keyword are unsupported. +keyword is unsupported. .Pp The flags .Op Fl 0BDEGjOPTUYZz , diff --git a/bin/pax/tar.c b/bin/pax/tar.c index d3eb5daec..91bc114a7 100644 --- a/bin/pax/tar.c +++ b/bin/pax/tar.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tar.c,v 1.73 2023/09/04 17:05:34 jca Exp $ */ +/* $OpenBSD: tar.c,v 1.74 2023/12/09 23:00:11 jca Exp $ */ /* $NetBSD: tar.c,v 1.5 1995/03/21 09:07:49 cgd Exp $ */ /*- @@ -35,10 +35,12 @@ */ #include +#include #include #include #include #include +#include #include #include #include @@ -50,6 +52,19 @@ #include "extern.h" #include "tar.h" +SLIST_HEAD(xheader, xheader_record); +struct xheader_record { + SLIST_ENTRY(xheader_record) entry; + size_t reclen; + char *record; +}; + +/* shortest possible extended record: "5 a=\n" */ +#define MINXHDRSZ 5 + +/* longest record we'll accept */ +#define MAXXHDRSZ BLKMULT + /* * Routines for reading, writing and header identify of various versions of tar */ @@ -60,6 +75,9 @@ static char *name_split(char *, int); static int ul_oct(u_long, char *, int, int); static int ull_oct(unsigned long long, char *, int, int); static int rd_xheader(ARCHD *arcn, int, off_t); +#ifndef SMALL +static int wr_xheader(ARCHD *, struct xheader *); +#endif static uid_t uid_nobody; static uid_t uid_warn; @@ -891,24 +909,121 @@ reset: return(0); } -/* - * ustar_wr() - * write a ustar header for the file specified in the ARCHD to the archive - * Have to check for file types that cannot be stored and file names that - * are too long. Be careful of the term (last arg) to ul_oct, we only use - * '\0' for the termination character (this is different than picky tar) - * ASSUMED: space after header in header block is zero filled - * Return: - * 0 if file has data to be written after the header, 1 if file has NO - * data to write after the header, -1 if archive write failed - */ +#ifndef SMALL +static int +xheader_add(struct xheader *xhdr, const char *keyword, + const char *value) +{ + struct xheader_record *rec; + int reclen, tmplen; + char *s; -int -ustar_wr(ARCHD *arcn) + tmplen = MINXHDRSZ; + do { + reclen = tmplen; + tmplen = snprintf(NULL, 0, "%d %s=%s\n", reclen, keyword, + value); + } while (tmplen >= 0 && tmplen != reclen); + if (tmplen < 0) + return -1; + + rec = calloc(1, sizeof(*rec)); + if (rec == NULL) + return -1; + rec->reclen = reclen; + if (asprintf(&s, "%d %s=%s\n", reclen, keyword, value) < 0) { + free(rec); + return -1; + } + rec->record = s; + + SLIST_INSERT_HEAD(xhdr, rec, entry); + + return 0; +} + +static void +xheader_free(struct xheader *xhdr) +{ + struct xheader_record *rec; + + while (!SLIST_EMPTY(xhdr)) { + rec = SLIST_FIRST(xhdr); + SLIST_REMOVE_HEAD(xhdr, entry); + free(rec->record); + free(rec); + } +} + +static int +wr_xheader(ARCHD *arcn, struct xheader *xhdr) +{ + char hdblk[sizeof(HD_USTAR)]; + HD_USTAR *hd; + char buf[sizeof(hd->name) + 1]; + struct xheader_record *rec; + size_t size; + + size = 0; + SLIST_FOREACH(rec, xhdr, entry) + size += rec->reclen; + + memset(hdblk, 0, sizeof(hdblk)); + hd = (HD_USTAR *)hdblk; + hd->typeflag = XHDRTYPE; + strncpy(hd->magic, TMAGIC, TMAGLEN); + strncpy(hd->version, TVERSION, TVERSLEN); + if (ul_oct(size, hd->size, sizeof(hd->size), 3)) + return -1; + + /* + * Best effort attempt at providing a useful file name for + * implementations that don't support pax format. Don't bother + * with truncation if the resulting file name doesn't fit. + * XXX dirname/basename portability (check return value?) + */ + (void)snprintf(buf, sizeof(buf), "%s/PaxHeaders.%ld/%s", + dirname(arcn->name), (long)getpid(), basename(arcn->name)); + fieldcpy(hd->name, sizeof(hd->name), buf, sizeof(buf)); + + if (ul_oct(arcn->sb.st_mode, hd->mode, sizeof(hd->mode), 0) || + ull_oct(arcn->sb.st_mtime < 0 ? 0 : arcn->sb.st_mtime, hd->mtime, + sizeof(hd->mtime), 1) || + ul_oct(arcn->sb.st_uid, hd->uid, sizeof(hd->uid), 0) || + ul_oct(arcn->sb.st_gid, hd->gid, sizeof(hd->gid), 0)) + return -1; + + if (ul_oct(tar_chksm(hdblk, sizeof(HD_USTAR)), hd->chksum, + sizeof(hd->chksum), 3)) + return -1; + + /* write out extended header */ + if (wr_rdbuf(hdblk, sizeof(HD_USTAR)) < 0) + return -1; + if (wr_skip(BLKMULT - sizeof(HD_USTAR)) < 0) + return -1; + + /* write out extended header records */ + SLIST_FOREACH(rec, xhdr, entry) + if (wr_rdbuf(rec->record, rec->reclen) < 0) + return -1; + + if (wr_skip(TAR_PAD(size)) < 0) + return -1; + + return 0; +} +#endif + +static int +wr_ustar_or_pax(ARCHD *arcn, int ustar) { HD_USTAR *hd; const char *name; char *pt, hdblk[sizeof(HD_USTAR)]; +#ifndef SMALL + struct xheader xhdr = SLIST_HEAD_INITIALIZER(xhdr); +#endif /* * check for those file system types ustar cannot store @@ -929,8 +1044,19 @@ ustar_wr(ARCHD *arcn) */ if (PAX_IS_LINK(arcn->type) && ((size_t)arcn->ln_nlen > sizeof(hd->linkname))) { - paxwarn(1, "Link name too long for ustar %s", arcn->ln_name); - return(1); + if (ustar) { + paxwarn(1, "Link name too long for ustar %s", + arcn->ln_name); + return(1); + } +#ifndef SMALL + else if (xheader_add(&xhdr, "linkpath", arcn->name) == -1) { + paxwarn(1, "Link name too long for pax %s", + arcn->ln_name); + xheader_free(&xhdr); + return(1); + } +#endif } /* @@ -938,8 +1064,21 @@ ustar_wr(ARCHD *arcn) * pt != arcn->name, the name has to be split */ if ((pt = name_split(arcn->name, arcn->nlen)) == NULL) { - paxwarn(1, "File name too long for ustar %s", arcn->name); - return(1); + if (ustar) { + paxwarn(1, "File name too long for ustar %s", + arcn->name); + return(1); + } +#ifndef SMALL + else if (xheader_add(&xhdr, "path", arcn->name) == -1) { + paxwarn(1, "File name too long for pax %s", + arcn->ln_name); + xheader_free(&xhdr); + return(1); + } + /* PAX format, we don't need to split the path */ + pt = arcn->name; +#endif } /* @@ -1074,6 +1213,18 @@ ustar_wr(ARCHD *arcn) strncpy(hd->gname, name, sizeof(hd->gname)); } +#ifndef SMALL + /* write out a pax extended header if needed */ + if (!SLIST_EMPTY(&xhdr)) { + int ret; + + ret = wr_xheader(arcn, &xhdr); + xheader_free(&xhdr); + if (ret == -1) + return(-1); + } +#endif + /* * calculate and store the checksum write the header to the archive * return 0 tells the caller to now write the file data, 1 says no data @@ -1091,6 +1242,9 @@ ustar_wr(ARCHD *arcn) return(1); out: +#ifndef SMALL + xheader_free(&xhdr); +#endif /* * header field is out of range */ @@ -1098,6 +1252,42 @@ ustar_wr(ARCHD *arcn) return(1); } +/* + * ustar_wr() + * Write out a ustar format archive. + * Have to check for file types that cannot be stored and file names that + * are too long. Be careful of the term (last arg) to ul_oct, we only use + * '\0' for the termination character (this is different than picky tar). + * ASSUMED: space after header in header block is zero filled + * Return: + * 0 if file has data to be written after the header, 1 if file has NO + * data to write after the header, -1 if archive write failed + */ +int +ustar_wr(ARCHD *arcn) +{ + return wr_ustar_or_pax(arcn, 1); +} + +/* + * pax_wr() + * Write out a pax format archive. + * Have to check for file types that cannot be stored. Be careful of the + * term (last arg) to ul_oct, we only use '\0' for the termination + * character (this is different than picky tar). + * ASSUMED: space after header in header block is zero filled + * Return: + * 0 if file has data to be written after the header, 1 if file has NO + * data to write after the header, -1 if archive write failed + */ +#ifndef SMALL +int +pax_wr(ARCHD *arcn) +{ + return wr_ustar_or_pax(arcn, 0); +} +#endif + /* * name_split() * see if the name has to be split for storage in a ustar header. We try @@ -1184,12 +1374,6 @@ expandname(char *buf, size_t len, char **gnu_name, const char *name, return(nlen); } -/* shortest possible extended record: "5 a=\n" */ -#define MINXHDRSZ 5 - -/* longest record we'll accept */ -#define MAXXHDRSZ BLKMULT - static int rd_time(struct timespec *ts, const char *keyword, char *p) { diff --git a/lib/libc/arch/DEFS.h b/lib/libc/arch/DEFS.h index 97832c3ea..d9852ecb1 100644 --- a/lib/libc/arch/DEFS.h +++ b/lib/libc/arch/DEFS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: DEFS.h,v 1.1 2022/01/01 23:47:14 guenther Exp $ */ +/* $OpenBSD: DEFS.h,v 1.2 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 2015,2018,2021 Philip Guenther * @@ -67,3 +67,9 @@ #endif #define _END(x) .size x, . - x + +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; diff --git a/lib/libc/arch/aarch64/SYS.h b/lib/libc/arch/aarch64/SYS.h index 8eb2463d4..8f85a31ea 100644 --- a/lib/libc/arch/aarch64/SYS.h +++ b/lib/libc/arch/aarch64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.6 2022/12/08 01:25:43 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.7 2023/12/10 16:45:50 deraadt Exp $ */ /* $NetBSD: SYS.h,v 1.8 2003/08/07 16:42:02 agc Exp $ */ /*- @@ -53,7 +53,8 @@ #define SYSTRAP(x) \ ldr x8, =SYS_ ## x; \ - svc 0; \ +97: svc 0; \ + PINSYSCALL(SYS_ ## x, 97b); \ dsb nsh; \ isb diff --git a/lib/libc/arch/alpha/SYS.h b/lib/libc/arch/alpha/SYS.h index 688864bef..62adccb89 100644 --- a/lib/libc/arch/alpha/SYS.h +++ b/lib/libc/arch/alpha/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.16 2023/12/06 06:15:33 miod Exp $ */ +/* $OpenBSD: SYS.h,v 1.17 2023/12/10 16:45:50 deraadt Exp $ */ /* $NetBSD: SYS.h,v 1.4 1996/10/17 03:03:53 cgd Exp $ */ /* @@ -56,6 +56,12 @@ */ #define _END(x) .size x, . - x +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; + /* * For functions implemented in ASM that aren't syscalls. * END_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names @@ -67,7 +73,8 @@ #define CALLSYS_NOERROR(name) \ ldiq v0, ___CONCAT(SYS_,name); \ - call_pal PAL_OSF1_callsys +97: call_pal PAL_OSF1_callsys; \ + PINSYSCALL(___CONCAT(SYS_,name), 97b) #define CALLSYS_ERROR(name) \ CALLSYS_NOERROR(name); \ diff --git a/lib/libc/arch/amd64/SYS.h b/lib/libc/arch/amd64/SYS.h index ce67ad032..95cee3b60 100644 --- a/lib/libc/arch/amd64/SYS.h +++ b/lib/libc/arch/amd64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.21 2023/01/11 01:55:17 mortimer Exp $ */ +/* $OpenBSD: SYS.h,v 1.22 2023/12/10 16:45:50 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -41,7 +41,11 @@ /* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */ #define TCB_OFFSET_ERRNO 32 -#define SYSTRAP(x) movl $(SYS_ ## x),%eax; movq %rcx, %r10; syscall +#define SYSTRAP(x) \ + movl $(SYS_ ## x),%eax; \ + movq %rcx, %r10; \ +97: syscall; \ + PINSYSCALL(SYS_ ## x, 97b) #define SYSENTRY(x) \ SYSENTRY_HIDDEN(x); \ diff --git a/lib/libc/arch/amd64/gen/setjmp.S b/lib/libc/arch/amd64/gen/setjmp.S index dff42508a..ded7c9ec4 100644 --- a/lib/libc/arch/amd64/gen/setjmp.S +++ b/lib/libc/arch/amd64/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.9 2020/10/21 17:22:59 kettenis Exp $ */ +/* $OpenBSD: setjmp.S,v 1.10 2023/12/10 16:45:51 deraadt Exp $ */ /* $NetBSD: __setjmp14.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $ */ /* @@ -64,7 +64,8 @@ ENTRY(setjmp) movl $1,%edi /* how = SIG_BLOCK */ xorl %esi,%esi /* set = empty */ movl $SYS_sigprocmask,%eax - syscall +99: syscall + PINSYSCALL(SYS_sigprocmask, 99b) movq %r8,%rdi /* restore jmpbuf addr */ movq %rax,(_JB_SIGMASK * 8)(%rdi) @@ -100,7 +101,8 @@ ENTRY(longjmp) movq (_JB_SIGMASK * 8)(%rdi),%rsi /* get set from sc_mask */ movl $3,%edi /* how = SIG_SETMASK */ movl $SYS_sigprocmask,%eax - syscall +98: syscall + PINSYSCALL(SYS_sigprocmask, 98b) movl %r8d,%eax leaq __jmpxor(%rip),%rcx diff --git a/lib/libc/arch/amd64/gen/sigsetjmp.S b/lib/libc/arch/amd64/gen/sigsetjmp.S index 55a10c03d..d26ed4a27 100644 --- a/lib/libc/arch/amd64/gen/sigsetjmp.S +++ b/lib/libc/arch/amd64/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsetjmp.S,v 1.9 2020/10/21 17:22:59 kettenis Exp $ */ +/* $OpenBSD: sigsetjmp.S,v 1.10 2023/12/10 16:45:51 deraadt Exp $ */ /* $NetBSD: __setjmp14.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $ */ /* @@ -62,7 +62,8 @@ ENTRY(sigsetjmp) movl $1,%edi /* how = SIG_BLOCK */ xorl %esi,%esi /* set = empty */ movl $SYS_sigprocmask,%eax - syscall +99: syscall + PINSYSCALL(SYS_sigprocmask, 99b) movq %r8,%rdi /* restore jmpbuf addr */ movq %rax,(_JB_SIGMASK * 8)(%rdi) @@ -100,7 +101,8 @@ ENTRY(siglongjmp) movq (_JB_SIGMASK * 8)(%rdi),%rsi /* get set from sc_mask */ movl $3,%edi /* how = SIG_SETMASK */ movl $SYS_sigprocmask,%eax - syscall +98: syscall + PINSYSCALL(SYS_sigprocmask, 98b) 2: movl %r8d,%eax leaq __jmpxor(%rip),%rcx diff --git a/lib/libc/arch/amd64/sys/tfork_thread.S b/lib/libc/arch/amd64/sys/tfork_thread.S index 8de236b7d..7889e5b14 100644 --- a/lib/libc/arch/amd64/sys/tfork_thread.S +++ b/lib/libc/arch/amd64/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.11 2023/01/11 01:55:17 mortimer Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.12 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 2000 Peter Wemm * Copyright (c) 2003 Alan L. Cox @@ -56,7 +56,8 @@ ENTRY(__tfork_thread) */ movl $SYS___tfork, %eax .cfi_endproc - syscall +99: syscall + PINSYSCALL(SYS___tfork, 99b) jb 2f /* @@ -90,7 +91,8 @@ ENTRY(__tfork_thread) */ movl $SYS___threxit, %eax xorl %edi, %edi - syscall +98: syscall + PINSYSCALL(SYS___threxit, 98b) int3 /* diff --git a/lib/libc/arch/arm/SYS.h b/lib/libc/arch/arm/SYS.h index 037ded405..b6d4407ce 100644 --- a/lib/libc/arch/arm/SYS.h +++ b/lib/libc/arch/arm/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.19 2022/12/08 01:25:43 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.20 2023/12/10 16:45:51 deraadt Exp $ */ /* $NetBSD: SYS.h,v 1.8 2003/08/07 16:42:02 agc Exp $ */ /*- @@ -54,7 +54,8 @@ #define SYSTRAP(x) \ ldr r12, =SYS_ ## x; \ - swi 0; \ +97: swi 0; \ + PINSYSCALL(SYS_ ## x, 97b); \ dsb nsh; \ isb diff --git a/lib/libc/arch/hppa/SYS.h b/lib/libc/arch/hppa/SYS.h index 896bf6fb3..6c0f54747 100644 --- a/lib/libc/arch/hppa/SYS.h +++ b/lib/libc/arch/hppa/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.23 2023/02/11 06:10:39 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.24 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1998-2002 Michael Shalayeff @@ -67,6 +67,11 @@ #define EXIT_WEAK(x) EXIT_STRONG(x) !\ .weak x +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits !\ + .long label !\ + .long sysno !\ + .popsection #define SYSENTRY(x) !\ LEAF_ENTRY(__CONCAT(_thread_sys_,x)) !\ @@ -84,8 +89,9 @@ LEAF_ENTRY(__CONCAT(_thread_sys_,x)) #define SYSCALL(x) !\ stw rp, HPPA_FRAME_ERP(sr0,sp) !\ ldil L%SYSCALLGATE, r1 !\ - ble 4(sr7, r1) !\ - ldi __CONCAT(SYS_,x), t1 !\ +97: ble 4(sr7, r1) !\ + PINSYSCALL(__CONCAT(SYS_,x), 97b) !\ + ldi __CONCAT(SYS_,x), t1 !\ comb,= 0, t1, 1f !\ ldw HPPA_FRAME_ERP(sr0,sp), rp !\ /* set errno */ \ @@ -113,8 +119,9 @@ SYSEXIT_HIDDEN(x) SYSENTRY(x) !\ stw rp, HPPA_FRAME_ERP(sr0,sp) !\ ldil L%SYSCALLGATE, r1 !\ - ble 4(sr7, r1) !\ - ldi __CONCAT(SYS_,y), t1 !\ +97: ble 4(sr7, r1) !\ + PINSYSCALL(__CONCAT(SYS_,x), 97b) !\ + ldi __CONCAT(SYS_,x), t1 !\ ldw HPPA_FRAME_ERP(sr0,sp), rp !\ bv r0(rp) !\ nop !\ diff --git a/lib/libc/arch/hppa/gen/setjmp.S b/lib/libc/arch/hppa/gen/setjmp.S index f8c48db26..e5adf7e8c 100644 --- a/lib/libc/arch/hppa/gen/setjmp.S +++ b/lib/libc/arch/hppa/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.11 2016/05/29 07:59:36 guenther Exp $ */ +/* $OpenBSD: setjmp.S,v 1.12 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -63,7 +63,8 @@ ALTENTRY(setjmp) copy %r0, %arg1 ; set = empty stw %rp, HPPA_FRAME_ERP(%sr0,%sp) ldil L%SYSCALLGATE, %r1 - ble 4(%sr7, %r1) +99: ble 4(%sr7, %r1) + PINSYSCALL(SYS_sigprocmask, 99b) ldi SYS_sigprocmask, %t1 ldw HPPA_FRAME_ERP(%sr0,%sp), %rp @@ -129,7 +130,8 @@ ALTENTRY(longjmp) ldi 3, %arg0 ; how = SIG_SETMASK stw %rp, HPPA_FRAME_ERP(%sr0,%sp) ldil L%SYSCALLGATE, %r1 - ble 4(%sr7, %r1) +98: ble 4(%sr7, %r1) + PINSYSCALL(SYS_sigprocmask, 98b) ldi SYS_sigprocmask, %t1 ldw HPPA_FRAME_ERP(%sr0,%sp), %rp diff --git a/lib/libc/arch/hppa/sys/Ovfork.S b/lib/libc/arch/hppa/sys/Ovfork.S index 8be9141b3..fc8057313 100644 --- a/lib/libc/arch/hppa/sys/Ovfork.S +++ b/lib/libc/arch/hppa/sys/Ovfork.S @@ -1,4 +1,4 @@ -/* $OpenBSD: Ovfork.S,v 1.15 2016/05/07 19:05:21 guenther Exp $ */ +/* $OpenBSD: Ovfork.S,v 1.16 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1999,2002 Michael Shalayeff @@ -32,8 +32,9 @@ SYSENTRY_HIDDEN(vfork) .import errno, data copy rp, t4 ldil L%SYSCALLGATE, r1 - ble 4(sr7, r1) - ldi __CONCAT(SYS_,vfork), t1 +99: ble 4(sr7, r1) + PINSYSCALL(__CONCAT(SYS_,vfork), 99b) + ldi __CONCAT(SYS_,vfork), t1 comb,= r0, t1, 1f copy t4, rp /* set errno */ diff --git a/lib/libc/arch/i386/DEFS.h b/lib/libc/arch/i386/DEFS.h index db2d9696d..c8ae4a29b 100644 --- a/lib/libc/arch/i386/DEFS.h +++ b/lib/libc/arch/i386/DEFS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: DEFS.h,v 1.3 2017/11/29 05:13:57 guenther Exp $ */ +/* $OpenBSD: DEFS.h,v 1.4 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 2017 Philip Guenther * @@ -47,3 +47,9 @@ #else #define END_BUILTIN(x) END_STRONG(x) #endif + +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; diff --git a/lib/libc/arch/i386/SYS.h b/lib/libc/arch/i386/SYS.h index 993ad3171..699744b94 100644 --- a/lib/libc/arch/i386/SYS.h +++ b/lib/libc/arch/i386/SYS.h @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: SYS.h,v 1.27 2017/11/29 05:13:57 guenther Exp $ + * $OpenBSD: SYS.h,v 1.28 2023/12/10 16:45:51 deraadt Exp $ */ #include "DEFS.h" @@ -59,7 +59,9 @@ #define __DO_SYSCALL(x) \ movl $(SYS_ ## x),%eax; \ - int $0x80 + 97: int $0x80; \ + PINSYSCALL(SYS_ ## x, 97b) + #define SET_ERRNO() \ movl %eax,%gs:(TCB_OFFSET_ERRNO); \ diff --git a/lib/libc/arch/i386/gen/setjmp.S b/lib/libc/arch/i386/gen/setjmp.S index 9dbb4ffaf..3d62109bf 100644 --- a/lib/libc/arch/i386/gen/setjmp.S +++ b/lib/libc/arch/i386/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.14 2020/12/13 21:21:32 bluhm Exp $ */ +/* $OpenBSD: setjmp.S,v 1.15 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -59,7 +59,8 @@ ENTRY(setjmp) pushl $1 /* how = SIG_BLOCK */ call 1f 1: movl $(SYS_sigprocmask),%eax - int $0x80 /* leave oset in %eax */ +99: int $0x80 /* leave oset in %eax */ + PINSYSCALL(SYS_sigprocmask, 99b) popl %edx addl $8,%esp addl $__jmpxor-1b,%edx # load cookie address @@ -89,7 +90,8 @@ ENTRY(longjmp) pushl $3 /* how = SIG_SETMASK */ call 1f /* get our eip */ 1: movl $(SYS_sigprocmask),%eax - int $0x80 +98: int $0x80 + PINSYSCALL(SYS_sigprocmask, 98b) popl %ecx addl $8,%esp addl $__jmpxor-1b,%ecx # load cookie address diff --git a/lib/libc/arch/i386/gen/sigsetjmp.S b/lib/libc/arch/i386/gen/sigsetjmp.S index 2c2013257..c34b28dbf 100644 --- a/lib/libc/arch/i386/gen/sigsetjmp.S +++ b/lib/libc/arch/i386/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsetjmp.S,v 1.13 2020/12/13 21:21:32 bluhm Exp $ */ +/* $OpenBSD: sigsetjmp.S,v 1.14 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -47,7 +47,8 @@ ENTRY(sigsetjmp) pushl $1 /* how = SIG_BLOCK */ subl $4,%esp movl $(SYS_sigprocmask),%eax - int $0x80 /* leave oset in %eax */ +99: int $0x80 /* leave oset in %eax */ + PINSYSCALL(SYS_sigprocmask, 99b) addl $12,%esp movl %eax,(_JB_SIGMASK * 4)(%ecx) @@ -81,7 +82,8 @@ ENTRY(siglongjmp) pushl $3 /* how = SIG_SETMASK */ subl $4,%esp movl $(SYS_sigprocmask),%eax - int $0x80 +98: int $0x80 + PINSYSCALL(SYS_sigprocmask, 98b) addl $12,%esp 1: call 2f diff --git a/lib/libc/arch/i386/sys/Ovfork.S b/lib/libc/arch/i386/sys/Ovfork.S index 2c2761866..b827f89fe 100644 --- a/lib/libc/arch/i386/sys/Ovfork.S +++ b/lib/libc/arch/i386/sys/Ovfork.S @@ -1,4 +1,4 @@ -/* $OpenBSD: Ovfork.S,v 1.10 2016/05/07 19:05:21 guenther Exp $ */ +/* $OpenBSD: Ovfork.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -36,7 +36,8 @@ SYSENTRY_HIDDEN(vfork) popl %ecx /* my rta into ecx */ movl $(SYS_vfork),%eax - int $0x80 +99: int $0x80 + PINSYSCALL(SYS_vfork, 99b) HANDLE_ERRNO() jmp *%ecx SYSCALL_END_HIDDEN(vfork) diff --git a/lib/libc/arch/i386/sys/brk.S b/lib/libc/arch/i386/sys/brk.S index a360f96b1..5d485961c 100644 --- a/lib/libc/arch/i386/sys/brk.S +++ b/lib/libc/arch/i386/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.15 2022/12/04 08:22:13 tb Exp $ */ +/* $OpenBSD: brk.S,v 1.16 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -54,7 +54,8 @@ ENTRY_NB(brk) movl %ecx,4(%esp) 1: movl $(SYS_break),%eax - int $0x80 +99: int $0x80 + PINSYSCALL(SYS_break, 99b) jc 2f PIC_PROLOGUE movl PIC_GOT(__curbrk),%edx # set up GOT addressing @@ -71,7 +72,8 @@ ENTRY_NB(brk) movl %ecx,4(%esp) 1: movl $(SYS_break),%eax - int $0x80 +98: int $0x80 + PINSYSCALL(SYS_break, 98b) jc 2f xorl %eax,%eax movl %ecx,__curbrk diff --git a/lib/libc/arch/i386/sys/sbrk.S b/lib/libc/arch/i386/sys/sbrk.S index 4d2ac8baa..675f8d278 100644 --- a/lib/libc/arch/i386/sys/sbrk.S +++ b/lib/libc/arch/i386/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.15 2022/12/04 08:22:13 tb Exp $ */ +/* $OpenBSD: sbrk.S,v 1.16 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -51,7 +51,8 @@ ENTRY_NB(sbrk) movl (%edx),%eax addl %eax,4(%esp) movl $(SYS_break),%eax - int $0x80 +99: int $0x80 + PINSYSCALL(SYS_break, 99b) jc 2f PIC_PROLOGUE movl PIC_GOT(__curbrk),%edx @@ -65,7 +66,8 @@ ENTRY_NB(sbrk) movl __curbrk,%eax addl %eax,4(%esp) movl $(SYS_break),%eax - int $0x80 +98: int $0x80 + PINSYSCALL(SYS_break, 98b) jc 2f movl __curbrk,%eax addl %ecx,__curbrk diff --git a/lib/libc/arch/i386/sys/sigprocmask.S b/lib/libc/arch/i386/sys/sigprocmask.S index 489eabcbf..262744ba4 100644 --- a/lib/libc/arch/i386/sys/sigprocmask.S +++ b/lib/libc/arch/i386/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.12 2016/05/07 19:05:21 guenther Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.13 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -43,7 +43,8 @@ SYSENTRY_HIDDEN(sigprocmask) 1: movl (%ecx),%ecx # fetch indirect ... movl %ecx,8(%esp) # to new mask arg 2: movl $(SYS_sigprocmask),%eax - int $0x80 +99: int $0x80 + PINSYSCALL(SYS_sigprocmask, 99b) jc 1f movl 12(%esp),%ecx # fetch old mask requested testl %ecx,%ecx # test if old mask requested diff --git a/lib/libc/arch/i386/sys/sigsuspend.S b/lib/libc/arch/i386/sys/sigsuspend.S index 88a08c7a1..e93dffb41 100644 --- a/lib/libc/arch/i386/sys/sigsuspend.S +++ b/lib/libc/arch/i386/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.10 2016/05/07 19:05:21 guenther Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -38,7 +38,8 @@ SYSENTRY_HIDDEN(sigsuspend) movl (%eax),%eax # indirect to mask arg movl %eax,4(%esp) movl $(SYS_sigsuspend),%eax - int $0x80 +99: int $0x80 + PINSYSCALL(SYS_sigsuspend, 99b) SET_ERRNO() ret SYSCALL_END_HIDDEN(sigsuspend) diff --git a/lib/libc/arch/i386/sys/tfork_thread.S b/lib/libc/arch/i386/sys/tfork_thread.S index dfafb9139..85e912963 100644 --- a/lib/libc/arch/i386/sys/tfork_thread.S +++ b/lib/libc/arch/i386/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.10 2020/10/18 14:28:17 deraadt Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 2000 Peter Wemm * All rights reserved. @@ -62,7 +62,8 @@ ENTRY(__tfork_thread) pushl 8(%ebp) # push param pushl $0 # slot for return address, ignored by kernel movl $SYS___tfork, %eax - int $0x80 +99: int $0x80 + PINSYSCALL(SYS___tfork, 99b) jb 2f /* @@ -98,7 +99,8 @@ ENTRY(__tfork_thread) pushl $0 # NULL pointer argument to __threxit pushl $0 # slot for return address, ignored by kernel movl $SYS___threxit, %eax - int $0x80 +98: int $0x80 + PINSYSCALL(SYS___threxit, 98b) int3 /* diff --git a/lib/libc/arch/m88k/DEFS.h b/lib/libc/arch/m88k/DEFS.h index 3db1a435f..804636ee8 100644 --- a/lib/libc/arch/m88k/DEFS.h +++ b/lib/libc/arch/m88k/DEFS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: DEFS.h,v 1.3 2016/09/22 18:19:59 guenther Exp $ */ +/* $OpenBSD: DEFS.h,v 1.4 2023/12/10 16:45:51 deraadt Exp $ */ #include @@ -23,3 +23,9 @@ */ #define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x)) #define END_WEAK(x) END_STRONG(x); .weak x + +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; diff --git a/lib/libc/arch/m88k/SYS.h b/lib/libc/arch/m88k/SYS.h index feb08d912..60e54c6b3 100644 --- a/lib/libc/arch/m88k/SYS.h +++ b/lib/libc/arch/m88k/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.25 2018/06/16 16:06:03 guenther Exp $*/ +/* $OpenBSD: SYS.h,v 1.26 2023/12/10 16:45:51 deraadt Exp $*/ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -80,7 +80,8 @@ #define __DO_SYSCALL(x) \ or %r13, %r0, __SYSCALLNAME(SYS_,x); \ - tb0 0, %r0, 450 +97: tb0 0, %r0, 450; \ + PINSYSCALL(__SYSCALLNAME(SYS_,x), 97b) #define __SYSCALL__NOERROR(p,x,y) \ __ENTRY(p,x); \ diff --git a/lib/libc/arch/m88k/sys/brk.S b/lib/libc/arch/m88k/sys/brk.S index f1aecbf68..12270b724 100644 --- a/lib/libc/arch/m88k/sys/brk.S +++ b/lib/libc/arch/m88k/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.14 2015/09/10 13:29:09 guenther Exp $ */ +/* $OpenBSD: brk.S,v 1.15 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -65,7 +65,8 @@ ENTRY(brk) 1: or %r4,%r2,0 or %r13,%r0,__SYSCALLNAME(SYS_,break) - tb0 0,%r0,450 +99: tb0 0,%r0,450 + PINSYSCALL(SYS_break, 99b) #ifdef __PIC__ br 9f #else diff --git a/lib/libc/arch/m88k/sys/sbrk.S b/lib/libc/arch/m88k/sys/sbrk.S index a35804a9e..8c8262500 100644 --- a/lib/libc/arch/m88k/sys/sbrk.S +++ b/lib/libc/arch/m88k/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.14 2015/09/10 13:29:09 guenther Exp $ */ +/* $OpenBSD: sbrk.S,v 1.15 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -64,7 +64,8 @@ ENTRY(sbrk) add %r2,%r2,%r5 or %r4,%r2,0 or %r13,%r0,SYS_break - tb0 0,%r0,450 +99: tb0 0,%r0,450 + PINSYSCALL(SYS_break, 99b) #ifdef __PIC__ br 9f #else diff --git a/lib/libc/arch/m88k/sys/sigpending.S b/lib/libc/arch/m88k/sys/sigpending.S index d3f41f116..15d11c00b 100644 --- a/lib/libc/arch/m88k/sys/sigpending.S +++ b/lib/libc/arch/m88k/sys/sigpending.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigpending.S,v 1.10 2015/09/10 13:29:09 guenther Exp $ */ +/* $OpenBSD: sigpending.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -38,7 +38,8 @@ SYSENTRY(sigpending) or %r4,%r2,0 /* save r2 */ or %r13,%r0,SYS_sigpending - tb0 0,%r0,450 +99: tb0 0,%r0,450 + PINSYSCALL(SYS_sigpending, 99b) br CERROR st %r2,%r4,0 jmp.n %r1 diff --git a/lib/libc/arch/m88k/sys/sigprocmask.S b/lib/libc/arch/m88k/sys/sigprocmask.S index 5ce01f227..ed3763602 100644 --- a/lib/libc/arch/m88k/sys/sigprocmask.S +++ b/lib/libc/arch/m88k/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.12 2015/10/23 04:39:24 guenther Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.13 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -43,7 +43,8 @@ SYSENTRY_HIDDEN(sigprocmask) ld %r3,%r3,0 /* else load set from *set and do it */ 2: or %r13,%r0,SYS_sigprocmask - tb0 0,%r0,450 +99: tb0 0,%r0,450 + PINSYSCALL(SYS_sigprocmask, 99b) br CERROR bcnd eq0,%r4,3f /* if old mask not requested, done */ st %r2,%r4,0 /* otherwise, set it */ diff --git a/lib/libc/arch/m88k/sys/sigsuspend.S b/lib/libc/arch/m88k/sys/sigsuspend.S index 847179c08..5ead0ac77 100644 --- a/lib/libc/arch/m88k/sys/sigsuspend.S +++ b/lib/libc/arch/m88k/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.13 2016/05/07 19:05:21 guenther Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.14 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -45,7 +45,8 @@ SYSENTRY_HIDDEN(sigsuspend) ld %r2,%r2,0 /* dereference the pointer mask */ or %r13,%r0,SYS_sigsuspend - tb0 0,%r0,450 +99: tb0 0,%r0,450 + PINSYSCALL(SYS_sigsuspend, 99b) br CERROR jmp.n %r1 or %r2,%r0,0 diff --git a/lib/libc/arch/m88k/sys/tfork_thread.S b/lib/libc/arch/m88k/sys/tfork_thread.S index e8ba82892..151319e80 100644 --- a/lib/libc/arch/m88k/sys/tfork_thread.S +++ b/lib/libc/arch/m88k/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.7 2020/11/07 02:52:08 aoyama Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.8 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat @@ -34,7 +34,8 @@ */ ENTRY(__tfork_thread) or %r13, %r0, __SYSCALLNAME(SYS_,__tfork) - tb0 0, %r0, 450 /* corrupts r2 and r3 in the child */ +99: tb0 0, %r0, 450 /* corrupts r2 and r3 in the child */ + PINSYSCALL(SYS___tfork, 99b) br CERROR bcnd eq0, %r2, 1f @@ -52,7 +53,8 @@ ENTRY(__tfork_thread) or %r2, %r5, %r0 /* arg */ or %r13, %r0, __SYSCALLNAME(SYS_,__threxit) - tb0 0, %r0, 450 +98: tb0 0, %r0, 450 + PINSYSCALL(SYS___threxit, 98b) NOP tb0 0, %r0, 130 /* breakpoint */ END(__tfork_thread) diff --git a/lib/libc/arch/mips64/SYS.h b/lib/libc/arch/mips64/SYS.h index 0eae2a001..c9ac6b24c 100644 --- a/lib/libc/arch/mips64/SYS.h +++ b/lib/libc/arch/mips64/SYS.h @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: SYS.h,v 1.12 2016/05/07 19:05:22 guenther Exp $ + * $OpenBSD: SYS.h,v 1.13 2023/12/10 16:45:51 deraadt Exp $ */ #include @@ -59,15 +59,16 @@ .size _HIDDEN(x), . - _HIDDEN(x) #define END_WEAK(x) END_STRONG(x); .weak x - #define CERROR __cerror .hidden CERROR # define __ENTRY(p,x) ENTRY(p ## x) -# define __DO_SYSCALL(x) \ - li v0,SYS_ ## x; \ - syscall +# define __DO_SYSCALL(x) \ + li v0,SYS_ ## x; \ + 97: syscall; \ + PINSYSCALL(SYS_ ## x, 97b) \ + # define __LEAF2(p,x,sz) LEAF(p ## x, sz) \ WEAK_ALIAS(x, p ## x); @@ -124,3 +125,8 @@ #define SYSCALL_END(x) __END2(_thread_sys_,x) #define SYSCALL_END_HIDDEN(x) __END2_HIDDEN(_thread_sys_,x) +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; diff --git a/lib/libc/arch/mips64/gen/setjmp.S b/lib/libc/arch/mips64/gen/setjmp.S index 95748045b..bd6ea86ea 100644 --- a/lib/libc/arch/mips64/gen/setjmp.S +++ b/lib/libc/arch/mips64/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.12 2018/01/08 16:44:32 visa Exp $ */ +/* $OpenBSD: setjmp.S,v 1.13 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -60,7 +60,8 @@ LEAF(setjmp, FRAMESZ) li a0, 1 # how = SIG_BLOCK move a1, zero # get current signal mask li v0, SYS_sigprocmask - syscall # mask in v0 +99: syscall # mask in v0 + PINSYSCALL(SYS_sigprocmask, 99b) bne a3, zero, botch REG_S v0, _JB_MASK(a2) # save sc_mask @@ -132,7 +133,8 @@ LEAF(longjmp, FRAMESZ) REG_L a1, _JB_MASK(a2) # load sc_mask li a0, 3 # how = SIG_SETMASK li v0, SYS_sigprocmask - syscall +98: syscall + PINSYSCALL(SYS_sigprocmask, 98b) bne a3, zero, botch REG_L v0, _JB_REGS+ZERO*REGSZ(a2) diff --git a/lib/libc/arch/mips64/sys/brk.S b/lib/libc/arch/mips64/sys/brk.S index f1996672a..a75be841f 100644 --- a/lib/libc/arch/mips64/sys/brk.S +++ b/lib/libc/arch/mips64/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.10 2022/12/08 01:25:43 guenther Exp $ */ +/* $OpenBSD: brk.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -55,7 +55,8 @@ LEAF(brk, FRAMESZ) move a0, v0 # dont allow break < minbrk 1: li v0, SYS_break - syscall +99: syscall + PINSYSCALL(SYS_break, 99b) bne a3, zero, 2f PTR_S a0, __curbrk move v0, zero diff --git a/lib/libc/arch/mips64/sys/sbrk.S b/lib/libc/arch/mips64/sys/sbrk.S index 1647b6136..d5a9197a5 100644 --- a/lib/libc/arch/mips64/sys/sbrk.S +++ b/lib/libc/arch/mips64/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.10 2022/12/08 01:25:43 guenther Exp $ */ +/* $OpenBSD: sbrk.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -52,7 +52,8 @@ LEAF(sbrk, FRAMESZ) PTR_L v1, __curbrk li v0, SYS_break PTR_ADDU a0, a0, v1 # compute current break - syscall +99: syscall + PINSYSCALL(SYS_break, 99b) bne a3, zero, 1f move v0, v1 # return old val of curbrk from above diff --git a/lib/libc/arch/mips64/sys/sigpending.S b/lib/libc/arch/mips64/sys/sigpending.S index f1217070f..fc1be104f 100644 --- a/lib/libc/arch/mips64/sys/sigpending.S +++ b/lib/libc/arch/mips64/sys/sigpending.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigpending.S,v 1.7 2015/10/23 04:39:24 guenther Exp $ */ +/* $OpenBSD: sigpending.S,v 1.8 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -41,7 +41,8 @@ SYSLEAF(sigpending, FRAMESZ) SETUP_GP64(GPOFF, _HIDDEN(sigpending)) .set reorder li v0, SYS_sigpending - syscall +99: syscall + PINSYSCALL(SYS_sigpending, 99b) bne a3, zero, 1f sw v0, 0(a0) move v0, zero diff --git a/lib/libc/arch/mips64/sys/sigprocmask.S b/lib/libc/arch/mips64/sys/sigprocmask.S index 5b079a8a8..2f6d59572 100644 --- a/lib/libc/arch/mips64/sys/sigprocmask.S +++ b/lib/libc/arch/mips64/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.7 2015/10/23 04:39:24 guenther Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.8 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -47,7 +47,8 @@ SYSLEAF_HIDDEN(sigprocmask, FRAMESZ) lw a1, 0(a1) # indirect to new mask arg .Ldoit: li v0, SYS_sigprocmask - syscall +99: syscall + PINSYSCALL(SYS_sigprocmask, 99b) bne a3, zero, .Lerr beq a2, zero, .Lout # test if old mask requested sw v0, 0(a2) # store old mask diff --git a/lib/libc/arch/mips64/sys/sigsuspend.S b/lib/libc/arch/mips64/sys/sigsuspend.S index 6c445f610..e704364d5 100644 --- a/lib/libc/arch/mips64/sys/sigsuspend.S +++ b/lib/libc/arch/mips64/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.7 2016/05/07 19:05:22 guenther Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.8 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -42,7 +42,8 @@ SYSLEAF_HIDDEN(sigsuspend, FRAMESZ) .set reorder lw a0, 0(a0) # indirect to mask arg li v0, SYS_sigsuspend - syscall +99: syscall + PINSYSCALL(SYS_sigsuspend, 99b) bne a3, zero, 1f move v0, zero # should not happen RESTORE_GP64 diff --git a/lib/libc/arch/powerpc/SYS.h b/lib/libc/arch/powerpc/SYS.h index 5ae776435..32677feb5 100644 --- a/lib/libc/arch/powerpc/SYS.h +++ b/lib/libc/arch/powerpc/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.27 2023/02/11 06:10:39 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.28 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1994 * Andrew Cagney. All rights reserved. @@ -64,7 +64,8 @@ #define PSEUDO_NOERROR(x,y) SYSENTRY(x) \ RETGUARD_SETUP(x, %r11, %r12); \ li %r0, SYS_ ## y ; \ - sc; \ + 97: sc; \ + PINSYSCALL(SYS_ ## y, 97b); \ RETGUARD_CHECK(x, %r11, %r12); \ blr; \ __END(x) @@ -72,7 +73,8 @@ #define PSEUDO_HIDDEN(x,y) SYSENTRY_HIDDEN(x) \ RETGUARD_SETUP(x, %r11, %r12); \ li %r0, SYS_ ## y; \ - sc; \ + 97: sc; \ + PINSYSCALL(SYS_ ## y, 97b); \ cmpwi %r0, 0; \ beq+ .L_ret; \ stw %r0, R2_OFFSET_ERRNO(2); \ diff --git a/lib/libc/arch/powerpc/gen/setjmp.S b/lib/libc/arch/powerpc/gen/setjmp.S index e62121eec..879876c8c 100644 --- a/lib/libc/arch/powerpc/gen/setjmp.S +++ b/lib/libc/arch/powerpc/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.14 2022/06/10 01:56:02 guenther Exp $ */ +/* $OpenBSD: setjmp.S,v 1.15 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn. All rights reserved. * @@ -68,7 +68,9 @@ ENTRY(setjmp) li 3, 1 /* how = SIG_BLOCK */ li 4, 0 /* oset = empty */ li 0, SYS_sigprocmask - sc +99: sc + PINSYSCALL(SYS_sigprocmask, 99b) + stw 3, JMP_sig(5) mr 3, 5 ENTRY(_setjmp) @@ -125,7 +127,8 @@ ENTRY(longjmp) li 3, 3 /* how = SIG_SETMASK */ lwz 4, JMP_sig(5) /* oset from the jmpbuf */ li 0, SYS_sigprocmask - sc +98: sc + PINSYSCALL(SYS_sigprocmask, 98b) mr 3, 5 /* restore jmpbuf and val to r3,r4 */ mr 4, 6 diff --git a/lib/libc/arch/powerpc/gen/sigsetjmp.S b/lib/libc/arch/powerpc/gen/sigsetjmp.S index db10a1a83..1b1a5115c 100644 --- a/lib/libc/arch/powerpc/gen/sigsetjmp.S +++ b/lib/libc/arch/powerpc/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsetjmp.S,v 1.8 2022/06/10 01:56:02 guenther Exp $ */ +/* $OpenBSD: sigsetjmp.S,v 1.9 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn. All rights reserved. * @@ -63,7 +63,8 @@ ENTRY(sigsetjmp) li 3, 1 /* how = SIG_BLOCK */ li 4, 0 /* oset = empty */ li 0, SYS_sigprocmask - sc +99: sc + PINSYSCALL(SYS_sigprocmask, 99b) stw 3, JMP_sigmask(5) 1: mflr 6 bcl 20, 31, 2f @@ -122,7 +123,8 @@ ENTRY(siglongjmp) li 3, 3 /* how = SIG_SETMASK */ lwz 4, JMP_sigmask(5) /* oset from the jmpbuf */ li 0, SYS_sigprocmask - sc +98: sc + PINSYSCALL(SYS_sigprocmask, 98b) 1: bcl 20, 31, 2f 2: mflr 9 diff --git a/lib/libc/arch/powerpc/sys/brk.S b/lib/libc/arch/powerpc/sys/brk.S index 9e117ffda..07f3ab42a 100644 --- a/lib/libc/arch/powerpc/sys/brk.S +++ b/lib/libc/arch/powerpc/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.18 2022/12/08 01:25:43 guenther Exp $ */ +/* $OpenBSD: brk.S,v 1.19 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -60,7 +60,8 @@ ENTRY_NB(brk) #endif li 0, SYS_break - sc +99: sc + PINSYSCALL(SYS_break, 99b) /* check for error */ cmpwi 0, 0 diff --git a/lib/libc/arch/powerpc/sys/sbrk.S b/lib/libc/arch/powerpc/sys/sbrk.S index b554245d0..4fb145f45 100644 --- a/lib/libc/arch/powerpc/sys/sbrk.S +++ b/lib/libc/arch/powerpc/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.17 2022/12/08 01:25:43 guenther Exp $ */ +/* $OpenBSD: sbrk.S,v 1.18 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -57,7 +57,8 @@ ENTRY_NB(sbrk) mr 7, 3 li 0, SYS_break - sc +99: sc + PINSYSCALL(SYS_break, 99b) /* check for error */ cmpwi 0, 0 diff --git a/lib/libc/arch/powerpc/sys/sigpending.S b/lib/libc/arch/powerpc/sys/sigpending.S index fa4175149..e61b8c7ec 100644 --- a/lib/libc/arch/powerpc/sys/sigpending.S +++ b/lib/libc/arch/powerpc/sys/sigpending.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigpending.S,v 1.8 2020/11/28 19:49:30 gkoehler Exp $ */ +/* $OpenBSD: sigpending.S,v 1.9 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 2012 Mark Kettenis * @@ -24,7 +24,8 @@ SYSENTRY(sigpending) RETGUARD_SETUP(sigpending, %r11, %r12) mr %r5, %r3 li %r0, SYS_sigpending - sc +99: sc + PINSYSCALL(SYS_sigpending, 99b) stw %r3, 0(%r5) li %r3, 0 RETGUARD_CHECK(sigpending, %r11, %r12) diff --git a/lib/libc/arch/powerpc/sys/sigprocmask.S b/lib/libc/arch/powerpc/sys/sigprocmask.S index bb21c0ca7..980e98af6 100644 --- a/lib/libc/arch/powerpc/sys/sigprocmask.S +++ b/lib/libc/arch/powerpc/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.14 2020/11/28 19:49:30 gkoehler Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.15 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -46,8 +46,9 @@ SYSENTRY_HIDDEN(sigprocmask) .L_do_call: li 0, SYS_sigprocmask - sc - +99: sc + PINSYSCALL(SYS_sigprocmask, 99b) + /* didnt work? */ cmpwi 0, 0 beq+ .L_sigprocmask_ok diff --git a/lib/libc/arch/powerpc/sys/sigsuspend.S b/lib/libc/arch/powerpc/sys/sigsuspend.S index 1c0f2372f..0f2cdfd36 100644 --- a/lib/libc/arch/powerpc/sys/sigsuspend.S +++ b/lib/libc/arch/powerpc/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.7 2020/11/28 19:49:30 gkoehler Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.8 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -35,7 +35,8 @@ SYSENTRY_HIDDEN(sigsuspend) li %r0, SYS_sigsuspend lwz %r3, 0(%r3) /* load the mask */ - sc +99: sc + PINSYSCALL(SYS_sigsuspend, 99b) cmpwi %r0, 0 beq+ .L_ret diff --git a/lib/libc/arch/powerpc/sys/tfork_thread.S b/lib/libc/arch/powerpc/sys/tfork_thread.S index a90bd4ec3..b04bf5beb 100644 --- a/lib/libc/arch/powerpc/sys/tfork_thread.S +++ b/lib/libc/arch/powerpc/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.10 2020/11/28 19:49:30 gkoehler Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 2005 Tim Wiess @@ -22,7 +22,8 @@ ENTRY(__tfork_thread) RETGUARD_SETUP(__tfork_thread, %r11, %r12) /* call __tfork */ li %r0, SYS___tfork - sc +99: sc + PINSYSCALL(SYS___tfork, 99b) cmpwi %r0, 0 bne 1f @@ -38,7 +39,8 @@ ENTRY(__tfork_thread) /* child returned, call __threxit */ li %r0, SYS___threxit - sc +98: sc + PINSYSCALL(SYS___threxit, 98b) .long 0 /* illegal */ 1: diff --git a/lib/libc/arch/powerpc64/DEFS.h b/lib/libc/arch/powerpc64/DEFS.h index f6f20da09..3b8c93320 100644 --- a/lib/libc/arch/powerpc64/DEFS.h +++ b/lib/libc/arch/powerpc64/DEFS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: DEFS.h,v 1.1 2020/06/25 01:59:27 drahn Exp $ */ +/* $OpenBSD: DEFS.h,v 1.2 2023/12/10 16:45:52 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -67,3 +67,9 @@ #else #define END_BUILTIN(x) END_STRONG(x) #endif + +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; diff --git a/lib/libc/arch/powerpc64/SYS.h b/lib/libc/arch/powerpc64/SYS.h index 9964c4809..ea96ed19e 100644 --- a/lib/libc/arch/powerpc64/SYS.h +++ b/lib/libc/arch/powerpc64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.5 2022/12/07 23:25:59 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.6 2023/12/10 16:45:52 deraadt Exp $ */ /*- * Copyright (c) 1994 * Andrew Cagney. All rights reserved. @@ -69,7 +69,8 @@ ENTRY(_thread_sys_ ## x) \ RETGUARD_SETUP(_thread_sys_ ## x, %r11); \ li %r0, SYS_ ## y ; \ - sc ; \ + 97: sc ; \ + PINSYSCALL(SYS_ ## y, 97b); \ RETGUARD_CHECK(_thread_sys_ ## x, %r11); \ blr; \ __END(_thread_sys_,x) @@ -77,7 +78,8 @@ #define PSEUDO_HIDDEN(x,y) ENTRY(_thread_sys_ ## x) \ RETGUARD_SETUP(_thread_sys_ ## x, %r11); \ li %r0, SYS_ ## y ; \ - sc ; \ + 97: sc ; \ + PINSYSCALL(SYS_ ## y, 97b); \ cmpwi %r0, 0 ; \ beq .L_ret ; \ stw %r0, R13_OFFSET_ERRNO(%r13); \ diff --git a/lib/libc/arch/powerpc64/gen/setjmp.S b/lib/libc/arch/powerpc64/gen/setjmp.S index 0d099f506..ea4251994 100644 --- a/lib/libc/arch/powerpc64/gen/setjmp.S +++ b/lib/libc/arch/powerpc64/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.4 2020/10/18 17:51:39 mortimer Exp $ */ +/* $OpenBSD: setjmp.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2020 Dale Rahn. All rights reserved. * @@ -70,7 +70,8 @@ ENTRY(setjmp) li %r3, 1 /* how = SIG_BLOCK */ li %r4, 0 /* oset = empty */ li %r0, SYS_sigprocmask - sc +99: sc + PINSYSCALL(SYS_sigprocmask, 99b) std %r3, JMP_sig(%r5) b 1f nop @@ -130,7 +131,8 @@ ENTRY(longjmp) li %r3, 3 /* how = SIG_SETMASK */ ld %r4, JMP_sig(%r5) /* oset from the jmpbuf */ li %r0, SYS_sigprocmask - sc +98: sc + PINSYSCALL(SYS_sigprocmask, 98b) nop b 1f nop diff --git a/lib/libc/arch/powerpc64/gen/sigsetjmp.S b/lib/libc/arch/powerpc64/gen/sigsetjmp.S index fe5de2eba..7dfcd5ee9 100644 --- a/lib/libc/arch/powerpc64/gen/sigsetjmp.S +++ b/lib/libc/arch/powerpc64/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsetjmp.S,v 1.3 2020/10/19 23:24:17 mortimer Exp $ */ +/* $OpenBSD: sigsetjmp.S,v 1.4 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2020 Dale Rahn. All rights reserved. * @@ -67,7 +67,8 @@ ENTRY(sigsetjmp) li %r3, 1 /* how = SIG_BLOCK */ li %r4, 0 /* oset = empty */ li %r0, SYS_sigprocmask - sc +99: sc + PINSYSCALL(SYS_sigprocmask, 99b) nop std %r3, JMP_sigmask(5) 1: @@ -126,7 +127,8 @@ ENTRY(siglongjmp) li %r3, 3 /* how = SIG_SETMASK */ ld %r4, JMP_sigmask(%r5) /* oset from the jmpbuf */ li %r0, SYS_sigprocmask - sc +98: sc + PINSYSCALL(SYS_sigprocmask, 98b) 1: addis %r9, %r2, __jmpxor@toc@ha addi %r9, %r9, __jmpxor@toc@l diff --git a/lib/libc/arch/powerpc64/sys/brk.S b/lib/libc/arch/powerpc64/sys/brk.S index a101010b3..9aa27fa41 100644 --- a/lib/libc/arch/powerpc64/sys/brk.S +++ b/lib/libc/arch/powerpc64/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.5 2022/12/07 23:25:59 guenther Exp $ */ +/* $OpenBSD: brk.S,v 1.6 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -50,7 +50,8 @@ SYSENTRY(brk) addi %r6, %r6, __curbrk@toc@l /* # %r6 = &__curbrk */ li %r0, SYS_break - sc +99: sc + PINSYSCALL(SYS_break, 99b) /* check for error */ cmpwi %r0, 0 diff --git a/lib/libc/arch/powerpc64/sys/sbrk.S b/lib/libc/arch/powerpc64/sys/sbrk.S index 28f04efa5..3f17a2801 100644 --- a/lib/libc/arch/powerpc64/sys/sbrk.S +++ b/lib/libc/arch/powerpc64/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.4 2020/10/16 23:42:16 deraadt Exp $ */ +/* $OpenBSD: sbrk.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -51,7 +51,8 @@ SYSENTRY(sbrk) mr %r7, %r3 li %r0, SYS_break - sc +99: sc + PINSYSCALL(SYS_break, 99b) /* check for error */ cmpwi %r0, 0 diff --git a/lib/libc/arch/powerpc64/sys/sigpending.S b/lib/libc/arch/powerpc64/sys/sigpending.S index 0af6670dd..488596e86 100644 --- a/lib/libc/arch/powerpc64/sys/sigpending.S +++ b/lib/libc/arch/powerpc64/sys/sigpending.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigpending.S,v 1.2 2020/10/16 23:42:16 deraadt Exp $ */ +/* $OpenBSD: sigpending.S,v 1.3 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2012 Mark Kettenis * @@ -25,7 +25,8 @@ SYSENTRY(sigpending) li %r0, SYS_sigpending mr %r5, %r3 - sc +99: sc + PINSYSCALL(SYS_sigpending, 99b) stw %r3, 0(%r5) li %r3, 0 RETGUARD_CHECK(sigpending, %r11) diff --git a/lib/libc/arch/powerpc64/sys/sigprocmask.S b/lib/libc/arch/powerpc64/sys/sigprocmask.S index 29342cac8..a58331048 100644 --- a/lib/libc/arch/powerpc64/sys/sigprocmask.S +++ b/lib/libc/arch/powerpc64/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.4 2020/10/16 23:42:16 deraadt Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -47,7 +47,8 @@ SYSENTRY_HIDDEN(sigprocmask) lwz %r4, 0(%r4) /* get new mask */ .L_do_call: - sc +99: sc + PINSYSCALL(SYS_sigprocmask, 99b) /* didnt work? */ cmpwi %r0, 0 diff --git a/lib/libc/arch/powerpc64/sys/sigsuspend.S b/lib/libc/arch/powerpc64/sys/sigsuspend.S index 74b5f0f51..e6f4c5eaa 100644 --- a/lib/libc/arch/powerpc64/sys/sigsuspend.S +++ b/lib/libc/arch/powerpc64/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.3 2020/10/16 23:42:16 deraadt Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.4 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -35,7 +35,8 @@ SYSENTRY(sigsuspend) li %r0, SYS_sigsuspend lwz %r3, 0(%r3) /* load the mask */ - sc +99: sc + PINSYSCALL(SYS_sigsuspend, 99b) cmpwi %r0, 0 beq .L_ret diff --git a/lib/libc/arch/powerpc64/sys/tfork_thread.S b/lib/libc/arch/powerpc64/sys/tfork_thread.S index 5a466af74..b2403d7c2 100644 --- a/lib/libc/arch/powerpc64/sys/tfork_thread.S +++ b/lib/libc/arch/powerpc64/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.4 2020/10/19 14:15:29 deraadt Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2005 Tim Wiess @@ -22,7 +22,8 @@ ENTRY(__tfork_thread) RETGUARD_SETUP(__tfork_thread, %r11) li %r0, SYS___tfork - sc +99: sc + PINSYSCALL(SYS___tfork, 99b) cmpwi %r0, 0 bne 1f @@ -39,7 +40,8 @@ ENTRY(__tfork_thread) /* child returned, call __threxit */ li %r0, SYS___threxit - sc +98: sc + PINSYSCALL(SYS___threxit, 98b) .long 0 /* illegal */ 1: stw %r0, R13_OFFSET_ERRNO(%r13) diff --git a/lib/libc/arch/riscv64/DEFS.h b/lib/libc/arch/riscv64/DEFS.h index 90e5eec2a..a2c61dda9 100644 --- a/lib/libc/arch/riscv64/DEFS.h +++ b/lib/libc/arch/riscv64/DEFS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: DEFS.h,v 1.1 2021/04/29 18:39:53 drahn Exp $ */ +/* $OpenBSD: DEFS.h,v 1.2 2023/12/10 16:45:52 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -58,3 +58,8 @@ #define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x)) #define END_WEAK(x) END_STRONG(x); .weak x +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; diff --git a/lib/libc/arch/riscv64/SYS.h b/lib/libc/arch/riscv64/SYS.h index ad2fdf3f5..9857cfbc9 100644 --- a/lib/libc/arch/riscv64/SYS.h +++ b/lib/libc/arch/riscv64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.4 2022/12/02 12:27:08 jca Exp $ */ +/* $OpenBSD: SYS.h,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /*- * Copyright (c) 2020 Brian Bamsch * Copyright (c) 1990 The Regents of the University of California. @@ -56,9 +56,10 @@ #define __END(x) \ __END_HIDDEN(x); END(x) -#define SYSTRAP(x) \ - li t0, SYS_ ## x; \ - ecall +#define SYSTRAP(x) \ + li t0, SYS_ ## x; \ +97: ecall; \ + PINSYSCALL(SYS_ ## x, 97b) #define HANDLE_ERROR() \ beqz t0, 200f; \ diff --git a/lib/libc/arch/riscv64/sys/brk.S b/lib/libc/arch/riscv64/sys/brk.S index 287f28a7f..6a777d143 100644 --- a/lib/libc/arch/riscv64/sys/brk.S +++ b/lib/libc/arch/riscv64/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.4 2022/12/03 15:02:30 jca Exp $ */ +/* $OpenBSD: brk.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2021 Dale Rahn * @@ -38,7 +38,8 @@ ENTRY_NB(brk) lla t1, __curbrk li t0, SYS_break - ecall +99: ecall + PINSYSCALL(SYS_break, 99b) /* check for error */ beqz t0, .L_brk_ok diff --git a/lib/libc/arch/sh/SYS.h b/lib/libc/arch/sh/SYS.h index 6c14b9194..cd5dbeaaf 100644 --- a/lib/libc/arch/sh/SYS.h +++ b/lib/libc/arch/sh/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.13 2023/02/11 06:10:39 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.14 2023/12/10 16:45:52 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -85,6 +85,12 @@ #define __END(x) \ __END_HIDDEN(x); SET_ENTRY_SIZE(x) +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; + #ifdef __ASSEMBLER__ /* * If the system call number fits in a 8-bit signed value (i.e. fits in 7 bits), @@ -94,10 +100,12 @@ .macro systrap num .iflt \num - 128 mov # \num, r0 - trapa #0x80 +97: trapa #0x80 + PINSYSCALL(\num, 97b) .else mov.l 903f, r0 - trapa #0x80 +97: trapa #0x80 + PINSYSCALL(\num, 97b) bra 904f nop .align 2 diff --git a/lib/libc/arch/sh/sys/brk.S b/lib/libc/arch/sh/sys/brk.S index 0ecee462c..5a98da359 100644 --- a/lib/libc/arch/sh/sys/brk.S +++ b/lib/libc/arch/sh/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.8 2022/12/08 02:11:27 guenther Exp $ */ +/* $OpenBSD: brk.S,v 1.9 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: brk.S,v 1.10 2006/01/06 03:58:31 uwe Exp $ */ /*- @@ -69,7 +69,8 @@ ENTRY(brk) #else mov #SYS_break, r0 #endif - trapa #0x80 +99: trapa #0x80 + PINSYSCALL(SYS_break, 99b) bf 2f #ifdef __PIC__ mov.l Lcurbrk, r0 diff --git a/lib/libc/arch/sh/sys/sbrk.S b/lib/libc/arch/sh/sys/sbrk.S index 0f11b4c3d..b86d0eb75 100644 --- a/lib/libc/arch/sh/sys/sbrk.S +++ b/lib/libc/arch/sh/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.8 2022/12/08 02:11:27 guenther Exp $ */ +/* $OpenBSD: sbrk.S,v 1.9 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: sbrk.S,v 1.9 2006/01/06 03:58:31 uwe Exp $ */ /*- @@ -69,7 +69,8 @@ ENTRY(sbrk) #else mov #SYS_break, r0 #endif - trapa #0x80 +99: trapa #0x80 + PINSYSCALL(SYS_break, 99b) bf 1f #ifdef __PIC__ mov.l Lcurbrk, r0 diff --git a/lib/libc/arch/sh/sys/sigprocmask.S b/lib/libc/arch/sh/sys/sigprocmask.S index 74bacc8ae..28841e600 100644 --- a/lib/libc/arch/sh/sys/sigprocmask.S +++ b/lib/libc/arch/sh/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.6 2022/09/02 06:19:04 miod Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.7 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: sigprocmask.S,v 1.6 2003/08/07 16:42:21 agc Exp $ */ /*- @@ -52,7 +52,8 @@ SYSENTRY_HIDDEN(sigprocmask) #else mov #SYS_sigprocmask, r0 #endif - trapa #0x80 +99: trapa #0x80 + PINSYSCALL(SYS_sigprocmask, 99b) bf 4f mov r6, r2 /* fetch old mask requested */ tst r2, r2 /* test if old mask requested */ diff --git a/lib/libc/arch/sh/sys/sigsuspend.S b/lib/libc/arch/sh/sys/sigsuspend.S index 4e2dffbb7..b2e2b25fc 100644 --- a/lib/libc/arch/sh/sys/sigsuspend.S +++ b/lib/libc/arch/sh/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.5 2022/09/02 06:19:04 miod Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.6 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: sigsuspend.S,v 1.5 2003/08/07 16:42:21 agc Exp $ */ /*- @@ -46,7 +46,8 @@ SYSENTRY_HIDDEN(sigsuspend) #else mov #SYS_sigsuspend, r0 #endif - trapa #0x80 +99: trapa #0x80 + PINSYSCALL(SYS_sigsuspend, 99b) SET_ERRNO_AND_RETURN .align 2 diff --git a/lib/libc/arch/sh/sys/tfork_thread.S b/lib/libc/arch/sh/sys/tfork_thread.S index 6a322fe2b..b17f2cffc 100644 --- a/lib/libc/arch/sh/sys/tfork_thread.S +++ b/lib/libc/arch/sh/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.4 2022/09/02 06:19:04 miod Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2007 Miodrag Vallat. @@ -29,7 +29,8 @@ ENTRY(__tfork_thread) #else mov #SYS___tfork, r0 #endif - trapa #0x80 +99: trapa #0x80 + PINSYSCALL(SYS___tfork, 99b) bf 9f tst r0, r0 @@ -53,7 +54,8 @@ ENTRY(__tfork_thread) #else mov #SYS___threxit, r0 #endif - trapa #0x80 +98: trapa #0x80 + PINSYSCALL(SYS___threxit, 98b) 9: /* diff --git a/lib/libc/arch/sparc64/SYS.h b/lib/libc/arch/sparc64/SYS.h index b0fd99d1e..b8b10c809 100644 --- a/lib/libc/arch/sparc64/SYS.h +++ b/lib/libc/arch/sparc64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.17 2022/01/01 23:47:14 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.18 2023/12/10 16:45:52 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -49,8 +49,8 @@ #define __ENTRY(p,x) ENTRY(_CAT(p,x)) ; .weak x; x = _CAT(p,x) #define __ENTRY_HIDDEN(p,x) ENTRY(_CAT(p,x)) -#define __END_HIDDEN(p,x) END(_CAT(p,x)); \ - _HIDDEN_FALIAS(x, _CAT(p,x)); \ +#define __END_HIDDEN(p,x) END(_CAT(p,x)); \ + _HIDDEN_FALIAS(x, _CAT(p,x)); \ END(_HIDDEN(x)) #define __END(p,x) __END_HIDDEN(p,x); END(x) @@ -67,15 +67,30 @@ * Note that it adds a `nop' over what we could do, if we only knew what * came at label 1.... */ -#define _SYSCALL(p,x,y) \ - __ENTRY(p,x); mov _CAT(SYS_,y),%g1; t ST_SYSCALL; bcc 1f; nop; ERROR(); 1: -#define _SYSCALL_HIDDEN(p,x,y) \ - __ENTRY_HIDDEN(p,x); mov _CAT(SYS_,y),%g1; t ST_SYSCALL; bcc 1f; nop; ERROR(); 1: +#define _SYSCALL(p,x,y) \ + __ENTRY(p,x); \ + mov _CAT(SYS_,y),%g1; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,y), 97b); \ + bcc 1f; \ + nop; \ + ERROR(); \ +1: -#define __SYSCALL(p,x) \ +#define _SYSCALL_HIDDEN(p,x,y) \ + __ENTRY_HIDDEN(p,x); \ + mov _CAT(SYS_,y),%g1; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,y), 97b); \ + bcc 1f; \ + nop; \ + ERROR(); \ +1: + +#define __SYSCALL(p,x) \ _SYSCALL(p,x,x) -#define __SYSCALL_HIDDEN(p,x) \ +#define __SYSCALL_HIDDEN(p,x) \ _SYSCALL_HIDDEN(p,x,x) /* @@ -83,19 +98,34 @@ * we use the SYSCALL_G2RFLAG to put the `success' return address in %g2 * and avoid a branch. */ -#define __RSYSCALL(p,x) \ - __ENTRY(p,x); mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; \ - add %o7,8,%g2; t ST_SYSCALL; ERROR(); __END(p,x) -#define __RSYSCALL_HIDDEN(p,x) \ - __ENTRY_HIDDEN(p,x); mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; \ - add %o7,8,%g2; t ST_SYSCALL; ERROR(); __END_HIDDEN(p,x) +#define __RSYSCALL(p,x) \ + __ENTRY(p,x); \ + mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; \ + add %o7,8,%g2; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,x), 97b); \ + ERROR(); \ + __END(p,x) +#define __RSYSCALL_HIDDEN(p,x) \ + __ENTRY_HIDDEN(p,x); \ + mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; \ + add %o7,8,%g2; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,x), 97b); \ + ERROR(); \ + __END_HIDDEN(p,x) /* * PSEUDO(x,y) is like RSYSCALL(y) except that the name is x. */ -#define __PSEUDO(p,x,y) \ - __ENTRY(p,x); mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \ - t ST_SYSCALL; ERROR(); __END(p,x) +#define __PSEUDO(p,x,y) \ + __ENTRY(p,x); \ + mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; \ + add %o7,8,%g2; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,y), 97b); \ + ERROR(); \ + __END(p,x) /* * SYSCALL_NOERROR is like SYSCALL, except it's used for syscalls @@ -103,8 +133,11 @@ * * XXX - This should be optimized. */ -#define __SYSCALL_NOERROR(p,x) \ - __ENTRY(p,x); mov _CAT(SYS_,x),%g1; t ST_SYSCALL +#define __SYSCALL_NOERROR(p,x) \ + __ENTRY(p,x); \ + mov _CAT(SYS_,x),%g1; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,x), 97b) /* * RSYSCALL_NOERROR is like RSYSCALL, except it's used for syscalls @@ -112,16 +145,24 @@ * * XXX - This should be optimized. */ -#define __RSYSCALL_NOERROR(p,x) \ - __ENTRY(p,x); mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \ - t ST_SYSCALL; __END(p,x) +#define __RSYSCALL_NOERROR(p,x) \ + __ENTRY(p,x); \ + mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; \ + add %o7,8,%g2; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,x), 97b); \ + __END(p,x) /* * PSEUDO_NOERROR(x,y) is like RSYSCALL_NOERROR(y) except that the name is x. */ -#define __PSEUDO_NOERROR(p,x,y) \ - __ENTRY(p,x); mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \ - t ST_SYSCALL; __END(p,x) +#define __PSEUDO_NOERROR(p,x,y) \ + __ENTRY(p,x); \ + mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; \ + add %o7,8,%g2; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,y), 97b); \ + __END(p,x) /* * SYSENTRY is for functions that pretend to be syscalls. diff --git a/lib/libc/arch/sparc64/gen/setjmp.S b/lib/libc/arch/sparc64/gen/setjmp.S index 66e4c665d..07f05903c 100644 --- a/lib/libc/arch/sparc64/gen/setjmp.S +++ b/lib/libc/arch/sparc64/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.6 2016/04/28 12:53:47 kettenis Exp $ */ +/* $OpenBSD: setjmp.S,v 1.7 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: setjmp.S,v 1.4 2000/08/28 00:45:59 eeh Exp $ */ /* @@ -53,7 +53,8 @@ ENTRY(setjmp) mov 1, %o0 /* SIG_BLOCK */ mov SYS_sigprocmask, %g1 clr %o1 /* sigprocmask(SIG_BLOCK, 0) */ - t ST_SYSCALL +99: t ST_SYSCALL + PINSYSCALL(SYS_sigprocmask, 99b) stx %o0, [%o3 + 0x10] stx %sp, [%o3 + 0x00] /* store caller's stack pointer */ @@ -68,7 +69,8 @@ ENTRY(longjmp) mov 3, %o0 /* SIG_SETMASK */ ldx [%i0 + 0x10], %o1 mov SYS_sigprocmask, %g1 - t ST_SYSCALL +98: t ST_SYSCALL + PINSYSCALL(SYS_sigprocmask, 98b) ldx [%i0 + 0x00], %fp ldx [%i0 + 0x08], %i7 diff --git a/lib/libc/arch/sparc64/gen/sigsetjmp.S b/lib/libc/arch/sparc64/gen/sigsetjmp.S index feb270979..b7d68fe7f 100644 --- a/lib/libc/arch/sparc64/gen/sigsetjmp.S +++ b/lib/libc/arch/sparc64/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsetjmp.S,v 1.4 2016/05/08 18:29:34 guenther Exp $ */ +/* $OpenBSD: sigsetjmp.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: sigsetjmp.S,v 1.5 2000/08/28 00:45:59 eeh Exp $ */ /* * Copyright (c) 1992, 1993 @@ -43,7 +43,8 @@ ENTRY(sigsetjmp) mov 1, %o0 /* SIG_BLOCK */ mov SYS_sigprocmask, %g1 clr %o1 /* sigprocmask(SIG_BLOCK, 0) */ - t ST_SYSCALL +99: t ST_SYSCALL + PINSYSCALL(SYS_sigprocmask, 99b) stx %o0, [%o3 + 0x10] 1: stx %sp, [%o3 + 0x00] /* store caller's stack pointer */ @@ -62,7 +63,8 @@ ENTRY(siglongjmp) mov 3, %o0 /* SIG_SETMASK */ ldx [%i0 + 0x10], %o1 mov SYS_sigprocmask, %g1 - t ST_SYSCALL +98: t ST_SYSCALL + PINSYSCALL(SYS_sigprocmask, 98b) 1: ldx [%i0 + 0x00], %fp ldx [%i0 + 0x08], %i7 diff --git a/lib/libc/arch/sparc64/sys/brk.S b/lib/libc/arch/sparc64/sys/brk.S index a8636e2e3..bfe6f9f8c 100644 --- a/lib/libc/arch/sparc64/sys/brk.S +++ b/lib/libc/arch/sparc64/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.11 2023/01/13 17:52:08 miod Exp $ */ +/* $OpenBSD: brk.S,v 1.12 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: brk.S,v 1.9 2000/07/25 20:15:40 mycroft Exp $ */ /* @@ -59,7 +59,8 @@ ENTRY_NB(brk) movgu %xcc, %o1, %o0 /* %o0 = minbrk */ mov %o0, %o2 /* save argument to syscall */ mov SYS_break, %g1 - t ST_SYSCALL +99: t ST_SYSCALL + PINSYSCALL(SYS_break, 99b) set __curbrk, %o3 bcc,a,pt %icc, 1f ldx [%o5 + %o3], %o4 @@ -74,7 +75,8 @@ ENTRY_NB(brk) movgu %xcc, %o1, %o0 /* %o0 = minbrk */ mov %o0, %o2 /* save argument to syscall */ mov SYS_break, %g1 - t ST_SYSCALL +98: t ST_SYSCALL + PINSYSCALL(SYS_break, 98b) bcc,a,pt %icc,1f sethi %hi(__curbrk), %g1 ERROR() diff --git a/lib/libc/arch/sparc64/sys/sbrk.S b/lib/libc/arch/sparc64/sys/sbrk.S index 09d2a4f09..0bf04e928 100644 --- a/lib/libc/arch/sparc64/sys/sbrk.S +++ b/lib/libc/arch/sparc64/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.9 2023/01/13 17:52:08 miod Exp $ */ +/* $OpenBSD: sbrk.S,v 1.10 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: sbrk.S,v 1.7 2000/07/25 15:14:46 mycroft Exp $ */ /* @@ -59,7 +59,8 @@ ENTRY_NB(sbrk) add %o3, %o0, %o4 /* %o4 = new break */ mov %o4, %o0 /* copy for syscall */ mov SYS_break, %g1 - t ST_SYSCALL /* break(new_break) */ +99: t ST_SYSCALL /* break(new_break) */ + PINSYSCALL(SYS_break, 99b) bcc,a 1f /* if success, */ mov %o3, %o0 /* set return value */ ERROR() @@ -72,7 +73,8 @@ ENTRY_NB(sbrk) add %o3, %o0, %o4 /* %o4 = new break */ mov %o4, %o0 /* copy for syscall */ mov SYS_break, %g1 - t ST_SYSCALL /* break(new_break) */ +98: t ST_SYSCALL /* break(new_break) */ + PINSYSCALL(SYS_break, 98b) bcc,a 1f /* if success, */ mov %o3, %o0 /* set return value */ ERROR() diff --git a/lib/libc/arch/sparc64/sys/sigpending.S b/lib/libc/arch/sparc64/sys/sigpending.S index 0099c2679..cf52219b6 100644 --- a/lib/libc/arch/sparc64/sys/sigpending.S +++ b/lib/libc/arch/sparc64/sys/sigpending.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigpending.S,v 1.3 2015/09/05 06:22:47 guenther Exp $ */ +/* $OpenBSD: sigpending.S,v 1.4 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -38,7 +38,8 @@ SYSENTRY(sigpending) mov %o0, %o2 /* save pointer */ mov SYS_sigpending, %g1 - t ST_SYSCALL /* sigpending() */ +99: t ST_SYSCALL /* sigpending() */ + PINSYSCALL(SYS_sigpending, 99b) bcc,a 1f /* if success, */ st %o0, [%o2] /* store return value */ ERROR() diff --git a/lib/libc/arch/sparc64/sys/sigprocmask.S b/lib/libc/arch/sparc64/sys/sigprocmask.S index 3d3fa865c..c8266131c 100644 --- a/lib/libc/arch/sparc64/sys/sigprocmask.S +++ b/lib/libc/arch/sparc64/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.4 2015/10/23 04:39:25 guenther Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -46,7 +46,8 @@ SYSENTRY_HIDDEN(sigprocmask) mov 1, %o0 /* ... using sigprocmask(SIG_BLOCK) */ 1: mov SYS_sigprocmask, %g1 - t ST_SYSCALL +99: t ST_SYSCALL + PINSYSCALL(SYS_sigprocmask, 99b) bcc 2f /* if success, */ tst %o2 /* check to see if oset requested */ ERROR() diff --git a/lib/libc/arch/sparc64/sys/sigsuspend.S b/lib/libc/arch/sparc64/sys/sigsuspend.S index 0bede84ef..0ea010741 100644 --- a/lib/libc/arch/sparc64/sys/sigsuspend.S +++ b/lib/libc/arch/sparc64/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.4 2016/05/07 19:05:22 guenther Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -39,6 +39,7 @@ SYSENTRY_HIDDEN(sigsuspend) ld [%o0], %o0 /* indirect to mask argument */ mov SYS_sigsuspend, %g1 - t ST_SYSCALL +99: t ST_SYSCALL + PINSYSCALL(SYS_sigsuspend, 99b) ERROR() /* always terminates with EINTR */ SYSCALL_END_HIDDEN(sigsuspend) diff --git a/lib/libc/arch/sparc64/sys/tfork_thread.S b/lib/libc/arch/sparc64/sys/tfork_thread.S index c879c3e71..4304498b6 100644 --- a/lib/libc/arch/sparc64/sys/tfork_thread.S +++ b/lib/libc/arch/sparc64/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.4 2020/10/18 14:28:18 deraadt Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat @@ -36,7 +36,8 @@ ENTRY(__tfork_thread) * different return paths. */ mov SYS___tfork, %g1 - t ST_SYSCALL +99: t ST_SYSCALL + PINSYSCALL(SYS___tfork, 99b) bcs 9f nop @@ -59,7 +60,8 @@ ENTRY(__tfork_thread) mov SYS___threxit, %g1 clr %o0 - t ST_SYSCALL /* will not return */ +98: t ST_SYSCALL /* will not return */ + PINSYSCALL(SYS___threxit, 98b) unimp 9: diff --git a/libexec/ld.so/aarch64/SYS.h b/libexec/ld.so/aarch64/SYS.h index 08ec2a7b3..c308acf5b 100644 --- a/libexec/ld.so/aarch64/SYS.h +++ b/libexec/ld.so/aarch64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.5 2020/02/18 12:19:11 kettenis Exp $ */ +/* $OpenBSD: SYS.h,v 1.6 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -29,18 +29,25 @@ #include #include -#define SYSTRAP(x) \ - ldr x8, =SYS_ ## x ;\ - svc 0 ;\ - dsb nsh ;\ +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits ;\ + .long label ;\ + .long sysno ;\ + .popsection + +#define SYSTRAP(x) \ + ldr x8, =SYS_ ## x ;\ +99: svc 0 ;\ + PINSYSCALL(SYS_ ## x, 99b) ;\ + dsb nsh ;\ isb -#define DL_SYSCALL(n) \ - .global __CONCAT(_dl_,n) ;\ - .type __CONCAT(_dl_,n)%function ;\ -__CONCAT(_dl_,n): ;\ - RETGUARD_SETUP(__CONCAT(_dl_,n), x15) ;\ - SYSTRAP(n) ;\ - cneg x0, x0, cs /* r0 = -errno */ ;\ - RETGUARD_CHECK(__CONCAT(_dl_,n), x15) ;\ +#define DL_SYSCALL(n) \ + .global __CONCAT(_dl_,n) ;\ + .type __CONCAT(_dl_,n)%function ;\ +__CONCAT(_dl_,n): ;\ + RETGUARD_SETUP(__CONCAT(_dl_,n), x15) ;\ + SYSTRAP(n) ;\ + cneg x0, x0, cs /* r0 = -errno */ ;\ + RETGUARD_CHECK(__CONCAT(_dl_,n), x15) ;\ ret diff --git a/libexec/ld.so/aarch64/ld.script b/libexec/ld.so/aarch64/ld.script index 2635711ac..f2dbd181f 100644 --- a/libexec/ld.so/aarch64/ld.script +++ b/libexec/ld.so/aarch64/ld.script @@ -5,6 +5,7 @@ PHDRS btext PT_LOAD FLAGS (0x08000001); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; + syscalls PT_OPENBSD_SYSCALLS; relro PT_GNU_RELRO; dynamic PT_DYNAMIC; note PT_NOTE; @@ -39,11 +40,20 @@ SECTIONS { *(.openbsd.randomdata .openbsd.randomdata.*) } :data :relro :random + .openbsd.syscalls : + { + *(.openbsd.syscalls .openbsd.syscalls.*) + } :syscalls .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro .dynamic : { *(.dynamic) } :data :relro :dynamic .got : { *(.got.plt) *(.got) } :data :relro . = DATA_SEGMENT_RELRO_END (0, .); + .openbsd.syscalls : + { + *(.openbsd.syscalls .openbsd.syscalls.*) + } :syscalls + /* BOOTDATA */ . = ALIGN(0x1000); boot_data_start = .; diff --git a/libexec/ld.so/alpha/SYS.h b/libexec/ld.so/alpha/SYS.h index 4472afa8a..3d0d14054 100644 --- a/libexec/ld.so/alpha/SYS.h +++ b/libexec/ld.so/alpha/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.3 2023/12/06 06:15:33 miod Exp $ */ +/* $OpenBSD: SYS.h,v 1.4 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 2001 Niklas Hallqvist @@ -61,10 +61,17 @@ * further register saving. */ +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits ;\ + .long label ;\ + .long sysno ;\ + .popsection + #define DL_SYSCALL(c) \ LEAF_NOPROFILE(_dl_##c, irrelevant); \ ldiq v0, SYS_##c; \ - call_pal PAL_OSF1_callsys; \ +99: call_pal PAL_OSF1_callsys; \ + PINSYSCALL(SYS_##c, 99b); \ beq a3, 1f; \ subq zero, v0, v0; /* return -errno */ \ 1: \ diff --git a/libexec/ld.so/alpha/ld.script b/libexec/ld.so/alpha/ld.script index 381dde4e0..33bfb8d8c 100644 --- a/libexec/ld.so/alpha/ld.script +++ b/libexec/ld.so/alpha/ld.script @@ -5,6 +5,7 @@ PHDRS btext PT_LOAD FLAGS (0x08000005); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; + syscalls PT_OPENBSD_SYSCALLS; relro PT_GNU_RELRO; dynamic PT_DYNAMIC; note PT_NOTE; @@ -39,6 +40,10 @@ SECTIONS { *(.openbsd.randomdata .openbsd.randomdata.*) } :data :relro :random + .openbsd.syscalls : + { + *(.openbsd.syscalls .openbsd.syscalls.*) + } :syscalls .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro .dynamic : { *(.dynamic) } :data :relro :dynamic .got : { *(.got.plt) *(.got) } :data :relro diff --git a/libexec/ld.so/amd64/SYS.h b/libexec/ld.so/amd64/SYS.h index 0ac95d77a..e160da920 100644 --- a/libexec/ld.so/amd64/SYS.h +++ b/libexec/ld.so/amd64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.3 2023/04/25 04:11:10 deraadt Exp $ */ +/* $OpenBSD: SYS.h,v 1.4 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 2002,2004 Dale Rahn @@ -30,19 +30,26 @@ #include #include -#define DL_SYSCALL(n) \ - .global __CONCAT(_dl_,n) ;\ - .type __CONCAT(_dl_,n), @function ;\ - .align 16,0xcc ;\ -__CONCAT(_dl_,n): ;\ - endbr64 ;\ - RETGUARD_SETUP(_dl_##n, r11) ;\ - RETGUARD_PUSH(r11) ;\ - movl $(__CONCAT(SYS_,n)), %eax ;\ - movq %rcx, %r10 ;\ - syscall ;\ - jnc 1f ;\ - neg %rax ;\ -1: RETGUARD_POP(r11) ;\ - RETGUARD_CHECK(_dl_##n, r11) ;\ +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits ;\ + .long label ;\ + .long sysno ;\ + .popsection + +#define DL_SYSCALL(n) \ + .global __CONCAT(_dl_,n) ;\ + .type __CONCAT(_dl_,n), @function ;\ + .align 16,0xcc ;\ +__CONCAT(_dl_,n): ;\ + endbr64 ;\ + RETGUARD_SETUP(_dl_##n, r11) ;\ + RETGUARD_PUSH(r11) ;\ + movl $(__CONCAT(SYS_,n)), %eax ;\ + movq %rcx, %r10 ;\ +99: syscall ;\ + PINSYSCALL(__CONCAT(SYS_,n), 99b) ;\ + jnc 1f ;\ + neg %rax ;\ +1: RETGUARD_POP(r11) ;\ + RETGUARD_CHECK(_dl_##n, r11) ;\ ret diff --git a/libexec/ld.so/amd64/ld.script b/libexec/ld.so/amd64/ld.script index 2de6fa42d..12bb242a6 100644 --- a/libexec/ld.so/amd64/ld.script +++ b/libexec/ld.so/amd64/ld.script @@ -5,6 +5,7 @@ PHDRS btext PT_LOAD FLAGS (0x08000005); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; + syscalls PT_OPENBSD_SYSCALLS; relro PT_GNU_RELRO; dynamic PT_DYNAMIC; note PT_NOTE; @@ -43,6 +44,11 @@ SECTIONS .got : { *(.got.plt) *(.got) } :data :relro . = DATA_SEGMENT_RELRO_END (0, .); + .openbsd.syscalls : + { + *(.openbsd.syscalls .openbsd.syscalls.*) + } :syscalls + /* BOOTDATA */ . = ALIGN(0x1000); boot_data_start = .; diff --git a/libexec/ld.so/arm/SYS.h b/libexec/ld.so/arm/SYS.h index 1e8651563..79f59756e 100644 --- a/libexec/ld.so/arm/SYS.h +++ b/libexec/ld.so/arm/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.3 2020/03/13 09:31:26 deraadt Exp $ */ +/* $OpenBSD: SYS.h,v 1.4 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 2004 Dale Rahn @@ -29,18 +29,25 @@ #include #include +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits ;\ + .long label ;\ + .long sysno ;\ + .popsection + #define SYSTRAP(x) \ - ldr r12, =SYS_ ## x; \ - swi 0; \ - dsb nsh; \ + ldr r12, =SYS_ ## x ;\ +99: swi 0 ;\ + PINSYSCALL(SYS_ ## x, 99b) ;\ + dsb nsh ;\ isb -#define DL_SYSCALL(n) \ - .global __CONCAT(_dl_,n) ;\ - .type __CONCAT(_dl_,n)%function ;\ -__CONCAT(_dl_,n): ;\ - SYSTRAP(n) ;\ - bcs .L_cerr ;\ +#define DL_SYSCALL(n) \ + .global __CONCAT(_dl_,n) ;\ + .type __CONCAT(_dl_,n)%function ;\ +__CONCAT(_dl_,n): ;\ + SYSTRAP(n) ;\ + bcs .L_cerr ;\ mov pc, lr .L_cerr: diff --git a/libexec/ld.so/arm/ld.script b/libexec/ld.so/arm/ld.script index ae7cc098e..0d66e23cd 100644 --- a/libexec/ld.so/arm/ld.script +++ b/libexec/ld.so/arm/ld.script @@ -5,6 +5,7 @@ PHDRS btext PT_LOAD FLAGS (0x08000005); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; + syscalls PT_OPENBSD_SYSCALLS; relro PT_GNU_RELRO; dynamic PT_DYNAMIC; note PT_NOTE; @@ -40,6 +41,11 @@ SECTIONS { *(.openbsd.randomdata .openbsd.randomdata.*) } :data :relro :random + .openbsd.syscalls : + { + *(.openbsd.syscalls .openbsd.syscalls.*) + } :syscalls + .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro .dynamic : { *(.dynamic) } :data :relro :dynamic .got : { *(.got.plt) *(.got) } :data :relro diff --git a/libexec/ld.so/hppa/SYS.h b/libexec/ld.so/hppa/SYS.h index a9955a87f..07707835a 100644 --- a/libexec/ld.so/hppa/SYS.h +++ b/libexec/ld.so/hppa/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.1 2017/08/27 21:59:52 deraadt Exp $ */ +/* $OpenBSD: SYS.h,v 1.2 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 2004 Michael Shalayeff @@ -33,17 +33,24 @@ #include #undef _LOCORE -#define DL_SYSCALL(x) \ -ENTRY(__CONCAT(_dl_,x),0) !\ - stw rp, HPPA_FRAME_ERP(sr0,sp) !\ - ldil L%SYSCALLGATE, r1 !\ - ble 4(sr7, r1) !\ - ldi __CONCAT(SYS_,x), t1 !\ - comb,<> r0, t1, _dl_sysexit !\ - ldw HPPA_FRAME_ERP(sr0,sp), rp !\ - bv r0(rp) !\ - nop !\ -_dl_sysexit !\ - bv r0(rp) !\ - sub r0, ret0, ret0 !\ +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits !\ + .long label !\ + .long sysno !\ + .popsection + +#define DL_SYSCALL(x) \ +ENTRY(__CONCAT(_dl_,x),0) !\ + stw rp, HPPA_FRAME_ERP(sr0,sp) !\ + ldil L%SYSCALLGATE, r1 !\ +99: ble 4(sr7, r1) !\ + PINSYSCALL(__CONCAT(SYS_,x), 99b) !\ + ldi __CONCAT(SYS_,x), t1 !\ + comb,<> r0, t1, _dl_sysexit !\ + ldw HPPA_FRAME_ERP(sr0,sp), rp !\ + bv r0(rp) !\ + nop !\ +_dl_sysexit !\ + bv r0(rp) !\ + sub r0, ret0, ret0 !\ EXIT(__CONCAT(_dl_,x)) diff --git a/libexec/ld.so/hppa/ld.script b/libexec/ld.so/hppa/ld.script index 4204e05e6..163c667a7 100644 --- a/libexec/ld.so/hppa/ld.script +++ b/libexec/ld.so/hppa/ld.script @@ -6,6 +6,7 @@ PHDRS pltgot PT_LOAD; data PT_LOAD; random PT_OPENBSD_RANDOMIZE; + syscalls PT_OPENBSD_SYSCALLS; relro PT_GNU_RELRO; dynamic PT_DYNAMIC; note PT_NOTE; @@ -45,6 +46,10 @@ SECTIONS { *(.openbsd.randomdata .openbsd.randomdata.*) } :data :relro :random + .openbsd.syscalls : + { + *(.openbsd.syscalls .openbsd.syscalls.*) + } :syscalls .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro .dynamic : { *(.dynamic) } :data :relro :dynamic . = DATA_SEGMENT_RELRO_END (0, .); diff --git a/libexec/ld.so/i386/SYS.h b/libexec/ld.so/i386/SYS.h index fef0f639d..b714c503b 100644 --- a/libexec/ld.so/i386/SYS.h +++ b/libexec/ld.so/i386/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.1 2017/08/27 21:59:52 deraadt Exp $ */ +/* $OpenBSD: SYS.h,v 1.2 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -30,6 +30,12 @@ #include #include +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits ;\ + .long label ;\ + .long sysno ;\ + .popsection + #define DL_SYSCALL(n) \ .section ".text" ;\ .align 16,0xcc ;\ @@ -37,7 +43,8 @@ .type __CONCAT(_dl_,n),@function ;\ __CONCAT(_dl_,n): ;\ movl $__CONCAT(SYS_, n),%eax; ;\ - int $0x80 ;\ +99: int $0x80 ;\ + PINSYSCALL(__CONCAT(SYS_, n), 99b) ;\ jb .L_cerr ;\ ret diff --git a/libexec/ld.so/i386/ld.script b/libexec/ld.so/i386/ld.script index c96ba5913..555c3741e 100644 --- a/libexec/ld.so/i386/ld.script +++ b/libexec/ld.so/i386/ld.script @@ -5,6 +5,7 @@ PHDRS btext PT_LOAD FLAGS (0x08000005); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; + syscalls PT_OPENBSD_SYSCALLS; relro PT_GNU_RELRO; dynamic PT_DYNAMIC; note PT_NOTE; @@ -38,6 +39,11 @@ SECTIONS { *(.openbsd.randomdata .openbsd.randomdata.*) } :data :relro :random + .openbsd.syscalls : + { + *(.openbsd.syscalls .openbsd.syscalls.*) + } :syscalls + .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro .dynamic : { *(.dynamic) } :data :relro :dynamic .got : { *(.got.plt) *(.got) } :data :relro diff --git a/libexec/ld.so/m88k/SYS.h b/libexec/ld.so/m88k/SYS.h index 79892dfa3..c1528b2bc 100644 --- a/libexec/ld.so/m88k/SYS.h +++ b/libexec/ld.so/m88k/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.4 2019/10/23 19:55:09 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.5 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 2013 Miodrag Vallat. @@ -44,22 +44,29 @@ #include #include +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits ;\ + .long label ;\ + .long sysno ;\ + .popsection + #define __CONCAT(p,x) p##x #define __ENTRY(p,x) ENTRY(__CONCAT(p,x)) #define __SYSCALLNAME(p,x) __CONCAT(p,x) -#define __DO_SYSCALL(x) \ - or %r13, %r0, __SYSCALLNAME(SYS_,x); \ - tb0 0, %r0, 450 +#define __DO_SYSCALL(x) \ + or %r13, %r0, __SYSCALLNAME(SYS_,x) ;\ +99: tb0 0, %r0, 450 ;\ + PINSYSCALL(__SYSCALLNAME(SYS_,x), 99b) /* * m88k syscall return ABI requires the same amount of ASM * whether or not the syscall can possibly fail, so there's * no benefit to a DL_SYSCALL_NOERR() macro. */ -#define DL_SYSCALL(n) \ - __ENTRY(_dl_,n); \ - __DO_SYSCALL(n); \ - subu %r2, %r0, %r2; /* return -errno; */ \ - jmp %r1; \ +#define DL_SYSCALL(n) \ + __ENTRY(_dl_,n) ;\ + __DO_SYSCALL(n) ;\ + subu %r2, %r0, %r2 /* return -errno; */ ;\ + jmp %r1 ;\ END(_dl_##n) diff --git a/libexec/ld.so/m88k/ld.script b/libexec/ld.so/m88k/ld.script index 84c3015fa..fbfa84f86 100644 --- a/libexec/ld.so/m88k/ld.script +++ b/libexec/ld.so/m88k/ld.script @@ -5,6 +5,7 @@ PHDRS btext PT_LOAD FLAGS (0x08000005); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; + scalls PT_OPENBSD_SYSCALLS; relro PT_GNU_RELRO; dynamic PT_DYNAMIC; note PT_NOTE; @@ -36,6 +37,9 @@ SECTIONS . = DATA_SEGMENT_ALIGN (0x10000, 0x1000); .openbsd.randomdata : { *(.openbsd.randomdata .openbsd.randomdata.*) } :data :relro :random + .openbsd.syscalls : { *(.openbsd.syscalls .openbsd.syscalls.*) } + :syscalls + .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro .dynamic : { *(.dynamic) } :data :relro :dynamic .got : { *(.got.plt) *(.got) } :data :relro diff --git a/libexec/ld.so/mips64/SYS.h b/libexec/ld.so/mips64/SYS.h index b6a4fd464..1dbc8a7e0 100644 --- a/libexec/ld.so/mips64/SYS.h +++ b/libexec/ld.so/mips64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.1 2017/08/27 21:59:52 deraadt Exp $ */ +/* $OpenBSD: SYS.h,v 1.2 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 1998-2002 Opsycon AB, Sweden. @@ -29,14 +29,21 @@ #include #include -#define DL_SYSCALL(c) \ -NLEAF(_dl_##c,0) \ - li v0,SYS_##c; \ - syscall; \ - bnez a3, 1f; \ - j ra; \ -1: ; \ - subu v0, zero, v0; \ - j ra ; \ +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits ;\ + .long label ;\ + .long sysno ;\ + .popsection + +#define DL_SYSCALL(c) \ +NLEAF(_dl_##c,0) \ + li v0,SYS_##c; \ +99: syscall; \ + PINSYSCALL(SYS_##c, 99b); \ + bnez a3, 1f; \ + j ra; \ +1: ; \ + subu v0, zero, v0; \ + j ra; \ END(_dl_##c) diff --git a/libexec/ld.so/mips64/ld.script b/libexec/ld.so/mips64/ld.script index 63d114fac..a1392fb23 100644 --- a/libexec/ld.so/mips64/ld.script +++ b/libexec/ld.so/mips64/ld.script @@ -5,6 +5,7 @@ PHDRS btext PT_LOAD FLAGS (0x08000005); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; + syscalls PT_OPENBSD_SYSCALLS; relro PT_GNU_RELRO; dynamic PT_DYNAMIC; note PT_NOTE; @@ -39,6 +40,11 @@ SECTIONS { *(.openbsd.randomdata .openbsd.randomdata.*) } :data :relro :random + .openbsd.syscalls : + { + *(.openbsd.syscalls .openbsd.syscalls.*) + } :syscalls + .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro .dynamic : { *(.dynamic) } :data :relro :dynamic _gp = ALIGN(16) + 0x7ff0; diff --git a/libexec/ld.so/powerpc/SYS.h b/libexec/ld.so/powerpc/SYS.h index 7e1a7962e..9da670134 100644 --- a/libexec/ld.so/powerpc/SYS.h +++ b/libexec/ld.so/powerpc/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.4 2020/11/28 19:49:30 gkoehler Exp $ */ +/* $OpenBSD: SYS.h,v 1.5 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -29,14 +29,21 @@ #include #include -#define DL_SYSCALL(n) \ -ENTRY(_dl_##n) \ - RETGUARD_SETUP(_dl_##n, %r11, %r12) ;\ - li 0, SYS_##n ;\ - sc ;\ - cmpwi 0, 0 ;\ - beq+ .L_end##n ;\ - neg 3, 3 ;\ -.L_end##n: ;\ - RETGUARD_CHECK(_dl_##n, %r11, %r12) ;\ +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits ;\ + .long label ;\ + .long sysno ;\ + .popsection + +#define DL_SYSCALL(n) \ +ENTRY(_dl_##n) \ + RETGUARD_SETUP(_dl_##n, %r11, %r12) ;\ + li 0, SYS_##n ;\ +99: sc ;\ + PINSYSCALL(SYS_##n, 99b) ;\ + cmpwi 0, 0 ;\ + beq+ .L_end##n ;\ + neg 3, 3 ;\ +.L_end##n: ;\ + RETGUARD_CHECK(_dl_##n, %r11, %r12) ;\ blr diff --git a/libexec/ld.so/powerpc/ld.script b/libexec/ld.so/powerpc/ld.script index c445283a0..afd66c5af 100644 --- a/libexec/ld.so/powerpc/ld.script +++ b/libexec/ld.so/powerpc/ld.script @@ -5,6 +5,7 @@ PHDRS btext PT_LOAD FLAGS (0x08000005); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; + syscalls PT_OPENBSD_SYSCALLS; relro PT_GNU_RELRO; dynamic PT_DYNAMIC; note PT_NOTE; @@ -39,6 +40,11 @@ SECTIONS { *(.openbsd.randomdata .openbsd.randomdata.*) } :data :relro :random + .openbsd.syscalls : + { + *(.openbsd.syscalls .openbsd.syscalls.*) + } :syscalls + .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro .dynamic : { *(.dynamic) } :data :relro :dynamic .got : { *(.got.plt) *(.got) } :data :relro diff --git a/libexec/ld.so/powerpc64/SYS.h b/libexec/ld.so/powerpc64/SYS.h index 23d084146..7671f3606 100644 --- a/libexec/ld.so/powerpc64/SYS.h +++ b/libexec/ld.so/powerpc64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.2 2020/10/16 23:42:53 deraadt Exp $ */ +/* $OpenBSD: SYS.h,v 1.3 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -29,14 +29,21 @@ #include #include -#define DL_SYSCALL(n) \ -ENTRY(_dl_##n) \ - RETGUARD_SETUP(_dl_##n, %r11) ;\ - li %r0, SYS_##n ;\ - sc ;\ - cmpdi %r0, 0 ;\ - beq .L_end##n ;\ - neg %r3, %r3 ;\ -.L_end##n: ;\ - RETGUARD_CHECK(_dl_##n, %r11) ;\ +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits ;\ + .long label ;\ + .long sysno ;\ + .popsection + +#define DL_SYSCALL(n) \ +ENTRY(_dl_##n) \ + RETGUARD_SETUP(_dl_##n, %r11) ;\ + li %r0, SYS_##n ;\ +99: sc ;\ + PINSYSCALL(SYS_##n, 99b) ;\ + cmpdi %r0, 0 ;\ + beq .L_end##n ;\ + neg %r3, %r3 ;\ +.L_end##n: ;\ + RETGUARD_CHECK(_dl_##n, %r11) ;\ blr diff --git a/libexec/ld.so/powerpc64/ld.script b/libexec/ld.so/powerpc64/ld.script index e9e600245..32eb13980 100644 --- a/libexec/ld.so/powerpc64/ld.script +++ b/libexec/ld.so/powerpc64/ld.script @@ -5,6 +5,7 @@ PHDRS text PT_LOAD FLAGS (1); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; + syscalls PT_OPENBSD_SYSCALLS; relro PT_GNU_RELRO; dynamic PT_DYNAMIC; note PT_NOTE; @@ -38,6 +39,11 @@ SECTIONS { *(.openbsd.randomdata .openbsd.randomdata.*) } :data :relro :random + .openbsd.syscalls : + { + *(.openbsd.syscalls .openbsd.syscalls.*) + } :syscalls + .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro .dynamic : { *(.dynamic) } :data :relro :dynamic .got : { *(.got.plt) *(.got) } :data :relro diff --git a/libexec/ld.so/riscv64/SYS.h b/libexec/ld.so/riscv64/SYS.h index 2e7882fc0..3d6537fae 100644 --- a/libexec/ld.so/riscv64/SYS.h +++ b/libexec/ld.so/riscv64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.1 2021/04/28 15:16:26 drahn Exp $ */ +/* $OpenBSD: SYS.h,v 1.2 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -29,19 +29,26 @@ #include #include -#define SYSTRAP(x) \ - li t0, SYS_ ## x ;\ - ecall ;\ +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits ;\ + .long label ;\ + .long sysno ;\ + .popsection + +#define SYSTRAP(x) \ + li t0, SYS_ ## x ;\ +99: ecall ;\ + PINSYSCALL(SYS_ ## x, 99b) /* XXX fence */ -#define DL_SYSCALL(n) \ - .global __CONCAT(_dl_,n) ;\ - .type __CONCAT(_dl_,n)%function ;\ -__CONCAT(_dl_,n): ;\ - RETGUARD_SETUP(__CONCAT(_dl_,n), x15) ;\ - SYSTRAP(n) ;\ - beqz t0, 1f ;\ - sub a0, zero, a0 /* r0 = -errno */ ;\ -1: ;\ - RETGUARD_CHECK(__CONCAT(_dl_,n), x15) ;\ +#define DL_SYSCALL(n) \ + .global __CONCAT(_dl_,n) ;\ + .type __CONCAT(_dl_,n)%function ;\ +__CONCAT(_dl_,n): ;\ + RETGUARD_SETUP(__CONCAT(_dl_,n), x15) ;\ + SYSTRAP(n) ;\ + beqz t0, 1f ;\ + sub a0, zero, a0 /* r0 = -errno */ ;\ +1: ;\ + RETGUARD_CHECK(__CONCAT(_dl_,n), x15) ;\ ret diff --git a/libexec/ld.so/riscv64/ld.script b/libexec/ld.so/riscv64/ld.script index 24a13ea9c..7050c4a99 100644 --- a/libexec/ld.so/riscv64/ld.script +++ b/libexec/ld.so/riscv64/ld.script @@ -5,6 +5,7 @@ PHDRS btext PT_LOAD FLAGS (0x08000005); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; + syscalls PT_OPENBSD_SYSCALLS; relro PT_GNU_RELRO; dynamic PT_DYNAMIC; note PT_NOTE; @@ -39,6 +40,11 @@ SECTIONS { *(.openbsd.randomdata .openbsd.randomdata.*) } :data :relro :random + .openbsd.syscalls : + { + *(.openbsd.syscalls .openbsd.syscalls.*) + } :syscalls + .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro .dynamic : { *(.dynamic) } :data :relro :dynamic .got : { *(.got.plt) *(.got) } :data :relro diff --git a/libexec/ld.so/sh/SYS.h b/libexec/ld.so/sh/SYS.h index f9062bf1b..4f9350229 100644 --- a/libexec/ld.so/sh/SYS.h +++ b/libexec/ld.so/sh/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.2 2022/09/02 06:19:05 miod Exp $ */ +/* $OpenBSD: SYS.h,v 1.3 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 2006 Dale Rahn @@ -29,6 +29,12 @@ #include #include +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits ;\ + .long label ;\ + .long sysno ;\ + .popsection + #ifdef __ASSEMBLER__ /* * If the system call number fits in a 8-bit signed value (i.e. fits in 7 bits), @@ -38,10 +44,12 @@ .macro systrap num .iflt \num - 128 mov # \num, r0 - trapa #0x80 +99: trapa #0x80 + PINSYSCALL(\num, 99b) .else mov.l 903f, r0 - trapa #0x80 +99: trapa #0x80 + PINSYSCALL(\num, 99b) bra 904f nop .align 2 @@ -51,17 +59,17 @@ .endm #endif -#define SYSTRAP(x) \ - systrap SYS_ ## x +#define SYSTRAP(x) \ + systrap SYS_ ## x -#define DL_SYSCALL(n) \ - .global __CONCAT(_dl_,n) ;\ - .type __CONCAT(_dl_,n)%function ;\ -__CONCAT(_dl_,n): ;\ - SYSTRAP(n) ;\ - bf .L_cerr ;\ - nop ;\ - rts ;\ +#define DL_SYSCALL(n) \ + .global __CONCAT(_dl_,n) ;\ + .type __CONCAT(_dl_,n)%function ;\ +__CONCAT(_dl_,n): ;\ + SYSTRAP(n) ;\ + bf .L_cerr ;\ + nop ;\ + rts ;\ nop .L_cerr: diff --git a/libexec/ld.so/sh/ld.script b/libexec/ld.so/sh/ld.script index 1842ee9c1..d5a87d7e8 100644 --- a/libexec/ld.so/sh/ld.script +++ b/libexec/ld.so/sh/ld.script @@ -5,6 +5,7 @@ PHDRS btext PT_LOAD FLAGS (0x08000005); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; + syscalls PT_OPENBSD_SYSCALLS; relro PT_GNU_RELRO; dynamic PT_DYNAMIC; note PT_NOTE; @@ -35,6 +36,7 @@ SECTIONS . = DATA_SEGMENT_ALIGN (0x10000, 0x1000); .openbsd.randomdata : { *(.openbsd.randomdata .openbsd.randomdata.*) } :data :relro :random + .openbsd.syscalls : { *(.openbsd.syscalls .openbsd.syscalls.*) } :syscalls .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro .dynamic : { *(.dynamic) } :data :relro :dynamic .got : { *(.got.plt) *(.got) } :data :relro diff --git a/libexec/ld.so/sparc64/SYS.h b/libexec/ld.so/sparc64/SYS.h index 2a226c353..7a29f2b57 100644 --- a/libexec/ld.so/sparc64/SYS.h +++ b/libexec/ld.so/sparc64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.4 2021/12/14 07:20:16 deraadt Exp $ */ +/* $OpenBSD: SYS.h,v 1.5 2023/12/10 16:45:50 deraadt Exp $ */ /* $NetBSD: rtld_start.S,v 1.5 2001/08/14 22:17:48 eeh Exp $ */ /* @@ -68,14 +68,21 @@ #include #include +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits ;\ + .long label ;\ + .long sysno ;\ + .popsection + #define __CONCAT(x,y) x##y -#define DL_SYSCALL(n) \ -_ENTRY(__CONCAT(_dl_,n)) \ - mov __CONCAT(SYS_,n) | SYSCALL_G2RFLAG, %g1 ;\ - add %o7, 8, %g2 ;\ - t ST_SYSCALL ;\ - retl ;\ +#define DL_SYSCALL(n) \ +_ENTRY(__CONCAT(_dl_,n)) \ + mov __CONCAT(SYS_,n) | SYSCALL_G2RFLAG, %g1 ;\ + add %o7, 8, %g2 ;\ +99: t ST_SYSCALL ;\ + PINSYSCALL(__CONCAT(SYS_,n), 99b) ;\ + retl ;\ sub %g0, %o0, %o0 diff --git a/libexec/ld.so/sparc64/ld.script b/libexec/ld.so/sparc64/ld.script index 7bfd96636..e7b0c06c9 100644 --- a/libexec/ld.so/sparc64/ld.script +++ b/libexec/ld.so/sparc64/ld.script @@ -5,6 +5,7 @@ PHDRS btext PT_LOAD FLAGS (0x08000005); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; + syscalls PT_OPENBSD_SYSCALLS; relro PT_GNU_RELRO; dynamic PT_DYNAMIC; note PT_NOTE; @@ -39,6 +40,10 @@ SECTIONS { *(.openbsd.randomdata .openbsd.randomdata.*) } :data :relro :random + .openbsd.syscalls : + { + *(.openbsd.syscalls .openbsd.syscalls.*) + } :syscalls .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro .dynamic : { *(.dynamic) } :data :relro :dynamic .got : { *(.got.plt) *(.got) } :data :relro diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S index 51933adda..d1cc97d0a 100644 --- a/sys/arch/amd64/amd64/locore.S +++ b/sys/arch/amd64/amd64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.141 2023/10/24 13:20:09 claudio Exp $ */ +/* $OpenBSD: locore.S,v 1.142 2023/12/10 16:56:01 deraadt Exp $ */ /* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */ /* @@ -176,6 +176,8 @@ sigcode: movq %rsp,%rdi pushq %rdi /* fake return address */ movq $SYS_sigreturn,%rax + .globl sigcodecall +sigcodecall: syscall .globl sigcoderet sigcoderet: diff --git a/sys/arch/arm/arm/sigcode.S b/sys/arch/arm/arm/sigcode.S index b59e9fce7..35442f8f9 100644 --- a/sys/arch/arm/arm/sigcode.S +++ b/sys/arch/arm/arm/sigcode.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigcode.S,v 1.12 2022/12/08 01:25:44 guenther Exp $ */ +/* $OpenBSD: sigcode.S,v 1.13 2023/12/10 16:56:01 deraadt Exp $ */ /* $NetBSD: sigcode.S,v 1.6 2003/10/05 19:44:58 matt Exp $ */ /* @@ -56,6 +56,8 @@ sigcode: /* mov r0, sp */ add r0, sp, #SIGF_SC mov r12, #SYS_sigreturn + .globl sigcodecall +sigcodecall: swi 0 dsb nsh isb diff --git a/sys/arch/arm64/arm64/locore.S b/sys/arch/arm64/arm64/locore.S index b385983a6..51fbfff4f 100644 --- a/sys/arch/arm64/arm64/locore.S +++ b/sys/arch/arm64/arm64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.43 2023/01/26 13:09:18 kettenis Exp $ */ +/* $OpenBSD: locore.S,v 1.44 2023/12/10 16:56:01 deraadt Exp $ */ /*- * Copyright (c) 2012-2014 Andrew Turner * All rights reserved. @@ -365,6 +365,8 @@ sigcode: add x0, x0, #SF_SC mov x8, #SYS_sigreturn + .globl sigcodecall +sigcodecall: svc 0 dsb nsh isb diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s index 2d80d10a7..c3a749702 100644 --- a/sys/arch/i386/i386/locore.s +++ b/sys/arch/i386/i386/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.202 2023/10/24 13:20:10 claudio Exp $ */ +/* $OpenBSD: locore.s,v 1.203 2023/12/10 16:56:01 deraadt Exp $ */ /* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */ /*- @@ -341,6 +341,8 @@ sigcode: pushl %eax pushl %eax # junk to fake return address movl $SYS_sigreturn,%eax + .globl sigcodecall +sigcodecall: int $0x80 # enter kernel with args on stack .globl sigcoderet sigcoderet: diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c index 30c897476..72895bc3e 100644 --- a/sys/dev/usb/uaudio.c +++ b/sys/dev/usb/uaudio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uaudio.c,v 1.173 2023/06/27 09:28:08 ratchov Exp $ */ +/* $OpenBSD: uaudio.c,v 1.174 2023/12/10 06:32:14 ratchov Exp $ */ /* * Copyright (c) 2018 Alexandre Ratchov * @@ -2584,7 +2584,6 @@ uaudio_process_as(struct uaudio_softc *sc, } } - while (p->rptr != p->wptr) { savep = p->rptr; if (!uaudio_getdesc(p, &dp)) @@ -2710,6 +2709,7 @@ int uaudio_process_conf(struct uaudio_softc *sc, struct uaudio_blob *p) { struct uaudio_blob dp; + struct uaudio_alt *a; unsigned int type, ifnum, altnum, nep, class, subclass; while (p->rptr != p->wptr) { @@ -2736,7 +2736,10 @@ uaudio_process_conf(struct uaudio_softc *sc, struct uaudio_blob *p) switch (subclass) { case UISUBCLASS_AUDIOCONTROL: - usbd_claim_iface(sc->udev, ifnum); + if (usbd_iface_claimed(sc->udev, ifnum)) { + DPRINTF("%s: %d: AC already claimed\n", __func__, ifnum); + break; + } if (sc->unit_list != NULL) { DPRINTF("%s: >1 AC ifaces\n", __func__); goto done; @@ -2745,7 +2748,10 @@ uaudio_process_conf(struct uaudio_softc *sc, struct uaudio_blob *p) return 0; break; case UISUBCLASS_AUDIOSTREAM: - usbd_claim_iface(sc->udev, ifnum); + if (usbd_iface_claimed(sc->udev, ifnum)) { + DPRINTF("%s: %d: AS already claimed\n", __func__, ifnum); + break; + } if (nep == 0) { DPRINTF("%s: " "stop altnum %d\n", __func__, altnum); @@ -2758,6 +2764,15 @@ uaudio_process_conf(struct uaudio_softc *sc, struct uaudio_blob *p) done: uaudio_fixup_params(sc); + /* + * Claim all interfaces we use. This prevents other uaudio(4) + * devices from trying to use them. + */ + for (a = sc->alts; a != NULL; a = a->next) + usbd_claim_iface(sc->udev, a->ifnum); + + usbd_claim_iface(sc->udev, sc->ctl_ifnum); + return 1; } diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c index a0934eb6f..e06170a9a 100644 --- a/sys/kern/init_sysent.c +++ b/sys/kern/init_sysent.c @@ -1,10 +1,10 @@ -/* $OpenBSD: init_sysent.c,v 1.270 2023/12/07 14:00:16 deraadt Exp $ */ +/* $OpenBSD: init_sysent.c,v 1.271 2023/12/10 16:59:51 deraadt Exp $ */ /* * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * created from; OpenBSD: syscalls.master,v 1.252 2023/12/07 13:59:04 deraadt Exp + * created from; OpenBSD: syscalls.master,v 1.253 2023/12/10 16:59:09 deraadt Exp */ #include diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c index e3d56d1c4..b009ec93c 100644 --- a/sys/kern/syscalls.c +++ b/sys/kern/syscalls.c @@ -1,10 +1,10 @@ -/* $OpenBSD: syscalls.c,v 1.268 2023/12/07 14:00:16 deraadt Exp $ */ +/* $OpenBSD: syscalls.c,v 1.269 2023/12/10 16:59:51 deraadt Exp $ */ /* * System call names. * * DO NOT EDIT-- this file is automatically generated. - * created from; OpenBSD: syscalls.master,v 1.252 2023/12/07 13:59:04 deraadt Exp + * created from; OpenBSD: syscalls.master,v 1.253 2023/12/10 16:59:09 deraadt Exp */ const char *const syscallnames[] = { diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 20215e6a2..ac0b924b8 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -1,4 +1,4 @@ -; $OpenBSD: syscalls.master,v 1.252 2023/12/07 13:59:04 deraadt Exp $ +; $OpenBSD: syscalls.master,v 1.253 2023/12/10 16:59:09 deraadt Exp $ ; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -307,7 +307,7 @@ 156 OBSOL ogetdirentries 157 OBSOL statfs25 158 STD { int sys_pinsyscalls(void *base, size_t len, \ - void *pins, size_t pinslen); } + uint *pins, size_t pinslen); } 159 STD { int sys_mimmutable(void *addr, size_t len); } 160 STD { int sys_waitid(int idtype, id_t id, \ siginfo_t *info, int options); } diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h index ceebcffd5..c013e0dc1 100644 --- a/sys/sys/syscall.h +++ b/sys/sys/syscall.h @@ -1,10 +1,10 @@ -/* $OpenBSD: syscall.h,v 1.267 2023/12/07 14:00:15 deraadt Exp $ */ +/* $OpenBSD: syscall.h,v 1.268 2023/12/10 16:59:51 deraadt Exp $ */ /* * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * created from; OpenBSD: syscalls.master,v 1.252 2023/12/07 13:59:04 deraadt Exp + * created from; OpenBSD: syscalls.master,v 1.253 2023/12/10 16:59:09 deraadt Exp */ /* syscall: "syscall" ret: "int" args: "int" "..." */ @@ -446,7 +446,7 @@ /* 156 is obsolete ogetdirentries */ /* 157 is obsolete statfs25 */ -/* syscall: "pinsyscalls" ret: "int" args: "void *" "size_t" "void *" "size_t" */ +/* syscall: "pinsyscalls" ret: "int" args: "void *" "size_t" "uint *" "size_t" */ #define SYS_pinsyscalls 158 /* syscall: "mimmutable" ret: "int" args: "void *" "size_t" */ diff --git a/sys/sys/syscallargs.h b/sys/sys/syscallargs.h index d91d1c745..25d648c66 100644 --- a/sys/sys/syscallargs.h +++ b/sys/sys/syscallargs.h @@ -1,10 +1,10 @@ -/* $OpenBSD: syscallargs.h,v 1.270 2023/12/07 14:00:15 deraadt Exp $ */ +/* $OpenBSD: syscallargs.h,v 1.271 2023/12/10 16:59:51 deraadt Exp $ */ /* * System call argument lists. * * DO NOT EDIT-- this file is automatically generated. - * created from; OpenBSD: syscalls.master,v 1.252 2023/12/07 13:59:04 deraadt Exp + * created from; OpenBSD: syscalls.master,v 1.253 2023/12/10 16:59:09 deraadt Exp */ #ifdef syscallarg @@ -753,7 +753,7 @@ struct sys_nfssvc_args { struct sys_pinsyscalls_args { syscallarg(void *) base; syscallarg(size_t) len; - syscallarg(void *) pins; + syscallarg(uint *) pins; syscallarg(size_t) pinslen; }; diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c index 97d1cb5d6..bd0ed8daa 100644 --- a/usr.bin/sndiod/dev.c +++ b/usr.bin/sndiod/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.106 2022/12/26 19:16:03 jmc Exp $ */ +/* $OpenBSD: dev.c,v 1.107 2023/12/09 22:12:03 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov * @@ -1389,7 +1389,7 @@ dev_migrate(struct dev *odev) if (s->opt == NULL || s->opt->dev != odev) continue; if (s->ops != NULL) { - s->ops->exit(s); + s->ops->exit(s->arg); s->ops = NULL; } } diff --git a/usr.sbin/rpki-client/cert.c b/usr.sbin/rpki-client/cert.c index 0f98100b3..f9add47d3 100644 --- a/usr.sbin/rpki-client/cert.c +++ b/usr.sbin/rpki-client/cert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cert.c,v 1.119 2023/10/19 17:05:54 job Exp $ */ +/* $OpenBSD: cert.c,v 1.120 2023/12/10 14:18:23 job Exp $ */ /* * Copyright (c) 2022 Theo Buehler * Copyright (c) 2021 Job Snijders @@ -765,7 +765,7 @@ cert_parse_pre(const char *fn, const unsigned char *der, size_t len) nid = OBJ_obj2nid(cobj); if (nid == NID_ecdsa_with_SHA256) { if (verbose) - warn("%s: P-256 support is experimental", fn); + warnx("%s: P-256 support is experimental", fn); } else if (nid != NID_sha256WithRSAEncryption) { warnx("%s: RFC 7935: wrong signature algorithm %s, want %s", fn, OBJ_nid2ln(nid), diff --git a/usr.sbin/rpki-client/cms.c b/usr.sbin/rpki-client/cms.c index 5fe0607bb..145f250b9 100644 --- a/usr.sbin/rpki-client/cms.c +++ b/usr.sbin/rpki-client/cms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms.c,v 1.40 2023/10/19 17:05:54 job Exp $ */ +/* $OpenBSD: cms.c,v 1.41 2023/12/10 14:18:23 job Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -267,7 +267,7 @@ cms_parse_validate_internal(X509 **xp, const char *fn, const unsigned char *der, /* RFC7935 last paragraph of section 2 specifies the allowed psig */ if (nid == NID_ecdsa_with_SHA256) { if (verbose) - warn("%s: P-256 support is experimental", fn); + warnx("%s: P-256 support is experimental", fn); } else if (nid != NID_rsaEncryption && nid != NID_sha256WithRSAEncryption) { warnx("%s: RFC 6488: wrong signature algorithm %s, want %s", diff --git a/usr.sbin/rpki-client/crl.c b/usr.sbin/rpki-client/crl.c index 9ada6c8ee..c57c038db 100644 --- a/usr.sbin/rpki-client/crl.c +++ b/usr.sbin/rpki-client/crl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crl.c,v 1.29 2023/11/16 11:17:52 tb Exp $ */ +/* $OpenBSD: crl.c,v 1.30 2023/12/10 14:18:23 job Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -65,7 +65,7 @@ crl_parse(const char *fn, const unsigned char *der, size_t len) nid = OBJ_obj2nid(cobj); if (nid == NID_ecdsa_with_SHA256) { if (verbose) - warn("%s: P-256 support is experimental", fn); + warnx("%s: P-256 support is experimental", fn); } else if (nid != NID_sha256WithRSAEncryption) { warnx("%s: RFC 7935: wrong signature algorithm %s, want %s", fn, OBJ_nid2ln(nid),