This commit is contained in:
purplerain 2023-05-18 12:23:26 +00:00
parent 9e7f51724c
commit 4b78db449c
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
42 changed files with 1110 additions and 143 deletions

View file

@ -45,6 +45,7 @@ ENTRY_NB(bcopy)
/* fall into memmove */
NENTRY(memmove)
endbr64
RETGUARD_SETUP(memmove, r10)
movq %rdi,%r11 /* save dest */
movq %rdx,%rcx

View file

@ -1,4 +1,4 @@
/* $OpenBSD: Ovfork.S,v 1.9 2023/01/11 01:55:17 mortimer Exp $ */
/* $OpenBSD: Ovfork.S,v 1.10 2023/05/18 04:26:06 guenther Exp $ */
/* $NetBSD: Ovfork.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
/*-
@ -39,17 +39,24 @@
#include "SYS.h"
/*
* This is written to support a potential vfork(2) that would share
* the parent's vmspace to the child. For that, the parent must
* not rely on anything on the stack at the time of the syscall,
* as the child will overwrite it. So, keep both the return address
* and retguard value in registers (r9 and r8) across the call.
* This used to do an indirect jump on success, but that doesn't
* work if indirect-branch-tracking is enabled as the _caller_ of
* this vfork() stub won't know to place an endbr64 instruction
* after the call. So, just push it back on the stack and return.
*/
SYSENTRY_HIDDEN(vfork)
RETGUARD_SETUP(_thread_sys_vfork, r8);
popq %r9 /* my rta into r9 */
RETGUARD_SETUP(_thread_sys_vfork, r11);
RETGUARD_PUSH(r11);
SYSTRAP(vfork)
RETGUARD_POP(r11)
jc 1f
jmp *%r9
1:
pushq %r9
jnc 1f
SET_ERRNO
RETGUARD_CHECK(_thread_sys_vfork, r11);
1: RETGUARD_CHECK(_thread_sys_vfork, r8);
ret
SYSCALL_END_HIDDEN(vfork)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: getwd.c,v 1.13 2021/12/16 19:12:43 millert Exp $ */
/* $OpenBSD: getwd.c,v 1.14 2023/05/18 16:11:09 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@ -34,9 +34,6 @@
#include <string.h>
#include <unistd.h>
int __getcwd(char *buf, size_t len);
PROTO_NORMAL(__getcwd);
char *
getwd(char *buf)
{

View file

@ -1,4 +1,4 @@
/* $OpenBSD: getcwd.c,v 1.21 2016/05/07 19:48:00 guenther Exp $ */
/* $OpenBSD: getcwd.c,v 1.22 2023/05/18 16:11:09 guenther Exp $ */
/*
* Copyright (c) 2005 Marius Eriksen <marius@openbsd.org>
@ -21,9 +21,6 @@
#include <stdlib.h>
#include <unistd.h>
int __getcwd(char *buf, size_t len);
PROTO_NORMAL(__getcwd);
char *
getcwd(char *buf, size_t size)
{

View file

@ -1,4 +1,4 @@
/* $OpenBSD: stdlib.h,v 1.16 2019/05/10 15:03:24 otto Exp $ */
/* $OpenBSD: stdlib.h,v 1.17 2023/05/18 16:11:09 guenther Exp $ */
/* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */
/*-
@ -45,11 +45,14 @@ __END_HIDDEN_DECLS
extern char **environ;
extern char *__progname;
int __realpath(const char *pathname, char *resolved);
#if 0
/*extern PROTO_NORMAL(suboptarg);*/
#endif
PROTO_NORMAL(__mb_cur_max);
PROTO_NORMAL(__realpath);
PROTO_STD_DEPRECATED(_Exit);
PROTO_DEPRECATED(a64l);
PROTO_NORMAL(abort);

View file

@ -0,0 +1,26 @@
/* $OpenBSD: event.h,v 1.1 2023/05/18 16:11:09 guenther Exp $ */
/*
* Copyright (c) 2023 Philip Guenther <guenther@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _LIBC_SYS_EVENT_H_
#define _LIBC_SYS_EVENT_H_
#include_next <sys/event.h>
PROTO_NORMAL(kevent);
PROTO_NORMAL(kqueue);
#endif /* !_LIBC_SYS_EVENT_H_ */

View file

@ -0,0 +1,26 @@
/* $OpenBSD: ktrace.h,v 1.1 2023/05/18 16:07:12 guenther Exp $ */
/*
* Copyright (c) 2023 Philip Guenther <guenther@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _LIBC_SYS_KTRACE_H_
#define _LIBC_SYS_KTRACE_H_
#include_next <sys/ktrace.h>
PROTO_NORMAL(ktrace);
PROTO_NORMAL(utrace);
#endif /* !_LIBC_SYS_KTRACE_H_ */

28
lib/libc/hidden/sys/shm.h Normal file
View file

@ -0,0 +1,28 @@
/* $OpenBSD: shm.h,v 1.1 2023/05/18 16:11:09 guenther Exp $ */
/*
* Copyright (c) 2023 Philip Guenther <guenther@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _LIBC_SYS_SHM_H_
#define _LIBC_SYS_SHM_H_
#include_next <sys/shm.h>
PROTO_NORMAL(shmat);
PROTO_NORMAL(shmctl);
PROTO_NORMAL(shmdt);
PROTO_NORMAL(shmget);
#endif /* !_LIBC_SYS_SHM_H_ */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: stat.h,v 1.2 2015/09/14 10:11:54 guenther Exp $ */
/* $OpenBSD: stat.h,v 1.3 2023/05/18 16:11:09 guenther Exp $ */
/*
* Copyright (c) 2015 Philip Guenther <guenther@openbsd.org>
*
@ -21,6 +21,7 @@
#include_next <sys/stat.h>
PROTO_NORMAL(chflags);
PROTO_NORMAL(chflagsat);
PROTO_NORMAL(chmod);
PROTO_NORMAL(fchflags);
PROTO_NORMAL(fchmod);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: unistd.h,v 1.11 2018/07/13 09:25:22 beck Exp $ */
/* $OpenBSD: unistd.h,v 1.12 2023/05/18 16:11:09 guenther Exp $ */
/*
* Copyright (c) 2015 Philip Guenther <guenther@openbsd.org>
*
@ -25,6 +25,10 @@ __BEGIN_HIDDEN_DECLS
extern int _pagesize;
__END_HIDDEN_DECLS
/* the real syscall behind getcwd(3) and getwd(3) */
int __getcwd(char *buf, size_t len);
PROTO_NORMAL(__getcwd);
PROTO_NORMAL(__tfork_thread);
PROTO_NORMAL(_exit);
PROTO_NORMAL(access);
@ -87,6 +91,7 @@ PROTO_NORMAL(getresgid);
PROTO_NORMAL(getresuid);
PROTO_NORMAL(getsid);
PROTO_NORMAL(getthrid);
PROTO_NORMAL(getthrname);
PROTO_NORMAL(getuid);
PROTO_DEPRECATED(getusershell);
PROTO_DEPRECATED(getwd);
@ -142,6 +147,7 @@ PROTO_NORMAL(setresgid);
PROTO_NORMAL(setresuid);
PROTO_NORMAL(setreuid);
PROTO_NORMAL(setsid);
PROTO_NORMAL(setthrname);
PROTO_NORMAL(setuid);
PROTO_DEPRECATED(setusershell);
/*PROTO_CANCEL(sleep);*/

View file

@ -1,4 +1,4 @@
/* $OpenBSD: realpath.c,v 1.27 2019/07/05 05:04:26 deraadt Exp $ */
/* $OpenBSD: realpath.c,v 1.28 2023/05/18 16:11:10 guenther Exp $ */
/*
* Copyright (c) 2019 Bob Beck <beck@openbsd.org>
* Copyright (c) 2019 Theo de Raadt <deraadt@openbsd.org>
@ -24,9 +24,6 @@
#include <syslog.h>
#include <stdarg.h>
int __realpath(const char *pathname, char *resolved);
PROTO_NORMAL(__realpath);
/*
* wrapper for kernel __realpath
*/