Wed Apr 27 06:22:11 2011 UTC ()
Simplify previous: the original code was mostly correct but relied on
"register_t" being signed.


(martin)
diff -r1.112 -r1.113 src/sys/kern/kern_prot.c

cvs diff -r1.112 -r1.113 src/sys/kern/kern_prot.c (expand / switch to unified diff)

--- src/sys/kern/kern_prot.c 2011/04/26 19:58:12 1.112
+++ src/sys/kern/kern_prot.c 2011/04/27 06:22:11 1.113
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kern_prot.c,v 1.112 2011/04/26 19:58:12 martin Exp $ */ 1/* $NetBSD: kern_prot.c,v 1.113 2011/04/27 06:22:11 martin Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993 4 * Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc. 6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed 7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph 8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc. 10 * the permission of UNIX System Laboratories, Inc.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -31,27 +31,27 @@ @@ -31,27 +31,27 @@
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * @(#)kern_prot.c 8.9 (Berkeley) 2/14/95 36 * @(#)kern_prot.c 8.9 (Berkeley) 2/14/95
37 */ 37 */
38 38
39/* 39/*
40 * System calls related to processes and protection 40 * System calls related to processes and protection
41 */ 41 */
42 42
43#include <sys/cdefs.h> 43#include <sys/cdefs.h>
44__KERNEL_RCSID(0, "$NetBSD: kern_prot.c,v 1.112 2011/04/26 19:58:12 martin Exp $"); 44__KERNEL_RCSID(0, "$NetBSD: kern_prot.c,v 1.113 2011/04/27 06:22:11 martin Exp $");
45 45
46#include "opt_compat_43.h" 46#include "opt_compat_43.h"
47 47
48#include <sys/param.h> 48#include <sys/param.h>
49#include <sys/acct.h> 49#include <sys/acct.h>
50#include <sys/systm.h> 50#include <sys/systm.h>
51#include <sys/ucred.h> 51#include <sys/ucred.h>
52#include <sys/proc.h> 52#include <sys/proc.h>
53#include <sys/timeb.h> 53#include <sys/timeb.h>
54#include <sys/times.h> 54#include <sys/times.h>
55#include <sys/pool.h> 55#include <sys/pool.h>
56#include <sys/prot.h> 56#include <sys/prot.h>
57#include <sys/syslog.h> 57#include <sys/syslog.h>
@@ -221,29 +221,27 @@ sys_getegid(struct lwp *l, const void *v @@ -221,29 +221,27 @@ sys_getegid(struct lwp *l, const void *v
221} 221}
222 222
223int 223int
224sys_getgroups(struct lwp *l, const struct sys_getgroups_args *uap, register_t *retval) 224sys_getgroups(struct lwp *l, const struct sys_getgroups_args *uap, register_t *retval)
225{ 225{
226 /* { 226 /* {
227 syscallarg(int) gidsetsize; 227 syscallarg(int) gidsetsize;
228 syscallarg(gid_t *) gidset; 228 syscallarg(gid_t *) gidset;
229 } */ 229 } */
230 230
231 *retval = kauth_cred_ngroups(l->l_cred); 231 *retval = kauth_cred_ngroups(l->l_cred);
232 if (SCARG(uap, gidsetsize) == 0) 232 if (SCARG(uap, gidsetsize) == 0)
233 return 0; 233 return 0;
234 if (SCARG(uap, gidsetsize) < 0) 234 if (SCARG(uap, gidsetsize) < (int)*retval)
235 return EINVAL; 
236 if (SCARG(uap, gidsetsize) < *retval) 
237 return EINVAL; 235 return EINVAL;
238 236
239 return kauth_cred_getgroups(l->l_cred, SCARG(uap, gidset), *retval, 237 return kauth_cred_getgroups(l->l_cred, SCARG(uap, gidset), *retval,
240 UIO_USERSPACE); 238 UIO_USERSPACE);
241} 239}
242 240
243int 241int
244sys_setsid(struct lwp *l, const void *v, register_t *retval) 242sys_setsid(struct lwp *l, const void *v, register_t *retval)
245{ 243{
246 struct proc *p = l->l_proc; 244 struct proc *p = l->l_proc;
247 int error; 245 int error;
248 246
249 error = proc_enterpgrp(p, p->p_pid, p->p_pid, true); 247 error = proc_enterpgrp(p, p->p_pid, p->p_pid, true);