kern_resource.c (163709) | kern_resource.c (164033) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 21 unchanged lines hidden (view full) --- 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)kern_resource.c 8.5 (Berkeley) 1/21/94 35 */ 36 37#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 21 unchanged lines hidden (view full) --- 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)kern_resource.c 8.5 (Berkeley) 1/21/94 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/kern/kern_resource.c 163709 2006-10-26 21:42:22Z jb $"); | 38__FBSDID("$FreeBSD: head/sys/kern/kern_resource.c 164033 2006-11-06 13:42:10Z rwatson $"); |
39 40#include "opt_compat.h" 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/sysproto.h> 45#include <sys/file.h> 46#include <sys/kernel.h> 47#include <sys/lock.h> 48#include <sys/malloc.h> 49#include <sys/mutex.h> | 39 40#include "opt_compat.h" 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/sysproto.h> 45#include <sys/file.h> 46#include <sys/kernel.h> 47#include <sys/lock.h> 48#include <sys/malloc.h> 49#include <sys/mutex.h> |
50#include <sys/priv.h> |
|
50#include <sys/proc.h> 51#include <sys/refcount.h> 52#include <sys/resourcevar.h> 53#include <sys/sched.h> 54#include <sys/sx.h> 55#include <sys/syscallsubr.h> 56#include <sys/sysent.h> 57#include <sys/time.h> --- 201 unchanged lines hidden (view full) --- 259 260 PROC_LOCK_ASSERT(p, MA_OWNED); 261 if ((error = p_cansched(td, p))) 262 return (error); 263 if (n > PRIO_MAX) 264 n = PRIO_MAX; 265 if (n < PRIO_MIN) 266 n = PRIO_MIN; | 51#include <sys/proc.h> 52#include <sys/refcount.h> 53#include <sys/resourcevar.h> 54#include <sys/sched.h> 55#include <sys/sx.h> 56#include <sys/syscallsubr.h> 57#include <sys/sysent.h> 58#include <sys/time.h> --- 201 unchanged lines hidden (view full) --- 260 261 PROC_LOCK_ASSERT(p, MA_OWNED); 262 if ((error = p_cansched(td, p))) 263 return (error); 264 if (n > PRIO_MAX) 265 n = PRIO_MAX; 266 if (n < PRIO_MIN) 267 n = PRIO_MIN; |
267 if (n < p->p_nice && suser(td) != 0) | 268 if (n < p->p_nice && priv_check(td, PRIV_SCHED_SETPRIORITY) != 0) |
268 return (EACCES); 269 mtx_lock_spin(&sched_lock); 270 sched_nice(p, n); 271 mtx_unlock_spin(&sched_lock); 272 return (0); 273} 274 275/* --- 187 unchanged lines hidden (view full) --- 463 mtx_unlock_spin(&sched_lock); 464 PROC_UNLOCK(p); 465 return (copyout(&rtp, uap->rtp, sizeof(struct rtprio))); 466 case RTP_SET: 467 if ((error = p_cansched(td, p)) || (error = cierror)) 468 break; 469 470 /* Disallow setting rtprio in most cases if not superuser. */ | 269 return (EACCES); 270 mtx_lock_spin(&sched_lock); 271 sched_nice(p, n); 272 mtx_unlock_spin(&sched_lock); 273 return (0); 274} 275 276/* --- 187 unchanged lines hidden (view full) --- 464 mtx_unlock_spin(&sched_lock); 465 PROC_UNLOCK(p); 466 return (copyout(&rtp, uap->rtp, sizeof(struct rtprio))); 467 case RTP_SET: 468 if ((error = p_cansched(td, p)) || (error = cierror)) 469 break; 470 471 /* Disallow setting rtprio in most cases if not superuser. */ |
471 if (suser(td) != 0) { | 472 if (priv_check(td, PRIV_SCHED_RTPRIO) != 0) { |
472 /* can't set someone else's */ 473 if (uap->pid) { 474 error = EPERM; 475 break; 476 } 477 /* can't set realtime priority */ 478/* 479 * Realtime priority has to be restricted for reasons which should be --- 269 unchanged lines hidden (view full) --- 749 oldssiz = 0; 750 p = td->td_proc; 751 newlim = lim_alloc(); 752 PROC_LOCK(p); 753 oldlim = p->p_limit; 754 alimp = &oldlim->pl_rlimit[which]; 755 if (limp->rlim_cur > alimp->rlim_max || 756 limp->rlim_max > alimp->rlim_max) | 473 /* can't set someone else's */ 474 if (uap->pid) { 475 error = EPERM; 476 break; 477 } 478 /* can't set realtime priority */ 479/* 480 * Realtime priority has to be restricted for reasons which should be --- 269 unchanged lines hidden (view full) --- 750 oldssiz = 0; 751 p = td->td_proc; 752 newlim = lim_alloc(); 753 PROC_LOCK(p); 754 oldlim = p->p_limit; 755 alimp = &oldlim->pl_rlimit[which]; 756 if (limp->rlim_cur > alimp->rlim_max || 757 limp->rlim_max > alimp->rlim_max) |
757 if ((error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL))) { | 758 if ((error = priv_check_cred(td->td_ucred, 759 PRIV_PROC_SETRLIMIT, SUSER_ALLOWJAIL))) { |
758 PROC_UNLOCK(p); 759 lim_free(newlim); 760 return (error); 761 } 762 if (limp->rlim_cur > limp->rlim_max) 763 limp->rlim_cur = limp->rlim_max; 764 lim_copy(newlim, oldlim); 765 alimp = &newlim->pl_rlimit[which]; --- 601 unchanged lines hidden --- | 760 PROC_UNLOCK(p); 761 lim_free(newlim); 762 return (error); 763 } 764 if (limp->rlim_cur > limp->rlim_max) 765 limp->rlim_cur = limp->rlim_max; 766 lim_copy(newlim, oldlim); 767 alimp = &newlim->pl_rlimit[which]; --- 601 unchanged lines hidden --- |