Date: Sun, 22 Jul 2001 21:00:54 +0400 (MSD) From: "Eugene L. Vorokov" <vel@bugz.infotecs.ru> To: freebsd-hackers@freebsd.org Subject: using syscalls in a module (stack problem ?) Message-ID: <200107221700.f6MH0tZ00313@bugz.infotecs.ru>
index | next in thread | raw e-mail
Hello,
using my ugly hack to do file i/o from a module, I discovered some
problem calling mmap() from a function with a lot of local buffers
defined. I have:
char * pizda_malloc(struct proc *p, int size)
{
struct mmap_args mem; int res; register_t save; char *buf;
save = p->p_retval[0];
mem.addr = NULL;
mem.len = size;
mem.prot = PROT_READ | PROT_WRITE;
mem.flags = MAP_ANON;
mem.fd = -1;
mem.pad = 0;
mem.pos = 0;
res = mmap(p, &mem);
if (res)
{
p->p_retval[0] = save;
return NULL;
}
buf = (char *)p->p_retval[0];
p->p_retval[0] = save;
subyte(buf, 0);
return buf;
}
I call this function with (curproc, PATH_MAX+1), and everything is fine
when I have just a few local variables defined in the caller (it all
works on MOD_LOAD only). However, if I have 2 buffers, 4096 bytes each,
as local variables and then try to allocate userspace memory the same
way, kernel crashes - sometimes inside mmap(), sometimes a bit later.
Why could this happen ? Is it related to possible stack overflow ?
(Yes, I know I can use MALLOC instead of static buffers, but I love
to understand what happens ...)
Regards,
Eugene
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200107221700.f6MH0tZ00313>
