Module Name:    src
Committed By:   thorpej
Date:           Mon Nov  1 05:53:46 UTC 2021

Modified Files:
        src/distrib/sets/lists/base: shl.mi
        src/distrib/sets/lists/debug: shl.mi
        src/include: signal.h
        src/lib/libc: shlib_version
        src/lib/libc/compat/sys: Makefile.inc
        src/lib/libc/sys: Makefile.inc
Added Files:
        src/lib/libc/compat/sys: compat___sigaction14_sigtramp.c
        src/lib/libc/sys: Lint___sigaction_siginfo.c __sigaction_siginfo.c
Removed Files:
        src/lib/libc/sys: Lint___sigaction14.c __sigaction14_sigtramp.c

Log Message:
Version the sigaction(2) libc wrapper.  The new version uses the "siginfo"
trampoline exclusively, thus relegating "sigcontext"-style handlers (which
have not been documented for many years now) to the dustbin of the compat
library.


To generate a diff of this commit:
cvs rdiff -u -r1.929 -r1.930 src/distrib/sets/lists/base/shl.mi
cvs rdiff -u -r1.286 -r1.287 src/distrib/sets/lists/debug/shl.mi
cvs rdiff -u -r1.57 -r1.58 src/include/signal.h
cvs rdiff -u -r1.292 -r1.293 src/lib/libc/shlib_version
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/compat/sys/Makefile.inc
cvs rdiff -u -r0 -r1.1 \
    src/lib/libc/compat/sys/compat___sigaction14_sigtramp.c
cvs rdiff -u -r1.1 -r0 src/lib/libc/sys/Lint___sigaction14.c
cvs rdiff -u -r0 -r1.1 src/lib/libc/sys/Lint___sigaction_siginfo.c \
    src/lib/libc/sys/__sigaction_siginfo.c
cvs rdiff -u -r1.249 -r1.250 src/lib/libc/sys/Makefile.inc
cvs rdiff -u -r1.2 -r0 src/lib/libc/sys/__sigaction14_sigtramp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/base/shl.mi
diff -u src/distrib/sets/lists/base/shl.mi:1.929 src/distrib/sets/lists/base/shl.mi:1.930
--- src/distrib/sets/lists/base/shl.mi:1.929	Sat Oct 16 07:01:02 2021
+++ src/distrib/sets/lists/base/shl.mi	Mon Nov  1 05:53:45 2021
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.929 2021/10/16 07:01:02 skrll Exp $
+# $NetBSD: shl.mi,v 1.930 2021/11/01 05:53:45 thorpej Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -24,7 +24,7 @@
 ./lib/libblocklist.so.0.0			base-sys-shlib		dynamicroot
 ./lib/libc.so					base-sys-shlib		dynamicroot
 ./lib/libc.so.12				base-sys-shlib		dynamicroot
-./lib/libc.so.12.219				base-sys-shlib		dynamicroot
+./lib/libc.so.12.220				base-sys-shlib		dynamicroot
 ./lib/libcrypt.so				base-sys-shlib		dynamicroot
 ./lib/libcrypt.so.1				base-sys-shlib		dynamicroot
 ./lib/libcrypt.so.1.0				base-sys-shlib		dynamicroot
@@ -251,7 +251,7 @@
 ./usr/lib/libc++.so.1.0				base-sys-shlib		compatfile,libcxx
 ./usr/lib/libc.so				base-sys-shlib		compatfile
 ./usr/lib/libc.so.12				base-sys-shlib		compatfile
-./usr/lib/libc.so.12.219			base-sys-shlib		compatfile
+./usr/lib/libc.so.12.220			base-sys-shlib		compatfile
 ./usr/lib/libcbor.so				base-sys-shlib		compatfile
 ./usr/lib/libcbor.so.0				base-sys-shlib		compatfile
 ./usr/lib/libcbor.so.0.5			base-sys-shlib		compatfile

Index: src/distrib/sets/lists/debug/shl.mi
diff -u src/distrib/sets/lists/debug/shl.mi:1.286 src/distrib/sets/lists/debug/shl.mi:1.287
--- src/distrib/sets/lists/debug/shl.mi:1.286	Sat Oct 16 07:01:03 2021
+++ src/distrib/sets/lists/debug/shl.mi	Mon Nov  1 05:53:45 2021
@@ -1,10 +1,10 @@
-# $NetBSD: shl.mi,v 1.286 2021/10/16 07:01:03 skrll Exp $
+# $NetBSD: shl.mi,v 1.287 2021/11/01 05:53:45 thorpej Exp $
 ./usr/lib/libbfd_g.a						comp-c-debuglib	debuglib,compatfile,binutils
 ./usr/libdata/debug/lib						base-sys-usr	debug,dynamicroot,compatdir
 ./usr/libdata/debug/lib/libavl.so.0.0.debug			comp-zfs-debug	debug,dynamicroot,zfs
 ./usr/libdata/debug/lib/libblacklist.so.0.0.debug		comp-obsolete	obsolete,compatfile
 ./usr/libdata/debug/lib/libblocklist.so.0.0.debug		comp-sys-debug	debug,dynamicroot
-./usr/libdata/debug/lib/libc.so.12.219.debug			comp-sys-debug	debug,dynamicroot
+./usr/libdata/debug/lib/libc.so.12.220.debug			comp-sys-debug	debug,dynamicroot
 ./usr/libdata/debug/lib/libcrypt.so.1.0.debug			comp-sys-debug	debug,dynamicroot
 ./usr/libdata/debug/lib/libcrypto.so.12.0.debug			comp-sys-debug	debug,dynamicroot,openssl=10
 ./usr/libdata/debug/lib/libcrypto.so.14.0.debug			comp-sys-debug	debug,dynamicroot,openssl=11
@@ -84,7 +84,7 @@
 ./usr/libdata/debug/usr/lib/libbsdmalloc.so.0.0.debug		comp-sys-debug	debug,compatfile
 ./usr/libdata/debug/usr/lib/libbz2.so.1.1.debug			comp-sys-debug	debug,compatfile
 ./usr/libdata/debug/usr/lib/libc++.so.1.0.debug			comp-sys-debug	debug,compatfile,libcxx
-./usr/libdata/debug/usr/lib/libc.so.12.219.debug		comp-sys-debug	debug,compatfile
+./usr/libdata/debug/usr/lib/libc.so.12.220.debug		comp-sys-debug	debug,compatfile
 ./usr/libdata/debug/usr/lib/libcbor.so.0.5.debug		comp-sys-debug	debug,compatfile
 ./usr/libdata/debug/usr/lib/libcom_err.so.8.0.debug		comp-krb5-debug	debug,compatfile,kerberos
 ./usr/libdata/debug/usr/lib/libcrypt.so.1.0.debug		comp-sys-debug	debug,compatfile

Index: src/include/signal.h
diff -u src/include/signal.h:1.57 src/include/signal.h:1.58
--- src/include/signal.h:1.57	Tue Jan  8 17:35:42 2019
+++ src/include/signal.h	Mon Nov  1 05:53:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: signal.h,v 1.57 2019/01/08 17:35:42 joerg Exp $	*/
+/*	$NetBSD: signal.h,v 1.58 2021/11/01 05:53:45 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -66,7 +66,7 @@ int signalnumber(const char *);
 #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
     defined(_NETBSD_SOURCE)
 int	kill(pid_t, int);
-int	__libc_sigaction14(int, const struct sigaction * __restrict,
+int	__sigaction_siginfo(int, const struct sigaction * __restrict,
 	    struct sigaction * __restrict);
 
 #if (_POSIX_C_SOURCE - 0L) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
@@ -83,7 +83,7 @@ int	__libc_thr_sigsetmask(int, const sig
 
 #ifndef __LIBC12_SOURCE__
 int	sigaction(int, const struct sigaction * __restrict,
-    struct sigaction * __restrict) __RENAME(__sigaction14);
+	    struct sigaction * __restrict) __RENAME(__sigaction_siginfo);
 int	sigaddset(sigset_t *, int) __RENAME(__sigaddset14);
 int	sigdelset(sigset_t *, int) __RENAME(__sigdelset14);
 int	sigemptyset(sigset_t *) __RENAME(__sigemptyset14);
@@ -91,7 +91,7 @@ int	sigfillset(sigset_t *) __RENAME(__si
 int	sigismember(const sigset_t *, int) __RENAME(__sigismember14);
 int	sigpending(sigset_t *) __RENAME(__sigpending14);
 int	sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict)
-    __RENAME(__sigprocmask14);
+	    __RENAME(__sigprocmask14);
 int	sigsuspend(const sigset_t *) __RENAME(__sigsuspend14);
 
 #if defined(__c99inline) || defined(__SIGSETOPS_BODY)
@@ -211,6 +211,8 @@ int	sigblock(int);
 int	sigsetmask(int);
 #endif /* _NETBSD_SOURCE */
 
+int	__sigtramp_check_np(void *);
+
 #endif	/* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */
 __END_DECLS
 

Index: src/lib/libc/shlib_version
diff -u src/lib/libc/shlib_version:1.292 src/lib/libc/shlib_version:1.293
--- src/lib/libc/shlib_version:1.292	Sun Sep 19 15:51:28 2021
+++ src/lib/libc/shlib_version	Mon Nov  1 05:53:45 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: shlib_version,v 1.292 2021/09/19 15:51:28 thorpej Exp $
+#	$NetBSD: shlib_version,v 1.293 2021/11/01 05:53:45 thorpej Exp $
 #	Remember to update distrib/sets/lists/base/shl.* when changing
 #
 # things we wish to do on next major version bump:
@@ -54,4 +54,4 @@
 # - the syscall stubs for the (obsolete) lfs syscalls should be removed
 # - remove tzsetwall(3), upstream has removed it
 major=12
-minor=219
+minor=220

Index: src/lib/libc/compat/sys/Makefile.inc
diff -u src/lib/libc/compat/sys/Makefile.inc:1.10 src/lib/libc/compat/sys/Makefile.inc:1.11
--- src/lib/libc/compat/sys/Makefile.inc:1.10	Sun Sep 22 22:59:38 2019
+++ src/lib/libc/compat/sys/Makefile.inc	Mon Nov  1 05:53:45 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.10 2019/09/22 22:59:38 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.11 2021/11/01 05:53:45 thorpej Exp $
 
 .PATH: ${COMPATDIR}/sys
 SRCS+= compat_getdents.c compat_getdirentries.c compat_msync.c \
@@ -13,7 +13,8 @@ SRCS+= compat_getdents.c compat_getdiren
     compat_mqueue.c compat__lwp_park.c compat_lfs_segwait.c compat_kevent.c \
     compat___ntp_gettime30.c compat___semctl13.c compat___shmctl13.c \
     compat___msgctl13.c compat___lwp_park50.c \
-    compat___fhstatvfs140.c compat___fhstatvfs40.c
+    compat___fhstatvfs140.c compat___fhstatvfs40.c \
+    compat___sigaction14_sigtramp.c
 
 MAN+=	getdirentries.3
 

Index: src/lib/libc/sys/Makefile.inc
diff -u src/lib/libc/sys/Makefile.inc:1.249 src/lib/libc/sys/Makefile.inc:1.250
--- src/lib/libc/sys/Makefile.inc:1.249	Sun Oct 31 22:24:36 2021
+++ src/lib/libc/sys/Makefile.inc	Mon Nov  1 05:53:45 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.249 2021/10/31 22:24:36 thorpej Exp $
+#	$NetBSD: Makefile.inc,v 1.250 2021/11/01 05:53:45 thorpej Exp $
 #	@(#)Makefile.inc	8.3 (Berkeley) 10/24/94
 
 # sys sources
@@ -21,7 +21,7 @@ SRCS+=	__clone.S __vfork14.S brk.S fork.
 
 _LSRC+=	Lint___clone.c Lint___vfork14.c Lint_brk.c Lint_clone.c \
 	Lint_getcontext.c Lint_pipe.c Lint_ptrace.c \
-	Lint_sbrk.c Lint___sigaction14.c Lint_syscall.c Lint___syscall.c \
+	Lint_sbrk.c Lint___sigaction_siginfo.c Lint_syscall.c Lint___syscall.c \
 	LintSysNormal.c LintSysNoerr.c LintSysPseudoNoerr.c
 
 .if ${MKLINT} != "no"
@@ -90,7 +90,7 @@ ASM_GLUE+= tmp___${glue:.c=}50.S
 .endfor
 
 # modules with default implementations on all architectures:
-SRCS+=	__sigaction14_sigtramp.c
+SRCS+=	__sigaction_siginfo.c
 
 ASM=\
     __acl_get_link.S __acl_set_link.S __acl_delete_link.S \

Added files:

Index: src/lib/libc/compat/sys/compat___sigaction14_sigtramp.c
diff -u /dev/null src/lib/libc/compat/sys/compat___sigaction14_sigtramp.c:1.1
--- /dev/null	Mon Nov  1 05:53:46 2021
+++ src/lib/libc/compat/sys/compat___sigaction14_sigtramp.c	Mon Nov  1 05:53:45 2021
@@ -0,0 +1,94 @@
+/*	$NetBSD: compat___sigaction14_sigtramp.c,v 1.1 2021/11/01 05:53:45 thorpej Exp $	*/
+
+/*-
+ * Copyright (c) 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: compat___sigaction14_sigtramp.c,v 1.1 2021/11/01 05:53:45 thorpej Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <stddef.h>
+#include <signal.h>
+#include <errno.h>
+
+#include "extern.h"
+
+#define C(a,b) __CONCAT(a,b)
+#define __SIGTRAMP_SIGCONTEXT  \
+    C(__sigtramp_sigcontext_,__SIGTRAMP_SIGCONTEXT_VERSION)
+#define __SIGTRAMP_SIGINFO  \
+    C(__sigtramp_siginfo_,__SIGTRAMP_SIGINFO_VERSION)
+
+__weak_alias(__sigaction14, __libc_sigaction14)
+
+#define __LIBC12_SOURCE__
+
+/*
+ * The symbol must remain, but we don't want this exposed in a header
+ * anywhere, so the prototype goes here.
+ */
+int	__libc_sigaction14(int, const struct sigaction *, struct sigaction *);
+
+int
+__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
+{
+	extern const char __SIGTRAMP_SIGINFO[];
+
+	/*
+	 * If no sigaction, use the "default" trampoline since it won't
+	 * be used.
+	 */
+	if (act == NULL)
+		return  __sigaction_sigtramp(sig, act, oact, NULL, 0);
+
+#if defined(__HAVE_STRUCT_SIGCONTEXT) &&  defined(__LIBC12_SOURCE__)
+	/*
+	 * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not
+	 * set in the sigaction.
+	 */
+	if ((act->sa_flags & SA_SIGINFO) == 0) {
+		extern const char __SIGTRAMP_SIGCONTEXT[];
+		int sav = errno;
+		int rv =  __sigaction_sigtramp(sig, act, oact,
+		    __SIGTRAMP_SIGCONTEXT, __SIGTRAMP_SIGCONTEXT_VERSION);
+		if (rv >= 0 || errno != EINVAL)
+			return rv;
+		errno = sav;
+	}
+#endif
+
+	/*
+	 * If SA_SIGINFO was specified or the compatibility trampolines
+	 * can't be used, use the siginfo trampoline.
+	 */
+	return __sigaction_sigtramp(sig, act, oact,
+	    __SIGTRAMP_SIGINFO, __SIGTRAMP_SIGINFO_VERSION);
+}

Index: src/lib/libc/sys/Lint___sigaction_siginfo.c
diff -u /dev/null src/lib/libc/sys/Lint___sigaction_siginfo.c:1.1
--- /dev/null	Mon Nov  1 05:53:46 2021
+++ src/lib/libc/sys/Lint___sigaction_siginfo.c	Mon Nov  1 05:53:45 2021
@@ -0,0 +1,11 @@
+/* $NetBSD: Lint___sigaction_siginfo.c,v 1.1 2021/11/01 05:53:45 thorpej Exp $ */
+
+#include <signal.h>
+
+/*ARGSUSED*/
+int
+__sigaction_siginfo(int sig, const struct sigaction *nact,
+    struct sigaction *oact)
+{
+	return 0;
+}
Index: src/lib/libc/sys/__sigaction_siginfo.c
diff -u /dev/null src/lib/libc/sys/__sigaction_siginfo.c:1.1
--- /dev/null	Mon Nov  1 05:53:46 2021
+++ src/lib/libc/sys/__sigaction_siginfo.c	Mon Nov  1 05:53:45 2021
@@ -0,0 +1,62 @@
+/*	$NetBSD: __sigaction_siginfo.c,v 1.1 2021/11/01 05:53:45 thorpej Exp $	*/
+
+/*-
+ * Copyright (c) 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: __sigaction_siginfo.c,v 1.1 2021/11/01 05:53:45 thorpej Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <stddef.h>
+#include <signal.h>
+#include <errno.h>
+
+#include "extern.h"
+
+#define C(a,b) __CONCAT(a,b)
+#define __SIGTRAMP_SIGINFO  \
+    C(__sigtramp_siginfo_,__SIGTRAMP_SIGINFO_VERSION)
+
+/*
+ * This serves no purpose except as a marker that this function should
+ * simply be renamed "sigaction" when libc's major version is bumped.
+ */
+#define __LIBC12_SOURCE__
+
+int
+__sigaction_siginfo(int sig, const struct sigaction *act,
+    struct sigaction *oact)
+{
+	extern const char __SIGTRAMP_SIGINFO[];
+
+	return __sigaction_sigtramp(sig, act, oact,
+	    __SIGTRAMP_SIGINFO, __SIGTRAMP_SIGINFO_VERSION);
+}

Reply via email to