o Replace reference to 'struct proc' with 'struct thread' in 'struct

sysctl_req', which describes in-progress sysctl requests.  This permits
  sysctl handlers to have access to the current thread, permitting work
  on implementing td->td_ucred, migration of suser() to using struct
  thread to derive the appropriate ucred, and allowing struct thread to be
  passed down to other code, such as network code where td is not currently
  available (and curproc is used).

o Note: netncp and netsmb are not updated to reflect this change, as they
  are not currently KSE-adapted.

Reviewed by:		julian
Obtained from:	TrustedBSD Project
This commit is contained in:
rwatson 2001-11-08 02:13:18 +00:00
parent c4a9f1d3ab
commit 8cf42b482a
11 changed files with 36 additions and 34 deletions

View File

@ -56,11 +56,11 @@ linux_sysctl_osname(SYSCTL_HANDLER_ARGS)
char osname[LINUX_MAX_UTSNAME];
int error;
strcpy(osname, linux_get_osname(req->p));
strcpy(osname, linux_get_osname(req->td->td_proc));
error = sysctl_handle_string(oidp, osname, LINUX_MAX_UTSNAME, req);
if (error || req->newptr == NULL)
return (error);
error = linux_set_osname(req->p, osname);
error = linux_set_osname(req->td->td_proc, osname);
return (error);
}
@ -77,11 +77,11 @@ linux_sysctl_osrelease(SYSCTL_HANDLER_ARGS)
char osrelease[LINUX_MAX_UTSNAME];
int error;
strcpy(osrelease, linux_get_osrelease(req->p));
strcpy(osrelease, linux_get_osrelease(req->td->td_proc));
error = sysctl_handle_string(oidp, osrelease, LINUX_MAX_UTSNAME, req);
if (error || req->newptr == NULL)
return (error);
error = linux_set_osrelease(req->p, osrelease);
error = linux_set_osrelease(req->td->td_proc, osrelease);
return (error);
}
@ -98,11 +98,11 @@ linux_sysctl_oss_version(SYSCTL_HANDLER_ARGS)
int oss_version;
int error;
oss_version = linux_get_oss_version(req->p);
oss_version = linux_get_oss_version(req->td->td_proc);
error = sysctl_handle_int(oidp, &oss_version, 0, req);
if (error || req->newptr == NULL)
return (error);
error = linux_set_oss_version(req->p, oss_version);
error = linux_set_oss_version(req->td->td_proc, oss_version);
return (error);
}

View File

@ -155,12 +155,12 @@ sysctl_hostname(SYSCTL_HANDLER_ARGS)
{
int error;
if (jailed(req->p->p_ucred)) {
if (jailed(req->td->td_proc->p_ucred)) {
if (!jail_set_hostname_allowed && req->newptr)
return(EPERM);
error = sysctl_handle_string(oidp,
req->p->p_ucred->cr_prison->pr_host,
sizeof req->p->p_ucred->cr_prison->pr_host, req);
req->td->td_proc->p_ucred->cr_prison->pr_host,
sizeof req->td->td_proc->p_ucred->cr_prison->pr_host, req);
} else
error = sysctl_handle_string(oidp,
hostname, sizeof hostname, req);
@ -186,7 +186,7 @@ sysctl_kern_securelvl(SYSCTL_HANDLER_ARGS)
struct prison *pr;
int error, level;
pr = req->p->p_ucred->cr_prison;
pr = req->td->td_proc->p_ucred->cr_prison;
/*
* If the process is in jail, return the maximum of the global and

View File

@ -848,7 +848,7 @@ kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old,
bzero(&req, sizeof req);
req.p = td->td_proc;
req.td = td;
if (oldlenp) {
req.oldlen = *oldlenp;
@ -1037,12 +1037,12 @@ sysctl_root(SYSCTL_HANDLER_ARGS)
/* Is this sysctl sensitive to securelevels? */
if (req->newptr && (oid->oid_kind & CTLFLAG_SECURE)) {
if (req->p == NULL) {
if (req->td == NULL) {
error = securelevel_gt(NULL, 0); /* XXX */
if (error)
return (error);
} else {
error = securelevel_gt(req->p->p_ucred, 0);
error = securelevel_gt(req->td->td_proc->p_ucred, 0);
if (error)
return (error);
}
@ -1050,14 +1050,14 @@ sysctl_root(SYSCTL_HANDLER_ARGS)
/* Is this sysctl writable by only privileged users? */
if (req->newptr && !(oid->oid_kind & CTLFLAG_ANYBODY)) {
if (req->p != NULL) {
if (req->td != NULL) {
int flags;
if (oid->oid_kind & CTLFLAG_PRISON)
flags = PRISON_ROOT;
else
flags = 0;
error = suser_xxx(NULL, req->p, flags);
error = suser_xxx(NULL, req->td->td_proc, flags);
if (error)
return (error);
}
@ -1132,7 +1132,7 @@ userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
bzero(&req, sizeof req);
req.p = td->td_proc;
req.td = td;
if (oldlenp) {
if (inkernel) {

View File

@ -850,7 +850,7 @@ unp_pcblist(SYSCTL_HANDLER_ARGS)
for (unp = LIST_FIRST(head), i = 0; unp && i < n;
unp = LIST_NEXT(unp, unp_link)) {
if (unp->unp_gencnt <= gencnt) {
if (cr_cansee(req->p->p_ucred,
if (cr_cansee(req->td->td_proc->p_ucred,
unp->unp_socket->so_cred))
continue;
unp_list[i++] = unp;

View File

@ -46,6 +46,7 @@
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/proc.h>
#include <sys/socket.h>
#include <sys/protosw.h>
#include <sys/socketvar.h>
@ -485,7 +486,8 @@ div_pcblist(SYSCTL_HANDLER_ARGS)
s = splnet();
for (inp = LIST_FIRST(divcbinfo.listhead), i = 0; inp && i < n;
inp = LIST_NEXT(inp, inp_list)) {
if (inp->inp_gencnt <= gencnt && !prison_xinpcb(req->p, inp))
if (inp->inp_gencnt <= gencnt && !prison_xinpcb(
req->td->td_proc, inp))
inp_list[i++] = inp;
}
splx(s);

View File

@ -627,7 +627,7 @@ rip_pcblist(SYSCTL_HANDLER_ARGS)
for (inp = LIST_FIRST(ripcbinfo.listhead), i = 0; inp && i < n;
inp = LIST_NEXT(inp, inp_list)) {
if (inp->inp_gencnt <= gencnt) {
if (cr_cansee(req->p->p_ucred,
if (cr_cansee(req->td->td_proc->p_ucred,
inp->inp_socket->so_cred))
continue;
inp_list[i++] = inp;

View File

@ -855,7 +855,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
for (inp = LIST_FIRST(tcbinfo.listhead), i = 0; inp && i < n;
inp = LIST_NEXT(inp, inp_list)) {
if (inp->inp_gencnt <= gencnt) {
if (cr_cansee(req->p->p_ucred,
if (cr_cansee(req->td->td_proc->p_ucred,
inp->inp_socket->so_cred))
continue;
inp_list[i++] = inp;
@ -913,7 +913,7 @@ tcp_getcred(SYSCTL_HANDLER_ARGS)
struct inpcb *inp;
int error, s;
error = suser_xxx(0, req->p, PRISON_ROOT);
error = suser_xxx(0, req->td->td_proc, PRISON_ROOT);
if (error)
return (error);
error = SYSCTL_IN(req, addrs, sizeof(addrs));
@ -926,7 +926,7 @@ tcp_getcred(SYSCTL_HANDLER_ARGS)
error = ENOENT;
goto out;
}
error = cr_cansee(req->p->p_ucred, inp->inp_socket->so_cred);
error = cr_cansee(req->td->td_proc->p_ucred, inp->inp_socket->so_cred);
if (error)
goto out;
bzero(&xuc, sizeof(xuc));
@ -953,7 +953,7 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS)
struct inpcb *inp;
int error, s, mapped = 0;
error = suser_xxx(0, req->p, PRISON_ROOT);
error = suser_xxx(0, req->td->td_proc, PRISON_ROOT);
if (error)
return (error);
error = SYSCTL_IN(req, addrs, sizeof(addrs));
@ -982,7 +982,7 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS)
error = ENOENT;
goto out;
}
error = cr_cansee(req->p->p_ucred, inp->inp_socket->so_cred);
error = cr_cansee(req->td->td_proc->p_ucred, inp->inp_socket->so_cred);
if (error)
goto out;
bzero(&xuc, sizeof(xuc));

View File

@ -855,7 +855,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
for (inp = LIST_FIRST(tcbinfo.listhead), i = 0; inp && i < n;
inp = LIST_NEXT(inp, inp_list)) {
if (inp->inp_gencnt <= gencnt) {
if (cr_cansee(req->p->p_ucred,
if (cr_cansee(req->td->td_proc->p_ucred,
inp->inp_socket->so_cred))
continue;
inp_list[i++] = inp;
@ -913,7 +913,7 @@ tcp_getcred(SYSCTL_HANDLER_ARGS)
struct inpcb *inp;
int error, s;
error = suser_xxx(0, req->p, PRISON_ROOT);
error = suser_xxx(0, req->td->td_proc, PRISON_ROOT);
if (error)
return (error);
error = SYSCTL_IN(req, addrs, sizeof(addrs));
@ -926,7 +926,7 @@ tcp_getcred(SYSCTL_HANDLER_ARGS)
error = ENOENT;
goto out;
}
error = cr_cansee(req->p->p_ucred, inp->inp_socket->so_cred);
error = cr_cansee(req->td->td_proc->p_ucred, inp->inp_socket->so_cred);
if (error)
goto out;
bzero(&xuc, sizeof(xuc));
@ -953,7 +953,7 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS)
struct inpcb *inp;
int error, s, mapped = 0;
error = suser_xxx(0, req->p, PRISON_ROOT);
error = suser_xxx(0, req->td->td_proc, PRISON_ROOT);
if (error)
return (error);
error = SYSCTL_IN(req, addrs, sizeof(addrs));
@ -982,7 +982,7 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS)
error = ENOENT;
goto out;
}
error = cr_cansee(req->p->p_ucred, inp->inp_socket->so_cred);
error = cr_cansee(req->td->td_proc->p_ucred, inp->inp_socket->so_cred);
if (error)
goto out;
bzero(&xuc, sizeof(xuc));

View File

@ -583,7 +583,7 @@ udp_pcblist(SYSCTL_HANDLER_ARGS)
for (inp = LIST_FIRST(udbinfo.listhead), i = 0; inp && i < n;
inp = LIST_NEXT(inp, inp_list)) {
if (inp->inp_gencnt <= gencnt) {
if (cr_cansee(req->p->p_ucred,
if (cr_cansee(req->td->td_proc->p_ucred,
inp->inp_socket->so_cred))
continue;
inp_list[i++] = inp;
@ -635,7 +635,7 @@ udp_getcred(SYSCTL_HANDLER_ARGS)
struct inpcb *inp;
int error, s;
error = suser_xxx(0, req->p, PRISON_ROOT);
error = suser_xxx(0, req->td->td_proc, PRISON_ROOT);
if (error)
return (error);
error = SYSCTL_IN(req, addrs, sizeof(addrs));
@ -648,7 +648,7 @@ udp_getcred(SYSCTL_HANDLER_ARGS)
error = ENOENT;
goto out;
}
error = cr_cansee(req->p->p_ucred, inp->inp_socket->so_cred);
error = cr_cansee(req->td->td_proc->p_ucred, inp->inp_socket->so_cred);
if (error)
goto out;
bzero(&xuc, sizeof(xuc));

View File

@ -464,7 +464,7 @@ udp6_getcred(SYSCTL_HANDLER_ARGS)
struct inpcb *inp;
int error, s;
error = suser(req->p);
error = suser(req->td->td_proc);
if (error)
return (error);

View File

@ -111,7 +111,7 @@ struct ctlname {
* so that we can use the interface from the kernel or from user-space.
*/
struct sysctl_req {
struct proc *p; /* used for access checking */
struct thread *td; /* used for access checking */
int lock;
void *oldptr;
size_t oldlen;