From owner-freebsd-hackers Thu Jul 4 20:18:44 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5B93A37B400 for ; Thu, 4 Jul 2002 20:18:41 -0700 (PDT) Received: from milla.ask33.net (milla.ask33.net [217.197.166.60]) by mx1.FreeBSD.org (Postfix) with ESMTP id EA0E043E09 for ; Thu, 4 Jul 2002 20:18:40 -0700 (PDT) (envelope-from nick@milla.ask33.net) Received: by milla.ask33.net (Postfix, from userid 1001) id A4C363ABB4F; Fri, 5 Jul 2002 05:18:37 +0200 (CEST) Date: Fri, 5 Jul 2002 05:18:37 +0200 From: Pawel Jakub Dawidek To: freebsd-hackers@freebsd.org Subject: Problem with malloc(). Message-ID: <20020705031837.GF347@garage.freebsd.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline X-PGP-Key-URL: http://garage.freebsd.pl/jules.pgp X-OS: FreeBSD 4.6-STABLE i386 User-Agent: Mutt/1.5.1i 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 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