Re: userspace vs. kernelspace address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Simply use

<asm/uaccess.h>

int access_ok(int type, const void * address, unsigned long size)

This checks whether the address is a userspace address, but does not
guarantee that the address is relevant with the desired process.

Also I know that put_user, get_user (described in same header) already
do the access_ok check. Lastly, this information applies for the 2.4
kernel.

Thanks,
Bahadir


On Fri, 28 Jan 2005 08:52:09 +0100, Jan Hudec <bulb@xxxxxx> wrote:
> On Fri, Jan 28, 2005 at 01:06:21 +0100, Bernd Petrovitsch wrote:
> > On Thu, 2005-01-27 at 09:14 -0800, Rock Gordon wrote:
> > > If I'm given a particular address, how do I test
> > > whether that address is from userspace or from kernel
> > > space?
> >
> > You don't.
> >
> > > I need to make these decisions from either inside a
> > > kernel module or a userspace program. The idea is I
> > > use memcpy() in the user-user version,
> > > copy_from/to_user in the kernel-kernel version, and
> > > prohibit the others.
> >
> > You need to know where the address is from and use the correct function.
> 
> If the interface is defined as taking userland address, than kernel
> function passing a kernel address in is responsible for calling
> set_fs(KERNEL_DS) before and undoing it after. That way the
> copy_to/from_user does not complain.
> 
> -------------------------------------------------------------------------------
>                                                 Jan 'Bulb' Hudec <bulb@xxxxxx>
> 
> 
>

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux