Re: About the system call named "sys_mount".

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

 



It seems that for x86 it's the same, a simple mov do the thing, I think it is because (on x86), this function MUST be called in user context, thus cr3 is pointing to the table of the process and thus the kernel can access user pages by a simple mov.

http://lxr.linux.no/linux+v2.6.31/arch/x86/include/asm/uaccess.h#L376


2009/10/20 vinit dhatrak <vinit.dhatrak@xxxxxxxxx>
On Tue, Oct 20, 2009 at 4:38 PM, Rajat Jain <Rajat.Jain@xxxxxxxxxxxx> wrote:
>
> Hi,
>
>> Thank you for your reply.
>> it's interesting, my modified kernel image is run ok on my
>> hardware(arm926ejs). i test mounting ramfs and nfs, they are all ok.
>> are they occasional?
>>
>> sorry, i don't comprehend  your explanation about it
>> In my opinion, if it's possible that the content of
>> parameters isn't in memory at the time of the call, the
>> "sys_mount" can't get them also.
>>
>> could u explain it in detail? Thanks
>
> OK. So here is it. Not all memory used by user space actually needs to
> be in RAM all the time. It may be swapped out to disk since the actual
> memory in use in a system is much more than its RAM size. When a piece
> of memory that is currently swapped out on disk needs to be accessed, it
> needs to be brought back into RAM memory - this is done by the page
> fault handler. But consider that the Disk IO is a very slow process, and
> thus it is relatively a very huge time for the kernel. For this reason,
> any memory that is accessed by the kernel needs to be locked down in RAM
> so that it cannot be swapped out.
>
> Secondly, the 4GB virtual address space is split up into user space and
> kernel space code (3G/1G split generally). User space cannot access
> kernel space virtual addresses and vice versa. Thus the user space
> pointer cannot be dereferenced in the kernel.
>
> Thus, any user data that needs to be accessed firstly needs to be copied
> into kernel address space. This done generally by copy_from_user()
> function or its varians that sys_mount() uses:
>
> exact_copy_from_user((void *)page, data, size);
> strncpy_from_user(page, filename, len);
>
> Now, how you code works comes as a surprize to me though...
>
> Thanks,
>
> Rajat
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>

Probably this code works because as per linux code, __copy_from_user
is defined as memcpy for arm architecture. Correct me if I am wrong
here,

http://lxr.linux.no/#linux+v2.6.31/arch/arm/include/asm/uaccess.h#L393


-Vinit

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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