From owner-freebsd-hackers Wed Jan 19 18:14:13 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from c62443-a.frmt1.sfba.home.com (c62443-a.frmt1.sfba.home.com [24.0.69.165]) by hub.freebsd.org (Postfix) with ESMTP id B19ED152FA for ; Wed, 19 Jan 2000 18:14:10 -0800 (PST) (envelope-from adsharma@c62443-a.frmt1.sfba.home.com) Received: (from adsharma@localhost) by c62443-a.frmt1.sfba.home.com (8.9.3/8.9.3) id SAA17214; Wed, 19 Jan 2000 18:14:10 -0800 Date: Wed, 19 Jan 2000 18:14:10 -0800 From: Arun Sharma Message-Id: <200001200214.SAA17214@c62443-a.frmt1.sfba.home.com> To: zzhang@cs.binghamton.edu, hackers@freebsd.org Subject: Re: Accessing user data from kernel In-Reply-To: References: Reply-To: adsharma@sharmas.dhs.org Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In muc.lists.freebsd.hackers, you wrote: > > When the kernel wants to access any user data, it either copies them into > the kernel or maps them into kernel address space. Can anyone tell me the > reasons why this is done? When a process enters the kernel mode, the > page tables are not changed. > > I have taken this for granted for a long time without knowing the reasons. 1. The kernel may be entered asynchronously - from interrupts and traps. You can't always be sure of which is the currently running user process. 2. For cases where you've entered the kernel synchronously - through syscalls for example, you need to check for the validity of data. You could potentially skip the step and validate the data where it is used, rather than doing it upfront - but that may mean too many checks. It's just cleaner to copyin/copyout once at entry/exit, rather than repeating the code all over the place. -Arun To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message