From 170ca6cd9aafa3cdc31a31ea372066cfe462e34a Mon Sep 17 00:00:00 2001 From: guenther Date: Thu, 18 May 2023 16:11:09 +0000 Subject: [PATCH] Add PROTO_NORMAL() declarations for the remaining syscalls, to avoid future, inadvertant PLT entries. Move the __getcwd and __realpath declarations to hidden/{stdlib,unistd}.h to consolidate and remove duplication. ok tb@ otto@ deraadt@ --- lib/libc/compat-43/getwd.c | 5 +---- lib/libc/gen/getcwd.c | 5 +---- lib/libc/hidden/stdlib.h | 5 ++++- lib/libc/hidden/sys/event.h | 26 ++++++++++++++++++++++++++ lib/libc/hidden/sys/shm.h | 28 ++++++++++++++++++++++++++++ lib/libc/hidden/sys/stat.h | 3 ++- lib/libc/hidden/unistd.h | 8 +++++++- lib/libc/stdlib/realpath.c | 5 +---- 8 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 lib/libc/hidden/sys/event.h create mode 100644 lib/libc/hidden/sys/shm.h diff --git a/lib/libc/compat-43/getwd.c b/lib/libc/compat-43/getwd.c index 2ae13683744..824d827f70c 100644 --- a/lib/libc/compat-43/getwd.c +++ b/lib/libc/compat-43/getwd.c @@ -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 #include -int __getcwd(char *buf, size_t len); -PROTO_NORMAL(__getcwd); - char * getwd(char *buf) { diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c index 7197276d8d7..1bc9065563d 100644 --- a/lib/libc/gen/getcwd.c +++ b/lib/libc/gen/getcwd.c @@ -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 @@ -21,9 +21,6 @@ #include #include -int __getcwd(char *buf, size_t len); -PROTO_NORMAL(__getcwd); - char * getcwd(char *buf, size_t size) { diff --git a/lib/libc/hidden/stdlib.h b/lib/libc/hidden/stdlib.h index 5753c32945f..46c3536715d 100644 --- a/lib/libc/hidden/stdlib.h +++ b/lib/libc/hidden/stdlib.h @@ -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); diff --git a/lib/libc/hidden/sys/event.h b/lib/libc/hidden/sys/event.h new file mode 100644 index 00000000000..7e129b8aab4 --- /dev/null +++ b/lib/libc/hidden/sys/event.h @@ -0,0 +1,26 @@ +/* $OpenBSD: event.h,v 1.1 2023/05/18 16:11:09 guenther Exp $ */ +/* + * Copyright (c) 2023 Philip Guenther + * + * 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 + +PROTO_NORMAL(kevent); +PROTO_NORMAL(kqueue); + +#endif /* !_LIBC_SYS_EVENT_H_ */ diff --git a/lib/libc/hidden/sys/shm.h b/lib/libc/hidden/sys/shm.h new file mode 100644 index 00000000000..93b2a2f2c60 --- /dev/null +++ b/lib/libc/hidden/sys/shm.h @@ -0,0 +1,28 @@ +/* $OpenBSD: shm.h,v 1.1 2023/05/18 16:11:09 guenther Exp $ */ +/* + * Copyright (c) 2023 Philip Guenther + * + * 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 + +PROTO_NORMAL(shmat); +PROTO_NORMAL(shmctl); +PROTO_NORMAL(shmdt); +PROTO_NORMAL(shmget); + +#endif /* !_LIBC_SYS_SHM_H_ */ diff --git a/lib/libc/hidden/sys/stat.h b/lib/libc/hidden/sys/stat.h index 4c95416041d..19235e020f7 100644 --- a/lib/libc/hidden/sys/stat.h +++ b/lib/libc/hidden/sys/stat.h @@ -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 * @@ -21,6 +21,7 @@ #include_next PROTO_NORMAL(chflags); +PROTO_NORMAL(chflagsat); PROTO_NORMAL(chmod); PROTO_NORMAL(fchflags); PROTO_NORMAL(fchmod); diff --git a/lib/libc/hidden/unistd.h b/lib/libc/hidden/unistd.h index 692951637c8..c5950955339 100644 --- a/lib/libc/hidden/unistd.h +++ b/lib/libc/hidden/unistd.h @@ -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 * @@ -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);*/ diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c index f7ac9fe6060..6562e1311b1 100644 --- a/lib/libc/stdlib/realpath.c +++ b/lib/libc/stdlib/realpath.c @@ -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 * Copyright (c) 2019 Theo de Raadt @@ -24,9 +24,6 @@ #include #include -int __realpath(const char *pathname, char *resolved); -PROTO_NORMAL(__realpath); - /* * wrapper for kernel __realpath */ -- 2.20.1