Re: how to access user space memory from kernel.

Ben Collins (bcollins@debian.org)
Mon, 11 Nov 2002 17:59:42 -0500


On Mon, Nov 11, 2002 at 11:40:19PM +0100, David San?n Baena wrote:
> Hi. I need to access to user space memory from a kernel module. This module
> is not a driver, so I would like how can i write and read from/to a variable
> in a user application from my kernel module?
> At first I thought I could do that with shared memory (shmget, shmat...),
> but in that is not possible in a kernel module. So I have thought to do it
> with copy_from_user and copy_to_user, but i don't know how to do it exactly,
> basically how to know where to write or read in the user var...
> Any suggestion???
> Thanks in advance

The user space application will have to make a call to the driver
somehow. Usually this is in the way of an ioctl() on a device that the
driver has made available to use space. The arguments passed across the
ioctl are known to your kernel module and userspace app. You could pass
a pointer to the kernel module which would be userspace memory that the
driver could copy_to_user some data to.

-- 
Debian     - http://www.debian.org/
Linux 1394 - http://www.linux1394.org/
Subversion - http://subversion.tigris.org/
Deqo       - http://www.deqo.com/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/