diff options
author | Matthew Dillon <dillon@FreeBSD.org> | 2001-09-01 05:47:58 +0000 |
---|---|---|
committer | Matthew Dillon <dillon@FreeBSD.org> | 2001-09-01 05:47:58 +0000 |
commit | 6f1e8c186f9f87a6c385927f111f521470b00fff (patch) | |
tree | b7aa248569b224dc69ea56ec3af0521cfaf9fe65 /sys/kern | |
parent | 3e443c051288d8fabd99d95c568b1ad6a529f339 (diff) | |
download | src-test2-6f1e8c186f9f87a6c385927f111f521470b00fff.tar.gz src-test2-6f1e8c186f9f87a6c385927f111f521470b00fff.zip |
Notes
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_ntptime.c | 17 | ||||
-rw-r--r-- | sys/kern/kern_xxx.c | 122 | ||||
-rw-r--r-- | sys/kern/subr_prof.c | 18 |
3 files changed, 113 insertions, 44 deletions
diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index 76814724650e..3d689db405fd 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -38,6 +38,8 @@ #include <sys/sysproto.h> #include <sys/kernel.h> #include <sys/proc.h> +#include <sys/lock.h> +#include <sys/mutex.h> #include <sys/time.h> #include <sys/timex.h> #include <sys/timetc.h> @@ -270,6 +272,9 @@ struct ntp_adjtime_args { }; #endif +/* + * MPSAFE + */ int ntp_adjtime(struct proc *p, struct ntp_adjtime_args *uap) { @@ -292,11 +297,12 @@ ntp_adjtime(struct proc *p, struct ntp_adjtime_args *uap) * the STA_PLL bit in the status word is cleared, the state and * status words are reset to the initial values at boot. */ + mtx_lock(&Giant); modes = ntv.modes; if (modes) error = suser(p); if (error) - return (error); + goto done2; s = splclock(); if (modes & MOD_MAXERROR) time_maxerror = ntv.maxerror; @@ -397,7 +403,7 @@ ntp_adjtime(struct proc *p, struct ntp_adjtime_args *uap) error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv)); if (error) - return (error); + goto done2; /* * Status word error decode. See comments in @@ -409,10 +415,13 @@ ntp_adjtime(struct proc *p, struct ntp_adjtime_args *uap) (time_status & STA_PPSTIME && time_status & STA_PPSJITTER) || (time_status & STA_PPSFREQ && - time_status & (STA_PPSWANDER | STA_PPSERROR))) + time_status & (STA_PPSWANDER | STA_PPSERROR))) { p->p_retval[0] = TIME_ERROR; - else + } else { p->p_retval[0] = time_state; + } +done2: + mtx_unlock(&Giant); return (error); } diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c index 4738aa185f7d..84d88ce979a3 100644 --- a/sys/kern/kern_xxx.c +++ b/sys/kern/kern_xxx.c @@ -41,6 +41,8 @@ #include <sys/sysproto.h> #include <sys/kernel.h> #include <sys/proc.h> +#include <sys/lock.h> +#include <sys/mutex.h> #include <sys/sysctl.h> #include <sys/utsname.h> @@ -53,6 +55,9 @@ struct gethostname_args { u_int len; }; #endif +/* + * MPSAFE + */ /* ARGSUSED */ int ogethostname(p, uap) @@ -60,12 +65,15 @@ ogethostname(p, uap) struct gethostname_args *uap; { int name[2]; + int error; size_t len = uap->len; name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; - return (userland_sysctl(p, name, 2, uap->hostname, &len, - 1, 0, 0, 0)); + mtx_lock(&Giant); + error = userland_sysctl(p, name, 2, uap->hostname, &len, 1, 0, 0, 0); + mtx_unlock(&Giant); + return(error); } #ifndef _SYS_SYSPROTO_H_ @@ -74,6 +82,9 @@ struct sethostname_args { u_int len; }; #endif +/* + * MPSAFE + */ /* ARGSUSED */ int osethostname(p, uap) @@ -85,10 +96,13 @@ osethostname(p, uap) name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; - if ((error = suser_xxx(0, p, PRISON_ROOT))) - return (error); - return (userland_sysctl(p, name, 2, 0, 0, 0, - uap->hostname, uap->len, 0)); + mtx_lock(&Giant); + if ((error = suser_xxx(0, p, PRISON_ROOT)) == 0) { + error = userland_sysctl(p, name, 2, 0, 0, 0, + uap->hostname, uap->len, 0); + } + mtx_unlock(&Giant); + return (error); } #ifndef _SYS_SYSPROTO_H_ @@ -96,6 +110,9 @@ struct ogethostid_args { int dummy; }; #endif +/* + * MPSAFE + */ /* ARGSUSED */ int ogethostid(p, uap) @@ -114,6 +131,9 @@ struct osethostid_args { long hostid; }; #endif +/* + * MPSAFE + */ /* ARGSUSED */ int osethostid(p, uap) @@ -122,18 +142,21 @@ osethostid(p, uap) { int error; - if ((error = suser(p))) - return (error); - hostid = uap->hostid; - return (0); + mtx_lock(&Giant); + if ((error = suser(p)) == 0) + hostid = uap->hostid; + mtx_unlock(&Giant); + return (error); } +/* + * MPSAFE + */ int oquota(p, uap) struct proc *p; struct oquota_args *uap; { - return (ENOSYS); } #endif /* COMPAT_43 */ @@ -152,44 +175,52 @@ struct uname_args { }; #endif +/* + * MPSAFE + */ /* ARGSUSED */ int uname(p, uap) struct proc *p; struct uname_args *uap; { - int name[2], rtval; + int name[2], error; size_t len; char *s, *us; name[0] = CTL_KERN; name[1] = KERN_OSTYPE; - len = sizeof uap->name->sysname; - rtval = userland_sysctl(p, name, 2, uap->name->sysname, &len, + len = sizeof (uap->name->sysname); + mtx_lock(&Giant); + error = userland_sysctl(p, name, 2, uap->name->sysname, &len, 1, 0, 0, 0); - if( rtval) return rtval; + if (error) + goto done2; subyte( uap->name->sysname + sizeof(uap->name->sysname) - 1, 0); name[1] = KERN_HOSTNAME; len = sizeof uap->name->nodename; - rtval = userland_sysctl(p, name, 2, uap->name->nodename, &len, + error = userland_sysctl(p, name, 2, uap->name->nodename, &len, 1, 0, 0, 0); - if( rtval) return rtval; + if (error) + goto done2; subyte( uap->name->nodename + sizeof(uap->name->nodename) - 1, 0); name[1] = KERN_OSRELEASE; len = sizeof uap->name->release; - rtval = userland_sysctl(p, name, 2, uap->name->release, &len, + error = userland_sysctl(p, name, 2, uap->name->release, &len, 1, 0, 0, 0); - if( rtval) return rtval; + if (error) + goto done2; subyte( uap->name->release + sizeof(uap->name->release) - 1, 0); /* name = KERN_VERSION; len = sizeof uap->name->version; - rtval = userland_sysctl(p, name, 2, uap->name->version, &len, + error = userland_sysctl(p, name, 2, uap->name->version, &len, 1, 0, 0, 0); - if( rtval) return rtval; + if (error) + goto done2; subyte( uap->name->version + sizeof(uap->name->version) - 1, 0); */ @@ -199,23 +230,25 @@ uname(p, uap) for(s = version; *s && *s != '#'; s++); for(us = uap->name->version; *s && *s != ':'; s++) { - rtval = subyte( us++, *s); - if( rtval) - return rtval; + error = subyte( us++, *s); + if (error) + goto done2; } - rtval = subyte( us++, 0); - if( rtval) - return rtval; + error = subyte( us++, 0); + if (error) + goto done2; name[0] = CTL_HW; name[1] = HW_MACHINE; len = sizeof uap->name->machine; - rtval = userland_sysctl(p, name, 2, uap->name->machine, &len, + error = userland_sysctl(p, name, 2, uap->name->machine, &len, 1, 0, 0, 0); - if( rtval) return rtval; + if (error) + goto done2; subyte( uap->name->machine + sizeof(uap->name->machine) - 1, 0); - - return 0; +done2: + mtx_unlock(&Giant); + return (error); } #ifndef _SYS_SYSPROTO_H_ @@ -225,16 +258,25 @@ struct getdomainname_args { }; #endif +/* + * MPSAFE + */ /* ARGSUSED */ int getdomainname(p, uap) struct proc *p; struct getdomainname_args *uap; { - int domainnamelen = strlen(domainname) + 1; + int domainnamelen; + int error; + + mtx_lock(&Giant); + domainnamelen = strlen(domainname) + 1; if ((u_int)uap->len > domainnamelen + 1) uap->len = domainnamelen + 1; - return (copyout((caddr_t)domainname, (caddr_t)uap->domainname, uap->len)); + error = copyout((caddr_t)domainname, (caddr_t)uap->domainname, uap->len); + mtx_unlock(&Giant); + return (error); } #ifndef _SYS_SYSPROTO_H_ @@ -244,6 +286,9 @@ struct setdomainname_args { }; #endif +/* + * MPSAFE + */ /* ARGSUSED */ int setdomainname(p, uap) @@ -252,13 +297,18 @@ setdomainname(p, uap) { int error, domainnamelen; + mtx_lock(&Giant); if ((error = suser(p))) - return (error); - if ((u_int)uap->len > sizeof (domainname) - 1) - return EINVAL; + goto done2; + if ((u_int)uap->len > sizeof (domainname) - 1) { + error = EINVAL; + goto done2; + } domainnamelen = uap->len; error = copyin((caddr_t)uap->domainname, domainname, uap->len); domainname[domainnamelen] = 0; +done2: + mtx_unlock(&Giant); return (error); } diff --git a/sys/kern/subr_prof.c b/sys/kern/subr_prof.c index 015f6669447a..e177065f2769 100644 --- a/sys/kern/subr_prof.c +++ b/sys/kern/subr_prof.c @@ -351,6 +351,9 @@ struct profil_args { u_int scale; }; #endif +/* + * MPSAFE + */ /* ARGSUSED */ int profil(p, uap) @@ -359,12 +362,17 @@ profil(p, uap) { register struct uprof *upp; int s; + int error = 0; + + mtx_lock(&Giant); - if (uap->scale > (1 << 16)) - return (EINVAL); + if (uap->scale > (1 << 16)) { + error = EINVAL; + goto done2; + } if (uap->scale == 0) { stopprofclock(p); - return (0); + goto done2; } upp = &p->p_stats->p_prof; @@ -377,7 +385,9 @@ profil(p, uap) startprofclock(p); splx(s); - return (0); +done2: + mtx_unlock(&Giant); + return (error); } /* |