Pull up following revision(s) (requested by mrg in ticket #1479): sys/compat/svr4/svr4_lwp.c: 1.20 sys/compat/svr4/svr4_signal.c: 1.67 sys/compat/svr4/svr4_stream.c: 1.89-1.91 via patch sys/compat/svr4_32/svr4_32_signal.c: 1.29 Fix some of the multitudinous holes in svr4 streams. We should never have enabled this by default; it is a minefield. From Ilja Van Sprundel. -- Zero stack data before copyout. From Ilja Van Sprundel. -- Fix indexing of svr4 signals. From Ilja Van Sprundel. -- Feebly attempt to get this reference counting less bad. This svr4 streams code is bad and it should feel bad. From Ilja Van Sprundel. -- Check bounds in svr4_sys_putmsg. Check more svr4_strmcmd bounds. svr4 streams code is still a disaster. From Ilja Van Sprundel.diff -r1.19 -r1.19.32.1 src/sys/compat/svr4/svr4_lwp.c
(snj)
--- src/sys/compat/svr4/Attic/svr4_lwp.c 2009/11/23 00:46:07 1.19
+++ src/sys/compat/svr4/Attic/svr4_lwp.c 2017/08/19 03:40:48 1.19.32.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: svr4_lwp.c,v 1.19 2009/11/23 00:46:07 rmind Exp $ */ | 1 | /* $NetBSD: svr4_lwp.c,v 1.19.32.1 2017/08/19 03:40:48 snj Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Christos Zoulas. | 8 | * by Christos Zoulas. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: svr4_lwp.c,v 1.19 2009/11/23 00:46:07 rmind Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: svr4_lwp.c,v 1.19.32.1 2017/08/19 03:40:48 snj Exp $"); | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/kernel.h> | 36 | #include <sys/kernel.h> | |
37 | #include <sys/systm.h> | 37 | #include <sys/systm.h> | |
38 | #include <sys/queue.h> | 38 | #include <sys/queue.h> | |
39 | #include <sys/mbuf.h> | 39 | #include <sys/mbuf.h> | |
40 | #include <sys/file.h> | 40 | #include <sys/file.h> | |
41 | #include <sys/mount.h> | 41 | #include <sys/mount.h> | |
42 | #include <sys/time.h> | 42 | #include <sys/time.h> | |
43 | #include <sys/resourcevar.h> | 43 | #include <sys/resourcevar.h> | |
44 | #include <sys/proc.h> | 44 | #include <sys/proc.h> | |
45 | #include <sys/socket.h> | 45 | #include <sys/socket.h> | |
46 | #include <sys/socketvar.h> | 46 | #include <sys/socketvar.h> | |
@@ -98,26 +98,28 @@ svr4_sys__lwp_kill(struct lwp *l, const | @@ -98,26 +98,28 @@ svr4_sys__lwp_kill(struct lwp *l, const | |||
98 | struct sys__lwp_kill_args ap; | 98 | struct sys__lwp_kill_args ap; | |
99 | SCARG(&ap, target) = SCARG(uap, lwpid); | 99 | SCARG(&ap, target) = SCARG(uap, lwpid); | |
100 | SCARG(&ap, signo) = SCARG(uap, signum); | 100 | SCARG(&ap, signo) = SCARG(uap, signum); | |
101 | 101 | |||
102 | return sys__lwp_kill(l, &ap, retval); | 102 | return sys__lwp_kill(l, &ap, retval); | |
103 | } | 103 | } | |
104 | 104 | |||
105 | int | 105 | int | |
106 | svr4_sys__lwp_info(struct lwp *l, const struct svr4_sys__lwp_info_args *uap, register_t *retval) | 106 | svr4_sys__lwp_info(struct lwp *l, const struct svr4_sys__lwp_info_args *uap, register_t *retval) | |
107 | { | 107 | { | |
108 | struct svr4_lwpinfo lwpinfo; | 108 | struct svr4_lwpinfo lwpinfo; | |
109 | int error; | 109 | int error; | |
110 | 110 | |||
111 | memset(&lwpinfo, 0, sizeof(lwpinfo)); | |||
112 | ||||
111 | /* XXX NJWLWP */ | 113 | /* XXX NJWLWP */ | |
112 | TIMEVAL_TO_TIMESPEC(&l->l_proc->p_stats->p_ru.ru_stime, &lwpinfo.lwp_stime); | 114 | TIMEVAL_TO_TIMESPEC(&l->l_proc->p_stats->p_ru.ru_stime, &lwpinfo.lwp_stime); | |
113 | TIMEVAL_TO_TIMESPEC(&l->l_proc->p_stats->p_ru.ru_utime, &lwpinfo.lwp_utime); | 115 | TIMEVAL_TO_TIMESPEC(&l->l_proc->p_stats->p_ru.ru_utime, &lwpinfo.lwp_utime); | |
114 | 116 | |||
115 | if ((error = copyout(&lwpinfo, SCARG(uap, lwpinfo), sizeof(lwpinfo))) == | 117 | if ((error = copyout(&lwpinfo, SCARG(uap, lwpinfo), sizeof(lwpinfo))) == | |
116 | -1) | 118 | -1) | |
117 | return error; | 119 | return error; | |
118 | return 0; | 120 | return 0; | |
119 | } | 121 | } | |
120 | 122 | |||
121 | int | 123 | int | |
122 | svr4_sys__lwp_exit(struct lwp *l, const void *v, register_t *retval) | 124 | svr4_sys__lwp_exit(struct lwp *l, const void *v, register_t *retval) | |
123 | { | 125 | { |
--- src/sys/compat/svr4/Attic/svr4_signal.c 2011/02/03 21:45:31 1.65
+++ src/sys/compat/svr4/Attic/svr4_signal.c 2017/08/19 03:40:48 1.65.24.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: svr4_signal.c,v 1.65 2011/02/03 21:45:31 joerg Exp $ */ | 1 | /* $NetBSD: svr4_signal.c,v 1.65.24.1 2017/08/19 03:40:48 snj Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1994, 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1994, 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Christos Zoulas and by Charles M. Hannum. | 8 | * by Christos Zoulas and by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: svr4_signal.c,v 1.65 2011/02/03 21:45:31 joerg Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: svr4_signal.c,v 1.65.24.1 2017/08/19 03:40:48 snj Exp $"); | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/systm.h> | 36 | #include <sys/systm.h> | |
37 | #include <sys/namei.h> | 37 | #include <sys/namei.h> | |
38 | #include <sys/proc.h> | 38 | #include <sys/proc.h> | |
39 | #include <sys/filedesc.h> | 39 | #include <sys/filedesc.h> | |
40 | #include <sys/ioctl.h> | 40 | #include <sys/ioctl.h> | |
41 | #include <sys/mount.h> | 41 | #include <sys/mount.h> | |
42 | #include <sys/kernel.h> | 42 | #include <sys/kernel.h> | |
43 | #include <sys/signal.h> | 43 | #include <sys/signal.h> | |
44 | #include <sys/signalvar.h> | 44 | #include <sys/signalvar.h> | |
45 | #include <sys/malloc.h> | 45 | #include <sys/malloc.h> | |
46 | #include <sys/wait.h> | 46 | #include <sys/wait.h> | |
@@ -63,26 +63,41 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_signal. | @@ -63,26 +63,41 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_signal. | |||
63 | #define svr4_sigemptyset(s) memset((s), 0, sizeof(*(s))) | 63 | #define svr4_sigemptyset(s) memset((s), 0, sizeof(*(s))) | |
64 | #define svr4_sigismember(s, n) ((s)->bits[svr4_sigword(n)] & svr4_sigmask(n)) | 64 | #define svr4_sigismember(s, n) ((s)->bits[svr4_sigword(n)] & svr4_sigmask(n)) | |
65 | #define svr4_sigaddset(s, n) ((s)->bits[svr4_sigword(n)] |= svr4_sigmask(n)) | 65 | #define svr4_sigaddset(s, n) ((s)->bits[svr4_sigword(n)] |= svr4_sigmask(n)) | |
66 | 66 | |||
67 | static inline void svr4_sigfillset(svr4_sigset_t *); | 67 | static inline void svr4_sigfillset(svr4_sigset_t *); | |
68 | void svr4_to_native_sigaction(const struct svr4_sigaction *, | 68 | void svr4_to_native_sigaction(const struct svr4_sigaction *, | |
69 | struct sigaction *); | 69 | struct sigaction *); | |
70 | void native_to_svr4_sigaction(const struct sigaction *, | 70 | void native_to_svr4_sigaction(const struct sigaction *, | |
71 | struct svr4_sigaction *); | 71 | struct svr4_sigaction *); | |
72 | 72 | |||
73 | extern const int native_to_svr4_signo[]; | 73 | extern const int native_to_svr4_signo[]; | |
74 | extern const int svr4_to_native_signo[]; | 74 | extern const int svr4_to_native_signo[]; | |
75 | 75 | |||
76 | static int | |||
77 | svr4_decode_signum(int signum, int *native_signo, int *sigcall) | |||
78 | { | |||
79 | ||||
80 | if (SVR4_SIGNO(signum) >= SVR4_NSIG) | |||
81 | return EINVAL; | |||
82 | ||||
83 | if (native_signo) | |||
84 | *native_signo = svr4_to_native_signo[SVR4_SIGNO(signum)]; | |||
85 | if (sigcall) | |||
86 | *sigcall = SVR4_SIGCALL(signum); | |||
87 | ||||
88 | return 0; | |||
89 | } | |||
90 | ||||
76 | static inline void | 91 | static inline void | |
77 | svr4_sigfillset(svr4_sigset_t *s) | 92 | svr4_sigfillset(svr4_sigset_t *s) | |
78 | { | 93 | { | |
79 | int i; | 94 | int i; | |
80 | 95 | |||
81 | svr4_sigemptyset(s); | 96 | svr4_sigemptyset(s); | |
82 | for (i = 1; i < SVR4_NSIG; i++) | 97 | for (i = 1; i < SVR4_NSIG; i++) | |
83 | if (svr4_to_native_signo[i] != 0) | 98 | if (svr4_to_native_signo[i] != 0) | |
84 | svr4_sigaddset(s, i); | 99 | svr4_sigaddset(s, i); | |
85 | } | 100 | } | |
86 | 101 | |||
87 | void | 102 | void | |
88 | svr4_to_native_sigset(const svr4_sigset_t *sss, sigset_t *bss) | 103 | svr4_to_native_sigset(const svr4_sigset_t *sss, sigset_t *bss) | |
@@ -164,35 +179,41 @@ native_to_svr4_sigaction(const struct si | @@ -164,35 +179,41 @@ native_to_svr4_sigaction(const struct si | |||
164 | ssa->svr4_sa_flags |= SVR4_SA_NOCLDSTOP; | 179 | ssa->svr4_sa_flags |= SVR4_SA_NOCLDSTOP; | |
165 | } | 180 | } | |
166 | 181 | |||
167 | int | 182 | int | |
168 | svr4_sys_sigaction(struct lwp *l, const struct svr4_sys_sigaction_args *uap, register_t *retval) | 183 | svr4_sys_sigaction(struct lwp *l, const struct svr4_sys_sigaction_args *uap, register_t *retval) | |
169 | { | 184 | { | |
170 | /* { | 185 | /* { | |
171 | syscallarg(int) signum; | 186 | syscallarg(int) signum; | |
172 | syscallarg(const struct svr4_sigaction *) nsa; | 187 | syscallarg(const struct svr4_sigaction *) nsa; | |
173 | syscallarg(struct svr4_sigaction *) osa; | 188 | syscallarg(struct svr4_sigaction *) osa; | |
174 | } */ | 189 | } */ | |
175 | struct svr4_sigaction nssa, ossa; | 190 | struct svr4_sigaction nssa, ossa; | |
176 | struct sigaction nbsa, obsa; | 191 | struct sigaction nbsa, obsa; | |
192 | int native_signo; | |||
177 | int error; | 193 | int error; | |
178 | 194 | |||
179 | if (SCARG(uap, nsa)) { | 195 | if (SCARG(uap, nsa)) { | |
180 | error = copyin(SCARG(uap, nsa), &nssa, sizeof(nssa)); | 196 | error = copyin(SCARG(uap, nsa), &nssa, sizeof(nssa)); | |
181 | if (error) | 197 | if (error) | |
182 | return (error); | 198 | return (error); | |
183 | svr4_to_native_sigaction(&nssa, &nbsa); | 199 | svr4_to_native_sigaction(&nssa, &nbsa); | |
184 | } | 200 | } | |
185 | error = sigaction1(l, svr4_to_native_signo[SVR4_SIGNO(SCARG(uap, signum))], | 201 | ||
202 | error = svr4_decode_signum(SCARG(uap, signum), &native_signo, NULL); | |||
203 | if (error) | |||
204 | return error; | |||
205 | ||||
206 | error = sigaction1(l, native_signo, | |||
186 | SCARG(uap, nsa) ? &nbsa : 0, SCARG(uap, osa) ? &obsa : 0, | 207 | SCARG(uap, nsa) ? &nbsa : 0, SCARG(uap, osa) ? &obsa : 0, | |
187 | NULL, 0); | 208 | NULL, 0); | |
188 | if (error) | 209 | if (error) | |
189 | return (error); | 210 | return (error); | |
190 | if (SCARG(uap, osa)) { | 211 | if (SCARG(uap, osa)) { | |
191 | native_to_svr4_sigaction(&obsa, &ossa); | 212 | native_to_svr4_sigaction(&obsa, &ossa); | |
192 | error = copyout(&ossa, SCARG(uap, osa), sizeof(ossa)); | 213 | error = copyout(&ossa, SCARG(uap, osa), sizeof(ossa)); | |
193 | if (error) | 214 | if (error) | |
194 | return (error); | 215 | return (error); | |
195 | } | 216 | } | |
196 | return (0); | 217 | return (0); | |
197 | } | 218 | } | |
198 | 219 | |||
@@ -207,77 +228,79 @@ svr4_sys_sigaltstack(struct lwp *l, cons | @@ -207,77 +228,79 @@ svr4_sys_sigaltstack(struct lwp *l, cons | |||
207 | SVR4_SS_ONSTACK, SVR4_SS_DISABLE); | 228 | SVR4_SS_ONSTACK, SVR4_SS_DISABLE); | |
208 | } | 229 | } | |
209 | 230 | |||
210 | /* | 231 | /* | |
211 | * Stolen from the ibcs2 one | 232 | * Stolen from the ibcs2 one | |
212 | */ | 233 | */ | |
213 | int | 234 | int | |
214 | svr4_sys_signal(struct lwp *l, const struct svr4_sys_signal_args *uap, register_t *retval) | 235 | svr4_sys_signal(struct lwp *l, const struct svr4_sys_signal_args *uap, register_t *retval) | |
215 | { | 236 | { | |
216 | /* { | 237 | /* { | |
217 | syscallarg(int) signum; | 238 | syscallarg(int) signum; | |
218 | syscallarg(svr4_sig_t) handler; | 239 | syscallarg(svr4_sig_t) handler; | |
219 | } */ | 240 | } */ | |
220 | int signum = svr4_to_native_signo[SVR4_SIGNO(SCARG(uap, signum))]; | 241 | int native_signo, sigcall; | |
221 | struct proc *p = l->l_proc; | 242 | struct proc *p = l->l_proc; | |
222 | struct sigaction nbsa, obsa; | 243 | struct sigaction nbsa, obsa; | |
223 | sigset_t ss; | 244 | sigset_t ss; | |
224 | int error; | 245 | int error; | |
225 | 246 | |||
226 | if (signum <= 0 || signum >= SVR4_NSIG) | 247 | error = svr4_decode_signum(SCARG(uap, signum), &native_signo, | |
227 | return (EINVAL); | 248 | &sigcall); | |
249 | if (error) | |||
250 | return error; | |||
228 | 251 | |||
229 | switch (SVR4_SIGCALL(SCARG(uap, signum))) { | 252 | switch (sigcall) { | |
230 | case SVR4_SIGDEFER_MASK: | 253 | case SVR4_SIGDEFER_MASK: | |
231 | if (SCARG(uap, handler) == SVR4_SIG_HOLD) | 254 | if (SCARG(uap, handler) == SVR4_SIG_HOLD) | |
232 | goto sighold; | 255 | goto sighold; | |
233 | /* FALLTHROUGH */ | 256 | /* FALLTHROUGH */ | |
234 | 257 | |||
235 | case SVR4_SIGNAL_MASK: | 258 | case SVR4_SIGNAL_MASK: | |
236 | nbsa.sa_handler = (sig_t)SCARG(uap, handler); | 259 | nbsa.sa_handler = (sig_t)SCARG(uap, handler); | |
237 | sigemptyset(&nbsa.sa_mask); | 260 | sigemptyset(&nbsa.sa_mask); | |
238 | nbsa.sa_flags = 0; | 261 | nbsa.sa_flags = 0; | |
239 | error = sigaction1(l, signum, &nbsa, &obsa, NULL, 0); | 262 | error = sigaction1(l, native_signo, &nbsa, &obsa, NULL, 0); | |
240 | if (error) | 263 | if (error) | |
241 | return (error); | 264 | return (error); | |
242 | *retval = (u_int)(u_long)obsa.sa_handler; | 265 | *retval = (u_int)(u_long)obsa.sa_handler; | |
243 | return (0); | 266 | return (0); | |
244 | 267 | |||
245 | case SVR4_SIGHOLD_MASK: | 268 | case SVR4_SIGHOLD_MASK: | |
246 | sighold: | 269 | sighold: | |
247 | sigemptyset(&ss); | 270 | sigemptyset(&ss); | |
248 | sigaddset(&ss, signum); | 271 | sigaddset(&ss, native_signo); | |
249 | mutex_enter(p->p_lock); | 272 | mutex_enter(p->p_lock); | |
250 | error = sigprocmask1(l, SIG_BLOCK, &ss, 0); | 273 | error = sigprocmask1(l, SIG_BLOCK, &ss, 0); | |
251 | mutex_exit(p->p_lock); | 274 | mutex_exit(p->p_lock); | |
252 | return error; | 275 | return error; | |
253 | 276 | |||
254 | case SVR4_SIGRELSE_MASK: | 277 | case SVR4_SIGRELSE_MASK: | |
255 | sigemptyset(&ss); | 278 | sigemptyset(&ss); | |
256 | sigaddset(&ss, signum); | 279 | sigaddset(&ss, native_signo); | |
257 | mutex_enter(p->p_lock); | 280 | mutex_enter(p->p_lock); | |
258 | error = sigprocmask1(l, SIG_UNBLOCK, &ss, 0); | 281 | error = sigprocmask1(l, SIG_UNBLOCK, &ss, 0); | |
259 | mutex_exit(p->p_lock); | 282 | mutex_exit(p->p_lock); | |
260 | return error; | 283 | return error; | |
261 | 284 | |||
262 | case SVR4_SIGIGNORE_MASK: | 285 | case SVR4_SIGIGNORE_MASK: | |
263 | nbsa.sa_handler = SIG_IGN; | 286 | nbsa.sa_handler = SIG_IGN; | |
264 | sigemptyset(&nbsa.sa_mask); | 287 | sigemptyset(&nbsa.sa_mask); | |
265 | nbsa.sa_flags = 0; | 288 | nbsa.sa_flags = 0; | |
266 | return (sigaction1(l, signum, &nbsa, 0, NULL, 0)); | 289 | return (sigaction1(l, native_signo, &nbsa, 0, NULL, 0)); | |
267 | 290 | |||
268 | case SVR4_SIGPAUSE_MASK: | 291 | case SVR4_SIGPAUSE_MASK: | |
269 | ss = l->l_sigmask; /* XXXAD locking */ | 292 | ss = l->l_sigmask; /* XXXAD locking */ | |
270 | sigdelset(&ss, signum); | 293 | sigdelset(&ss, native_signo); | |
271 | return (sigsuspend1(l, &ss)); | 294 | return (sigsuspend1(l, &ss)); | |
272 | 295 | |||
273 | default: | 296 | default: | |
274 | return (ENOSYS); | 297 | return (ENOSYS); | |
275 | } | 298 | } | |
276 | } | 299 | } | |
277 | 300 | |||
278 | int | 301 | int | |
279 | svr4_sys_sigprocmask(struct lwp *l, const struct svr4_sys_sigprocmask_args *uap, register_t *retval) | 302 | svr4_sys_sigprocmask(struct lwp *l, const struct svr4_sys_sigprocmask_args *uap, register_t *retval) | |
280 | { | 303 | { | |
281 | /* { | 304 | /* { | |
282 | syscallarg(int) how; | 305 | syscallarg(int) how; | |
283 | syscallarg(const svr4_sigset_t *) set; | 306 | syscallarg(const svr4_sigset_t *) set; | |
@@ -383,29 +406,35 @@ svr4_sys_pause(struct lwp *l, const void | @@ -383,29 +406,35 @@ svr4_sys_pause(struct lwp *l, const void | |||
383 | { | 406 | { | |
384 | 407 | |||
385 | return (sigsuspend1(l, 0)); | 408 | return (sigsuspend1(l, 0)); | |
386 | } | 409 | } | |
387 | 410 | |||
388 | int | 411 | int | |
389 | svr4_sys_kill(struct lwp *l, const struct svr4_sys_kill_args *uap, register_t *retval) | 412 | svr4_sys_kill(struct lwp *l, const struct svr4_sys_kill_args *uap, register_t *retval) | |
390 | { | 413 | { | |
391 | /* { | 414 | /* { | |
392 | syscallarg(int) pid; | 415 | syscallarg(int) pid; | |
393 | syscallarg(int) signum; | 416 | syscallarg(int) signum; | |
394 | } */ | 417 | } */ | |
395 | struct sys_kill_args ka; | 418 | struct sys_kill_args ka; | |
419 | int native_signo; | |||
420 | int error; | |||
421 | ||||
422 | error = svr4_decode_signum(SCARG(uap, signum), &native_signo, NULL); | |||
423 | if (error) | |||
424 | return error; | |||
396 | 425 | |||
397 | SCARG(&ka, pid) = SCARG(uap, pid); | 426 | SCARG(&ka, pid) = SCARG(uap, pid); | |
398 | SCARG(&ka, signum) = svr4_to_native_signo[SVR4_SIGNO(SCARG(uap, signum))]; | 427 | SCARG(&ka, signum) = native_signo; | |
399 | return sys_kill(l, &ka, retval); | 428 | return sys_kill(l, &ka, retval); | |
400 | } | 429 | } | |
401 | 430 | |||
402 | void | 431 | void | |
403 | svr4_getcontext(struct lwp *l, struct svr4_ucontext *uc) | 432 | svr4_getcontext(struct lwp *l, struct svr4_ucontext *uc) | |
404 | { | 433 | { | |
405 | sigset_t mask; | 434 | sigset_t mask; | |
406 | struct proc *p = l->l_proc; | 435 | struct proc *p = l->l_proc; | |
407 | 436 | |||
408 | svr4_getmcontext(l, &uc->uc_mcontext, &uc->uc_flags); | 437 | svr4_getmcontext(l, &uc->uc_mcontext, &uc->uc_flags); | |
409 | uc->uc_link = l->l_ctxlink; | 438 | uc->uc_link = l->l_ctxlink; | |
410 | 439 | |||
411 | /* | 440 | /* |
--- src/sys/compat/svr4/Attic/svr4_stream.c 2011/06/26 16:42:41 1.79
+++ src/sys/compat/svr4/Attic/svr4_stream.c 2017/08/19 03:40:48 1.79.22.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: svr4_stream.c,v 1.79 2011/06/26 16:42:41 christos Exp $ */ | 1 | /* $NetBSD: svr4_stream.c,v 1.79.22.1 2017/08/19 03:40:48 snj Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1994, 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1994, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Christos Zoulas. | 8 | * by Christos Zoulas. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -29,27 +29,27 @@ | @@ -29,27 +29,27 @@ | |||
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * Pretend that we have streams... | 33 | * Pretend that we have streams... | |
34 | * Yes, this is gross. | 34 | * Yes, this is gross. | |
35 | * | 35 | * | |
36 | * ToDo: The state machine for getmsg needs re-thinking | 36 | * ToDo: The state machine for getmsg needs re-thinking | |
37 | * | 37 | * | |
38 | * The svr4_32 version is built from this file as well. | 38 | * The svr4_32 version is built from this file as well. | |
39 | */ | 39 | */ | |
40 | 40 | |||
41 | #include <sys/cdefs.h> | 41 | #include <sys/cdefs.h> | |
42 | __KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.79 2011/06/26 16:42:41 christos Exp $"); | 42 | __KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.79.22.1 2017/08/19 03:40:48 snj Exp $"); | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | #include <sys/buf.h> | 47 | #include <sys/buf.h> | |
48 | #include <sys/malloc.h> | 48 | #include <sys/malloc.h> | |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> | |
50 | #include <sys/tty.h> | 50 | #include <sys/tty.h> | |
51 | #include <sys/file.h> | 51 | #include <sys/file.h> | |
52 | #include <sys/filedesc.h> | 52 | #include <sys/filedesc.h> | |
53 | #include <sys/namei.h> | 53 | #include <sys/namei.h> | |
54 | #include <sys/select.h> | 54 | #include <sys/select.h> | |
55 | #include <sys/socket.h> | 55 | #include <sys/socket.h> | |
@@ -516,31 +516,37 @@ si_sockparams(file_t *fp, int fd, struct | @@ -516,31 +516,37 @@ si_sockparams(file_t *fp, int fd, struct | |||
516 | 516 | |||
517 | static int | 517 | static int | |
518 | si_listen(file_t *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l) | 518 | si_listen(file_t *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l) | |
519 | { | 519 | { | |
520 | int error; | 520 | int error; | |
521 | struct svr4_strm *st = svr4_stream_get(fp); | 521 | struct svr4_strm *st = svr4_stream_get(fp); | |
522 | register_t retval; | 522 | register_t retval; | |
523 | struct svr4_strmcmd lst; | 523 | struct svr4_strmcmd lst; | |
524 | struct sys_listen_args la; | 524 | struct sys_listen_args la; | |
525 | 525 | |||
526 | if (st == NULL) | 526 | if (st == NULL) | |
527 | return EINVAL; | 527 | return EINVAL; | |
528 | 528 | |||
529 | if (ioc->len > sizeof(lst)) | 529 | if (ioc->len < offsetof(struct svr4_strmcmd, pad) || | |
530 | ioc->len > sizeof(lst)) | |||
530 | return EINVAL; | 531 | return EINVAL; | |
531 | 532 | |||
532 | if ((error = copyin(NETBSD32PTR(ioc->buf), &lst, ioc->len)) != 0) | 533 | if ((error = copyin(NETBSD32PTR(ioc->buf), &lst, ioc->len)) != 0) | |
533 | return error; | 534 | return error; | |
535 | if (lst.offs < 0 || | |||
536 | lst.len < 0 || | |||
537 | lst.len > ioc->len || | |||
538 | ioc->len - lst.len < lst.offs) | |||
539 | return EINVAL; | |||
534 | 540 | |||
535 | if (lst.cmd != SVR4_TI_OLD_BIND_REQUEST) { | 541 | if (lst.cmd != SVR4_TI_OLD_BIND_REQUEST) { | |
536 | DPRINTF(("si_listen: bad request %ld\n", lst.cmd)); | 542 | DPRINTF(("si_listen: bad request %ld\n", lst.cmd)); | |
537 | return EINVAL; | 543 | return EINVAL; | |
538 | } | 544 | } | |
539 | 545 | |||
540 | /* | 546 | /* | |
541 | * We are making assumptions again... | 547 | * We are making assumptions again... | |
542 | */ | 548 | */ | |
543 | SCARG(&la, s) = fd; | 549 | SCARG(&la, s) = fd; | |
544 | DPRINTF(("SI_LISTEN: fileno %d backlog = %d\n", fd, 5)); | 550 | DPRINTF(("SI_LISTEN: fileno %d backlog = %d\n", fd, 5)); | |
545 | SCARG(&la, backlog) = 5; | 551 | SCARG(&la, backlog) = 5; | |
546 | 552 | |||
@@ -706,27 +712,29 @@ sockmod(file_t *fp, int fd, struct svr4_ | @@ -706,27 +712,29 @@ sockmod(file_t *fp, int fd, struct svr4_ | |||
706 | } | 712 | } | |
707 | } | 713 | } | |
708 | 714 | |||
709 | 715 | |||
710 | static int | 716 | static int | |
711 | ti_getinfo(file_t *fp, int fd, struct svr4_strioctl *ioc, | 717 | ti_getinfo(file_t *fp, int fd, struct svr4_strioctl *ioc, | |
712 | struct lwp *l) | 718 | struct lwp *l) | |
713 | { | 719 | { | |
714 | int error; | 720 | int error; | |
715 | struct svr4_infocmd info; | 721 | struct svr4_infocmd info; | |
716 | 722 | |||
717 | memset(&info, 0, sizeof(info)); | 723 | memset(&info, 0, sizeof(info)); | |
718 | 724 | |||
719 | if (ioc->len > sizeof(info)) | 725 | /* tsdu is next after cmd, the only field we read */ | |
726 | if (ioc->len < offsetof(struct svr4_infocmd, tsdu) || | |||
727 | ioc->len > sizeof(info)) | |||
720 | return EINVAL; | 728 | return EINVAL; | |
721 | 729 | |||
722 | if ((error = copyin(NETBSD32PTR(ioc->buf), &info, ioc->len)) != 0) | 730 | if ((error = copyin(NETBSD32PTR(ioc->buf), &info, ioc->len)) != 0) | |
723 | return error; | 731 | return error; | |
724 | 732 | |||
725 | if (info.cmd != SVR4_TI_INFO_REQUEST) | 733 | if (info.cmd != SVR4_TI_INFO_REQUEST) | |
726 | return EINVAL; | 734 | return EINVAL; | |
727 | 735 | |||
728 | info.cmd = SVR4_TI_INFO_REPLY; | 736 | info.cmd = SVR4_TI_INFO_REPLY; | |
729 | info.tsdu = 0; | 737 | info.tsdu = 0; | |
730 | info.etsdu = 1; | 738 | info.etsdu = 1; | |
731 | info.cdata = -2; | 739 | info.cdata = -2; | |
732 | info.ddata = -2; | 740 | info.ddata = -2; | |
@@ -752,58 +760,70 @@ ti_bind(file_t *fp, int fd, struct svr4_ | @@ -752,58 +760,70 @@ ti_bind(file_t *fp, int fd, struct svr4_ | |||
752 | struct svr4_strm *st = svr4_stream_get(fp); | 760 | struct svr4_strm *st = svr4_stream_get(fp); | |
753 | struct sockaddr_in sain; | 761 | struct sockaddr_in sain; | |
754 | struct sockaddr_un saun; | 762 | struct sockaddr_un saun; | |
755 | void *skp, *sup = NULL; | 763 | void *skp, *sup = NULL; | |
756 | int sasize; | 764 | int sasize; | |
757 | struct svr4_strmcmd bnd; | 765 | struct svr4_strmcmd bnd; | |
758 | struct mbuf *name; | 766 | struct mbuf *name; | |
759 | 767 | |||
760 | if (st == NULL) { | 768 | if (st == NULL) { | |
761 | DPRINTF(("ti_bind: bad file descriptor\n")); | 769 | DPRINTF(("ti_bind: bad file descriptor\n")); | |
762 | return EINVAL; | 770 | return EINVAL; | |
763 | } | 771 | } | |
764 | 772 | |||
765 | if (ioc->len > sizeof(bnd)) | 773 | if (ioc->len < offsetof(struct svr4_strmcmd, pad) || | |
774 | ioc->len > sizeof(bnd)) | |||
766 | return EINVAL; | 775 | return EINVAL; | |
767 | 776 | |||
768 | if ((error = copyin(NETBSD32PTR(ioc->buf), &bnd, ioc->len)) != 0) | 777 | if ((error = copyin(NETBSD32PTR(ioc->buf), &bnd, ioc->len)) != 0) | |
769 | return error; | 778 | return error; | |
770 | 779 | |||
771 | if (bnd.cmd != SVR4_TI_OLD_BIND_REQUEST) { | 780 | if (bnd.cmd != SVR4_TI_OLD_BIND_REQUEST) { | |
772 | DPRINTF(("ti_bind: bad request %ld\n", bnd.cmd)); | 781 | DPRINTF(("ti_bind: bad request %ld\n", bnd.cmd)); | |
773 | return EINVAL; | 782 | return EINVAL; | |
774 | } | 783 | } | |
784 | if (bnd.offs < 0 || | |||
785 | bnd.len < 0 || | |||
786 | bnd.len > ioc->len || | |||
787 | ioc->len - bnd.len < bnd.offs) | |||
788 | return EINVAL; | |||
775 | 789 | |||
776 | switch (st->s_family) { | 790 | switch (st->s_family) { | |
777 | case AF_INET: | 791 | case AF_INET: | |
778 | skp = &sain; | 792 | skp = &sain; | |
779 | sasize = sizeof(sain); | 793 | sasize = sizeof(sain); | |
780 | 794 | |||
781 | if (bnd.offs == 0) | 795 | if (bnd.offs == 0) | |
782 | goto reply; | 796 | goto reply; | |
783 | 797 | |||
798 | if (ioc->len < sizeof(struct svr4_netaddr_in) || | |||
799 | bnd.offs > ioc->len - sizeof(struct svr4_netaddr_in)) | |||
800 | return EINVAL; | |||
784 | netaddr_to_sockaddr_in(&sain, &bnd); | 801 | netaddr_to_sockaddr_in(&sain, &bnd); | |
785 | 802 | |||
786 | DPRINTF(("TI_BIND: fam %d, port %d, addr %x\n", | 803 | DPRINTF(("TI_BIND: fam %d, port %d, addr %x\n", | |
787 | sain.sin_family, sain.sin_port, | 804 | sain.sin_family, sain.sin_port, | |
788 | sain.sin_addr.s_addr)); | 805 | sain.sin_addr.s_addr)); | |
789 | break; | 806 | break; | |
790 | 807 | |||
791 | case AF_LOCAL: | 808 | case AF_LOCAL: | |
792 | skp = &saun; | 809 | skp = &saun; | |
793 | sasize = sizeof(saun); | 810 | sasize = sizeof(saun); | |
794 | if (bnd.offs == 0) | 811 | if (bnd.offs == 0) | |
795 | goto reply; | 812 | goto reply; | |
796 | 813 | |||
814 | if (ioc->len < sizeof(struct svr4_netaddr_un) || | |||
815 | bnd.offs > ioc->len - sizeof(struct svr4_netaddr_un)) | |||
816 | return EINVAL; | |||
797 | netaddr_to_sockaddr_un(&saun, &bnd); | 817 | netaddr_to_sockaddr_un(&saun, &bnd); | |
798 | 818 | |||
799 | if (saun.sun_path[0] == '\0') | 819 | if (saun.sun_path[0] == '\0') | |
800 | goto reply; | 820 | goto reply; | |
801 | 821 | |||
802 | DPRINTF(("TI_BIND: fam %d, path %s\n", | 822 | DPRINTF(("TI_BIND: fam %d, path %s\n", | |
803 | saun.sun_family, saun.sun_path)); | 823 | saun.sun_family, saun.sun_path)); | |
804 | 824 | |||
805 | if ((error = clean_pipe(l, saun.sun_path)) != 0) | 825 | if ((error = clean_pipe(l, saun.sun_path)) != 0) | |
806 | return error; | 826 | return error; | |
807 | 827 | |||
808 | bnd.pad[28] = 0x00001000; /* magic again */ | 828 | bnd.pad[28] = 0x00001000; /* magic again */ | |
809 | break; | 829 | break; | |
@@ -1410,35 +1430,43 @@ svr4_sys_putmsg(struct lwp *l, const str | @@ -1410,35 +1430,43 @@ svr4_sys_putmsg(struct lwp *l, const str | |||
1410 | goto out; | 1430 | goto out; | |
1411 | } else | 1431 | } else | |
1412 | dat.len = -1; | 1432 | dat.len = -1; | |
1413 | 1433 | |||
1414 | /* | 1434 | /* | |
1415 | * Only for sockets for now. | 1435 | * Only for sockets for now. | |
1416 | */ | 1436 | */ | |
1417 | if ((st = svr4_stream_get(fp)) == NULL) { | 1437 | if ((st = svr4_stream_get(fp)) == NULL) { | |
1418 | DPRINTF(("putmsg: bad file type\n")); | 1438 | DPRINTF(("putmsg: bad file type\n")); | |
1419 | error = EINVAL; | 1439 | error = EINVAL; | |
1420 | goto out; | 1440 | goto out; | |
1421 | } | 1441 | } | |
1422 | 1442 | |||
1423 | if (ctl.len > sizeof(sc)) { | 1443 | if (ctl.len < offsetof(struct svr4_strmcmd, pad) || | |
1444 | ctl.len > sizeof(sc)) { | |||
1424 | DPRINTF(("putmsg: Bad control size %ld != %d\n", | 1445 | DPRINTF(("putmsg: Bad control size %ld != %d\n", | |
1425 | (unsigned long)sizeof(struct svr4_strmcmd), ctl.len)); | 1446 | (unsigned long)sizeof(struct svr4_strmcmd), ctl.len)); | |
1426 | error = EINVAL; | 1447 | error = EINVAL; | |
1427 | goto out; | 1448 | goto out; | |
1428 | } | 1449 | } | |
1429 | 1450 | |||
1430 | if ((error = copyin(NETBSD32PTR(ctl.buf), &sc, ctl.len)) != 0) | 1451 | if ((error = copyin(NETBSD32PTR(ctl.buf), &sc, ctl.len)) != 0) | |
1431 | goto out; | 1452 | goto out; | |
1453 | if (sc.offs < 0 || | |||
1454 | sc.len < 0 || | |||
1455 | sc.len > ctl.len || | |||
1456 | sc.offs > ctl.len - sc.len) { | |||
1457 | error = EINVAL; | |||
1458 | goto out; | |||
1459 | } | |||
1432 | 1460 | |||
1433 | switch (st->s_family) { | 1461 | switch (st->s_family) { | |
1434 | case AF_INET: | 1462 | case AF_INET: | |
1435 | if (sc.len != sizeof(sain)) { | 1463 | if (sc.len != sizeof(sain)) { | |
1436 | #ifdef notyet | 1464 | #ifdef notyet | |
1437 | if (sc.cmd == SVR4_TI_DATA_REQUEST) { | 1465 | if (sc.cmd == SVR4_TI_DATA_REQUEST) { | |
1438 | struct sys_write_args wa; | 1466 | struct sys_write_args wa; | |
1439 | 1467 | |||
1440 | /* Solaris seems to use sc.cmd = 3 to | 1468 | /* Solaris seems to use sc.cmd = 3 to | |
1441 | * send "expedited" data. telnet uses | 1469 | * send "expedited" data. telnet uses | |
1442 | * this for options processing, sending EOF, | 1470 | * this for options processing, sending EOF, | |
1443 | * etc. I'm sure other things use it too. | 1471 | * etc. I'm sure other things use it too. | |
1444 | * I don't have any documentation | 1472 | * I don't have any documentation | |
@@ -1463,28 +1491,31 @@ svr4_sys_putmsg(struct lwp *l, const str | @@ -1463,28 +1491,31 @@ svr4_sys_putmsg(struct lwp *l, const str | |||
1463 | netaddr_to_sockaddr_in(&sain, &sc); | 1491 | netaddr_to_sockaddr_in(&sain, &sc); | |
1464 | skp = &sain; | 1492 | skp = &sain; | |
1465 | sasize = sizeof(sain); | 1493 | sasize = sizeof(sain); | |
1466 | error = sain.sin_family != st->s_family; | 1494 | error = sain.sin_family != st->s_family; | |
1467 | break; | 1495 | break; | |
1468 | 1496 | |||
1469 | case AF_LOCAL: | 1497 | case AF_LOCAL: | |
1470 | if (ctl.len == 8) { | 1498 | if (ctl.len == 8) { | |
1471 | /* We are doing an accept; succeed */ | 1499 | /* We are doing an accept; succeed */ | |
1472 | DPRINTF(("putmsg: Do nothing\n")); | 1500 | DPRINTF(("putmsg: Do nothing\n")); | |
1473 | *retval = 0; | 1501 | *retval = 0; | |
1474 | error = 0; | 1502 | error = 0; | |
1475 | goto out; | 1503 | goto out; | |
1476 | } | 1504 | } else if (sc.len < sizeof(dev_t[2])) { | |
1477 | else { | 1505 | *retval = 0; | |
1506 | error = EINVAL; | |||
1507 | goto out; | |||
1508 | } else { | |||
1478 | /* Maybe we've been given a device/inode pair */ | 1509 | /* Maybe we've been given a device/inode pair */ | |
1479 | dev_t *dev = SVR4_ADDROF(&sc); | 1510 | dev_t *dev = SVR4_ADDROF(&sc); | |
1480 | svr4_ino_t *ino = (svr4_ino_t *) &dev[1]; | 1511 | svr4_ino_t *ino = (svr4_ino_t *) &dev[1]; | |
1481 | skp = svr4_find_socket(p, fp, *dev, *ino); | 1512 | skp = svr4_find_socket(p, fp, *dev, *ino); | |
1482 | if (skp == NULL) { | 1513 | if (skp == NULL) { | |
1483 | skp = &saun; | 1514 | skp = &saun; | |
1484 | /* I guess we have it by name */ | 1515 | /* I guess we have it by name */ | |
1485 | netaddr_to_sockaddr_un(skp, &sc); | 1516 | netaddr_to_sockaddr_un(skp, &sc); | |
1486 | } | 1517 | } | |
1487 | sasize = sizeof(saun); | 1518 | sasize = sizeof(saun); | |
1488 | } | 1519 | } | |
1489 | break; | 1520 | break; | |
1490 | 1521 | |||
@@ -1492,30 +1523,32 @@ svr4_sys_putmsg(struct lwp *l, const str | @@ -1492,30 +1523,32 @@ svr4_sys_putmsg(struct lwp *l, const str | |||
1492 | DPRINTF(("putmsg: Unsupported address family %d\n", | 1523 | DPRINTF(("putmsg: Unsupported address family %d\n", | |
1493 | st->s_family)); | 1524 | st->s_family)); | |
1494 | error = ENOSYS; | 1525 | error = ENOSYS; | |
1495 | goto out; | 1526 | goto out; | |
1496 | } | 1527 | } | |
1497 | 1528 | |||
1498 | nam = m_get(M_WAIT, MT_SONAME); | 1529 | nam = m_get(M_WAIT, MT_SONAME); | |
1499 | nam->m_len = sasize; | 1530 | nam->m_len = sasize; | |
1500 | memcpy(mtod(nam, void *), skp, sasize); | 1531 | memcpy(mtod(nam, void *), skp, sasize); | |
1501 | 1532 | |||
1502 | switch (st->s_cmd = sc.cmd) { | 1533 | switch (st->s_cmd = sc.cmd) { | |
1503 | case SVR4_TI_CONNECT_REQUEST: /* connect */ | 1534 | case SVR4_TI_CONNECT_REQUEST: /* connect */ | |
1504 | KERNEL_UNLOCK_ONE(NULL); | 1535 | KERNEL_UNLOCK_ONE(NULL); | |
1536 | fd_putfile(SCARG(uap, fd)); | |||
1505 | return do_sys_connect(l, SCARG(uap, fd), nam); | 1537 | return do_sys_connect(l, SCARG(uap, fd), nam); | |
1506 | 1538 | |||
1507 | case SVR4_TI_SENDTO_REQUEST: /* sendto */ | 1539 | case SVR4_TI_SENDTO_REQUEST: /* sendto */ | |
1508 | KERNEL_UNLOCK_ONE(NULL); | 1540 | KERNEL_UNLOCK_ONE(NULL); | |
1541 | fd_putfile(SCARG(uap, fd)); | |||
1509 | msg.msg_name = nam; | 1542 | msg.msg_name = nam; | |
1510 | msg.msg_namelen = sasize; | 1543 | msg.msg_namelen = sasize; | |
1511 | msg.msg_iov = &aiov; | 1544 | msg.msg_iov = &aiov; | |
1512 | msg.msg_iovlen = 1; | 1545 | msg.msg_iovlen = 1; | |
1513 | msg.msg_control = NULL; | 1546 | msg.msg_control = NULL; | |
1514 | msg.msg_flags = MSG_NAMEMBUF; | 1547 | msg.msg_flags = MSG_NAMEMBUF; | |
1515 | aiov.iov_base = NETBSD32PTR(dat.buf); | 1548 | aiov.iov_base = NETBSD32PTR(dat.buf); | |
1516 | aiov.iov_len = dat.len; | 1549 | aiov.iov_len = dat.len; | |
1517 | error = do_sys_sendmsg(l, SCARG(uap, fd), &msg, | 1550 | error = do_sys_sendmsg(l, SCARG(uap, fd), &msg, | |
1518 | SCARG(uap, flags), retval); | 1551 | SCARG(uap, flags), retval); | |
1519 | 1552 | |||
1520 | *retval = 0; | 1553 | *retval = 0; | |
1521 | return error; | 1554 | return error; | |
@@ -1726,28 +1759,36 @@ svr4_sys_getmsg(struct lwp *l, const str | @@ -1726,28 +1759,36 @@ svr4_sys_getmsg(struct lwp *l, const str | |||
1726 | break; | 1759 | break; | |
1727 | 1760 | |||
1728 | case SVR4_TI_SENDTO_REQUEST: | 1761 | case SVR4_TI_SENDTO_REQUEST: | |
1729 | /* | 1762 | /* | |
1730 | * XXX: dsl - I think this means that because we last did a | 1763 | * XXX: dsl - I think this means that because we last did a | |
1731 | * 'sendto' we'd better do a recvfrom now. | 1764 | * 'sendto' we'd better do a recvfrom now. | |
1732 | */ | 1765 | */ | |
1733 | DPRINTF(("getmsg: TI_SENDTO_REQUEST\n")); | 1766 | DPRINTF(("getmsg: TI_SENDTO_REQUEST\n")); | |
1734 | if (ctl.maxlen > 36 && ctl.len < 36) | 1767 | if (ctl.maxlen > 36 && ctl.len < 36) | |
1735 | ctl.len = 36; | 1768 | ctl.len = 36; | |
1736 | if (ctl.len > sizeof(sc)) | 1769 | if (ctl.len > sizeof(sc)) | |
1737 | ctl.len = sizeof(sc); | 1770 | ctl.len = sizeof(sc); | |
1738 | 1771 | |||
1772 | if (ctl.len < offsetof(struct svr4_strmcmd, pad)) { | |||
1773 | error = EINVAL; | |||
1774 | goto out; | |||
1775 | } | |||
1739 | if ((error = copyin(NETBSD32PTR(ctl.buf), &sc, ctl.len)) != 0) | 1776 | if ((error = copyin(NETBSD32PTR(ctl.buf), &sc, ctl.len)) != 0) | |
1740 | goto out; | 1777 | goto out; | |
1778 | if (sc.offs < 0) { | |||
1779 | error = EINVAL; | |||
1780 | goto out; | |||
1781 | } | |||
1741 | 1782 | |||
1742 | msg.msg_name = NULL; | 1783 | msg.msg_name = NULL; | |
1743 | msg.msg_namelen = 0; | 1784 | msg.msg_namelen = 0; | |
1744 | msg.msg_iov = &aiov; | 1785 | msg.msg_iov = &aiov; | |
1745 | msg.msg_iovlen = 1; | 1786 | msg.msg_iovlen = 1; | |
1746 | msg.msg_control = 0; | 1787 | msg.msg_control = 0; | |
1747 | aiov.iov_base = NETBSD32PTR(dat.buf); | 1788 | aiov.iov_base = NETBSD32PTR(dat.buf); | |
1748 | aiov.iov_len = dat.maxlen; | 1789 | aiov.iov_len = dat.maxlen; | |
1749 | msg.msg_flags = 0; | 1790 | msg.msg_flags = 0; | |
1750 | 1791 | |||
1751 | error = do_sys_recvmsg(l, SCARG(uap, fd), &msg, &name, NULL, | 1792 | error = do_sys_recvmsg(l, SCARG(uap, fd), &msg, &name, NULL, | |
1752 | retval); | 1793 | retval); | |
1753 | 1794 |
--- src/sys/compat/svr4_32/Attic/svr4_32_signal.c 2008/04/28 20:23:46 1.26
+++ src/sys/compat/svr4_32/Attic/svr4_32_signal.c 2017/08/19 03:40:48 1.26.56.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: svr4_32_signal.c,v 1.26 2008/04/28 20:23:46 martin Exp $ */ | 1 | /* $NetBSD: svr4_32_signal.c,v 1.26.56.1 2017/08/19 03:40:48 snj Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1994, 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1994, 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Christos Zoulas and by Charles M. Hannum. | 8 | * by Christos Zoulas and by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: svr4_32_signal.c,v 1.26 2008/04/28 20:23:46 martin Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: svr4_32_signal.c,v 1.26.56.1 2017/08/19 03:40:48 snj Exp $"); | |
34 | 34 | |||
35 | #if defined(_KERNEL_OPT) | 35 | #if defined(_KERNEL_OPT) | |
36 | #include "opt_compat_svr4.h" | 36 | #include "opt_compat_svr4.h" | |
37 | #endif | 37 | #endif | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
41 | #include <sys/namei.h> | 41 | #include <sys/namei.h> | |
42 | #include <sys/proc.h> | 42 | #include <sys/proc.h> | |
43 | #include <sys/filedesc.h> | 43 | #include <sys/filedesc.h> | |
44 | #include <sys/ioctl.h> | 44 | #include <sys/ioctl.h> | |
45 | #include <sys/mount.h> | 45 | #include <sys/mount.h> | |
46 | #include <sys/kernel.h> | 46 | #include <sys/kernel.h> | |
@@ -198,26 +198,41 @@ const int svr4_to_native_signo[SVR4_NSIG | @@ -198,26 +198,41 @@ const int svr4_to_native_signo[SVR4_NSIG | |||
198 | SIGRTMIN + 22, /* 54 */ | 198 | SIGRTMIN + 22, /* 54 */ | |
199 | SIGRTMIN + 23, /* 55 */ | 199 | SIGRTMIN + 23, /* 55 */ | |
200 | SIGRTMIN + 24, /* 56 */ | 200 | SIGRTMIN + 24, /* 56 */ | |
201 | SIGRTMIN + 25, /* 57 */ | 201 | SIGRTMIN + 25, /* 57 */ | |
202 | SIGRTMIN + 26, /* 58 */ | 202 | SIGRTMIN + 26, /* 58 */ | |
203 | SIGRTMIN + 27, /* 59 */ | 203 | SIGRTMIN + 27, /* 59 */ | |
204 | SIGRTMIN + 28, /* 60 */ | 204 | SIGRTMIN + 28, /* 60 */ | |
205 | SIGRTMIN + 29, /* 61 */ | 205 | SIGRTMIN + 29, /* 61 */ | |
206 | SIGRTMIN + 30, /* 62 */ | 206 | SIGRTMIN + 30, /* 62 */ | |
207 | 0, /* 63 */ | 207 | 0, /* 63 */ | |
208 | }; | 208 | }; | |
209 | #endif | 209 | #endif | |
210 | 210 | |||
211 | static int | |||
212 | svr4_32_decode_signum(int signum, int *native_signo, int *sigcall) | |||
213 | { | |||
214 | ||||
215 | if (SVR4_SIGNO(signum) >= SVR4_NSIG) | |||
216 | return EINVAL; | |||
217 | ||||
218 | if (native_signo) | |||
219 | *native_signo = svr4_to_native_signo[SVR4_SIGNO(signum)]; | |||
220 | if (sigcall) | |||
221 | *sigcall = SVR4_SIGCALL(signum); | |||
222 | ||||
223 | return 0; | |||
224 | } | |||
225 | ||||
211 | static inline void | 226 | static inline void | |
212 | svr4_32_sigfillset(svr4_32_sigset_t *s) | 227 | svr4_32_sigfillset(svr4_32_sigset_t *s) | |
213 | { | 228 | { | |
214 | int i; | 229 | int i; | |
215 | 230 | |||
216 | svr4_sigemptyset(s); | 231 | svr4_sigemptyset(s); | |
217 | for (i = 1; i < SVR4_NSIG; i++) | 232 | for (i = 1; i < SVR4_NSIG; i++) | |
218 | if (svr4_to_native_signo[i] != 0) | 233 | if (svr4_to_native_signo[i] != 0) | |
219 | svr4_sigaddset(s, i); | 234 | svr4_sigaddset(s, i); | |
220 | } | 235 | } | |
221 | 236 | |||
222 | void | 237 | void | |
223 | svr4_32_to_native_sigset(const svr4_32_sigset_t *sss, sigset_t *bss) | 238 | svr4_32_to_native_sigset(const svr4_32_sigset_t *sss, sigset_t *bss) | |
@@ -300,37 +315,42 @@ native_to_svr4_32_sigaction(const struct | @@ -300,37 +315,42 @@ native_to_svr4_32_sigaction(const struct | |||
300 | ssa->svr4_32_sa_flags |= SVR4_SA_NOCLDSTOP; | 315 | ssa->svr4_32_sa_flags |= SVR4_SA_NOCLDSTOP; | |
301 | } | 316 | } | |
302 | 317 | |||
303 | int | 318 | int | |
304 | svr4_32_sys_sigaction(struct lwp *l, const struct svr4_32_sys_sigaction_args *uap, register_t *retval) | 319 | svr4_32_sys_sigaction(struct lwp *l, const struct svr4_32_sys_sigaction_args *uap, register_t *retval) | |
305 | { | 320 | { | |
306 | /* { | 321 | /* { | |
307 | syscallarg(int) signum; | 322 | syscallarg(int) signum; | |
308 | syscallarg(const struct svr4_32_sigaction *) nsa; | 323 | syscallarg(const struct svr4_32_sigaction *) nsa; | |
309 | syscallarg(struct svr4_32_sigaction *) osa; | 324 | syscallarg(struct svr4_32_sigaction *) osa; | |
310 | } */ | 325 | } */ | |
311 | struct svr4_32_sigaction nssa, ossa; | 326 | struct svr4_32_sigaction nssa, ossa; | |
312 | struct sigaction nbsa, obsa; | 327 | struct sigaction nbsa, obsa; | |
328 | int native_signo; | |||
313 | int error; | 329 | int error; | |
314 | 330 | |||
315 | if (SCARG_P32(uap, nsa)) { | 331 | if (SCARG_P32(uap, nsa)) { | |
316 | error = copyin(SCARG_P32(uap, nsa), | 332 | error = copyin(SCARG_P32(uap, nsa), | |
317 | &nssa, sizeof(nssa)); | 333 | &nssa, sizeof(nssa)); | |
318 | if (error) | 334 | if (error) | |
319 | return (error); | 335 | return (error); | |
320 | svr4_32_to_native_sigaction(&nssa, &nbsa); | 336 | svr4_32_to_native_sigaction(&nssa, &nbsa); | |
321 | } | 337 | } | |
322 | error = sigaction1(l, | 338 | ||
323 | svr4_to_native_signo[SVR4_SIGNO(SCARG(uap, signum))], | 339 | error = svr4_32_decode_signum(SCARG(uap, signum), &native_signo, NULL); | |
340 | if (error) | |||
341 | return error; | |||
342 | ||||
343 | error = sigaction1(l, native_signo, | |||
324 | SCARG_P32(uap, nsa) ? &nbsa : 0, SCARG_P32(uap, osa) ? &obsa : 0, | 344 | SCARG_P32(uap, nsa) ? &nbsa : 0, SCARG_P32(uap, osa) ? &obsa : 0, | |
325 | NULL, 0); | 345 | NULL, 0); | |
326 | if (error) | 346 | if (error) | |
327 | return (error); | 347 | return (error); | |
328 | if (SCARG_P32(uap, osa)) { | 348 | if (SCARG_P32(uap, osa)) { | |
329 | native_to_svr4_32_sigaction(&obsa, &ossa); | 349 | native_to_svr4_32_sigaction(&obsa, &ossa); | |
330 | error = copyout(&ossa, SCARG_P32(uap, osa), | 350 | error = copyout(&ossa, SCARG_P32(uap, osa), | |
331 | sizeof(ossa)); | 351 | sizeof(ossa)); | |
332 | if (error) | 352 | if (error) | |
333 | return (error); | 353 | return (error); | |
334 | } | 354 | } | |
335 | return (0); | 355 | return (0); | |
336 | } | 356 | } | |
@@ -347,35 +367,37 @@ svr4_32_sys_sigaltstack(struct lwp *l, c | @@ -347,35 +367,37 @@ svr4_32_sys_sigaltstack(struct lwp *l, c | |||
347 | } | 367 | } | |
348 | 368 | |||
349 | /* | 369 | /* | |
350 | * Stolen from the ibcs2 one | 370 | * Stolen from the ibcs2 one | |
351 | */ | 371 | */ | |
352 | int | 372 | int | |
353 | svr4_32_sys_signal(struct lwp *l, const struct svr4_32_sys_signal_args *uap, register_t *retval) | 373 | svr4_32_sys_signal(struct lwp *l, const struct svr4_32_sys_signal_args *uap, register_t *retval) | |
354 | { | 374 | { | |
355 | /* { | 375 | /* { | |
356 | syscallarg(int) signum; | 376 | syscallarg(int) signum; | |
357 | syscallarg(svr4_32_sig_t) handler; | 377 | syscallarg(svr4_32_sig_t) handler; | |
358 | } */ | 378 | } */ | |
359 | struct proc *p = l->l_proc; | 379 | struct proc *p = l->l_proc; | |
360 | int signum = svr4_to_native_signo[SVR4_SIGNO(SCARG(uap, signum))]; | 380 | int native_signo, sigcall; | |
361 | struct sigaction nbsa, obsa; | 381 | struct sigaction nbsa, obsa; | |
362 | sigset_t ss; | 382 | sigset_t ss; | |
363 | int error; | 383 | int error; | |
364 | 384 | |||
365 | if (signum <= 0 || signum >= SVR4_NSIG) | 385 | error = svr4_32_decode_signum(SCARG(uap, signum), &native_signo, | |
366 | return (EINVAL); | 386 | &sigcall); | |
387 | if (error) | |||
388 | return error; | |||
367 | 389 | |||
368 | switch (SVR4_SIGCALL(SCARG(uap, signum))) { | 390 | switch (sigcall) { | |
369 | case SVR4_SIGDEFER_MASK: | 391 | case SVR4_SIGDEFER_MASK: | |
370 | if (SCARG(uap, handler) == SVR4_SIG_HOLD) | 392 | if (SCARG(uap, handler) == SVR4_SIG_HOLD) | |
371 | goto sighold; | 393 | goto sighold; | |
372 | /* FALLTHROUGH */ | 394 | /* FALLTHROUGH */ | |
373 | 395 | |||
374 | case SVR4_SIGNAL_MASK: | 396 | case SVR4_SIGNAL_MASK: | |
375 | nbsa.sa_handler = (sig_t)SCARG(uap, handler); | 397 | nbsa.sa_handler = (sig_t)SCARG(uap, handler); | |
376 | sigemptyset(&nbsa.sa_mask); | 398 | sigemptyset(&nbsa.sa_mask); | |
377 | nbsa.sa_flags = 0; | 399 | nbsa.sa_flags = 0; | |
378 | error = sigaction1(l, signum, &nbsa, &obsa, NULL, 0); | 400 | error = sigaction1(l, signum, &nbsa, &obsa, NULL, 0); | |
379 | if (error) | 401 | if (error) | |
380 | return (error); | 402 | return (error); | |
381 | *retval = (u_int)(u_long)obsa.sa_handler; | 403 | *retval = (u_int)(u_long)obsa.sa_handler; | |
@@ -526,29 +548,35 @@ svr4_32_sys_pause(struct lwp *l, const v | @@ -526,29 +548,35 @@ svr4_32_sys_pause(struct lwp *l, const v | |||
526 | { | 548 | { | |
527 | 549 | |||
528 | return (sigsuspend1(l, 0)); | 550 | return (sigsuspend1(l, 0)); | |
529 | } | 551 | } | |
530 | 552 | |||
531 | int | 553 | int | |
532 | svr4_32_sys_kill(struct lwp *l, const struct svr4_32_sys_kill_args *uap, register_t *retval) | 554 | svr4_32_sys_kill(struct lwp *l, const struct svr4_32_sys_kill_args *uap, register_t *retval) | |
533 | { | 555 | { | |
534 | /* { | 556 | /* { | |
535 | syscallarg(int) pid; | 557 | syscallarg(int) pid; | |
536 | syscallarg(int) signum; | 558 | syscallarg(int) signum; | |
537 | } */ | 559 | } */ | |
538 | struct sys_kill_args ka; | 560 | struct sys_kill_args ka; | |
561 | int native_signo; | |||
562 | int error; | |||
563 | ||||
564 | error = svr4_32_decode_signum(SCARG(uap, signum), &native_signo, NULL); | |||
565 | if (error) | |||
566 | return error; | |||
539 | 567 | |||
540 | SCARG(&ka, pid) = SCARG(uap, pid); | 568 | SCARG(&ka, pid) = SCARG(uap, pid); | |
541 | SCARG(&ka, signum) = svr4_to_native_signo[SVR4_SIGNO(SCARG(uap, signum))]; | 569 | SCARG(&ka, signum) = native_signo; | |
542 | return sys_kill(l, &ka, retval); | 570 | return sys_kill(l, &ka, retval); | |
543 | } | 571 | } | |
544 | 572 | |||
545 | void | 573 | void | |
546 | svr4_32_getcontext(struct lwp *l, struct svr4_32_ucontext *uc, const sigset_t *mask) | 574 | svr4_32_getcontext(struct lwp *l, struct svr4_32_ucontext *uc, const sigset_t *mask) | |
547 | { | 575 | { | |
548 | void *sp; | 576 | void *sp; | |
549 | struct svr4_32_sigaltstack *ss = &uc->uc_stack; | 577 | struct svr4_32_sigaltstack *ss = &uc->uc_stack; | |
550 | 578 | |||
551 | memset(uc, 0, sizeof(*uc)); | 579 | memset(uc, 0, sizeof(*uc)); | |
552 | 580 | |||
553 | /* get machine context */ | 581 | /* get machine context */ | |
554 | sp = svr4_32_getmcontext(l, &uc->uc_mcontext, &uc->uc_flags); | 582 | sp = svr4_32_getmcontext(l, &uc->uc_mcontext, &uc->uc_flags); |