summaryrefslogtreecommitdiff
path: root/sys/kern/kern_xxx.c
diff options
context:
space:
mode:
authorMatthew Dillon <dillon@FreeBSD.org>2001-09-01 05:47:58 +0000
committerMatthew Dillon <dillon@FreeBSD.org>2001-09-01 05:47:58 +0000
commit6f1e8c186f9f87a6c385927f111f521470b00fff (patch)
treeb7aa248569b224dc69ea56ec3af0521cfaf9fe65 /sys/kern/kern_xxx.c
parent3e443c051288d8fabd99d95c568b1ad6a529f339 (diff)
downloadsrc-test2-6f1e8c186f9f87a6c385927f111f521470b00fff.tar.gz
src-test2-6f1e8c186f9f87a6c385927f111f521470b00fff.zip
Notes
Diffstat (limited to 'sys/kern/kern_xxx.c')
-rw-r--r--sys/kern/kern_xxx.c122
1 files changed, 86 insertions, 36 deletions
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);
}