Date: Fri, 5 Jul 2002 05:18:37 +0200 From: Pawel Jakub Dawidek <nick@garage.freebsd.pl> To: freebsd-hackers@freebsd.org Subject: Problem with malloc(). Message-ID: <20020705031837.GF347@garage.freebsd.pl>
next in thread | raw e-mail | index | archive | help
Hello there...
For example: we are in kernelspace and I want to change name of executed
files befor execution.
Example kernel module:
sysent[SYS_execve].sy_call = (sy_call_t *)n_execve;
#define FOOBAR "foobar"
int
n_execve(struct proc *p, struct execve_args *uap)
{
char *myname;
if (strcmp(uap->fname, "foo") == 0) {
myname = (char *)malloc(strlen(FOOBAR) + 1, M_TEMP, M_WAITOK);
strcpy(myname, FOOBAR);
/* and now: */
uap->fname = myname;
}
return execve(p, uap);
}
This of course will return EFAULT. How to allocate memory that will be used
in userspace when I'm in kernelspace? Yes, "foobar" is longer than "foo":)
--
Pawel Jakub Dawidek
UNIX Systems Administrator
http://garage.freebsd.pl
Am I Evil? Yes, I Am.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020705031837.GF347>
