From owner-freebsd-hackers Sun Jul 22 9:45:38 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from bugz.infotecs.ru (bugz.infotecs.ru [195.210.139.22]) by hub.freebsd.org (Postfix) with ESMTP id 99DCF37B403 for ; Sun, 22 Jul 2001 09:45:34 -0700 (PDT) (envelope-from vel@bugz.infotecs.ru) Received: (from vel@localhost) by bugz.infotecs.ru (8.11.1/8.11.1) id f6MH0tZ00313 for freebsd-hackers@freebsd.org; Sun, 22 Jul 2001 21:00:55 +0400 (MSD) (envelope-from vel) From: "Eugene L. Vorokov" Message-Id: <200107221700.f6MH0tZ00313@bugz.infotecs.ru> Subject: using syscalls in a module (stack problem ?) To: freebsd-hackers@freebsd.org Date: Sun, 22 Jul 2001 21:00:54 +0400 (MSD) X-Mailer: ELM [version 2.4ME+ PL82 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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