Re: copy_to/from_use query?

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

 



On Mon, Oct 11, 2004 at 14:22:56 +0530, Pavan Kumar wrote:
> copy_to_user/copy_from_user takes care of address not in memory (page

Yes.

Note: That means, that copy_to/from_user MAY SLEEP and thus must not be
called with spinlocks held.

> fault), For x86 atleast u can do blind memcpy ( it not
> recommended/portable though ).

On i386, copy_to/from_user uses the FS register. You definitely can't
access kernel memory with that segment, but it's likely that you can
address user-space with kernel segment.

Anyway, you can't do blind memcpy because you can't be sure it's mapped,
if nothing else.

> Pl. correct me if i am wrong.
> 
> On Mon, 11 Oct 2004 09:41:30 +0200, Jan Hudec <bulb@xxxxxx> wrote:
> > On Mon, Oct 11, 2004 at 09:55:37 +0530, mohanlal jangir wrote:
> > > I have a character device and some of its functions are being called by
> > > ioctl. In a function, I do copy_to_user and copy_from_user to get the user
> > > space data in kernel memory. My question is, if this function doesn't sleep,
> > > can I avoid calls to copy_to_user and copy_from_user?
> > 
> > No, you can't. The user-space memory is not directly addressable from
> > kernel.
> > 
> > -------------------------------------------------------------------------------
> >                                                  Jan 'Bulb' Hudec <bulb@xxxxxx>
> > 
> > 
> >
> 
-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@xxxxxx>

Attachment: signature.asc
Description: Digital signature


[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