Date: Sat, 22 Apr 2000 16:46:41 -0400 (EDT) From: Andrew Reiter <s467338@gettysburg.edu> To: Marco van de Voort <marcov@stack.nl> Cc: hackers@FreeBSD.ORG Subject: Re: Clone in userland Message-ID: <Pine.GSO.3.96.1000422164355.10163A-200000@jupiter2> In-Reply-To: <20000422183054.D53EB2E802@hermes.tue.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Marco,
Yes..to actually simplify this for myself, I wrote a quick kld that
creates a syscall that wraps the pfind() function. Attached is the source
to this kld.
Andrew
On Sat, 22 Apr 2000, Marco van de Voort wrote:
|
| p2 = pfind(p->p_retval[0]);
|
---------------------------------------------------------
Andrew Reiter <s467338@gettysburg.edu>
Computer Security Engineer
[-- Attachment #2 --]
/*
* procfind.c
*
*
* Description:
* Simply a wrapper for struct proc *pfind(pid_t pid) kernel function
* so that we may access it from userland. Fun.
*
*
*
* Andrew Reiter
* s467338@gettysburg.edu
* 4/00
*
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/module.h>
#include <sys/sysent.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/linker.h>
#include <sys/sysproto.h>
#include <sys/sysent.h>
#include <sys/syscall.h>
#include <sys/sysctl.h>
#include <sys/malloc.h>
#include <sys/ptrace.h>
#include <errno.h>
/*
* Arguments passed in when the syscall is called.
*
*/
struct procfind_args {
pid_t pid;
struct proc *up;
};
static int
procfind(struct proc *curp, struct procfind_args *uap)
{
struct proc *kp;
int err = -2;
if (uap->pid > 0) {
kp = pfind(uap->pid);
if (kp == NULL)
err = ESRCH; /* No such process */
else
err = copyout(kp, uap->up, sizeof(struct proc));
} else
err = ESRCH;
return(err);
}
static struct sysent procfind_sysent = {
2, /* number of arguments */
procfind /* function that is our syscall */
};
static int offset = NO_SYSCALL; /* find next available slot */
static int
load(struct module *m, int cmd, void *arg)
{
int err = 0;
switch(cmd) {
case MOD_LOAD:
printf("Procfind syscall loaded at slot %d\n", offset);
break;
case MOD_UNLOAD:
printf("Procfind syscall unloaded from slot %d\n", offset);
break;
default:
err = EINVAL;
break;
}
return(err);
}
SYSCALL_MODULE(procfind, &offset, &procfind_sysent, load, NULL);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.3.96.1000422164355.10163A-200000>
