lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Fri, 12 Aug 2011 13:27:53 +0200
From:	Clemens Ladisch <clemens@...isch.de>
To:	Pecker Hu <pecker.hu@...il.com>
CC:	linux-kernel@...r.kernel.org
Subject: Re: Need help about how linux to handle translation fault

Pecker Hu wrote:
> ...
> And I send the address of str to kernel space using IOCTL interface.
> ioctl(fd, VM_TEST_GET_VADDR, str);
> 
> When I try to use pgd to find the physical address, I don't find it
> .

You must not directly access user space memory from kernel space because
that memory can be moved or swapped out at any time.  Use only functions
like copy_from_user() which take appropriate precautions; and don't
forget to check for errors.

Furthermore, the physical address is useless.  If you want to access
the memory from a device, you have to use the DMA mapping API because
the CPU's physical address it not necessarily the same address as that
used on the device's bus, and sometimes you have to program an IOMMU
before devices are allowed to access that memory at all.

> So I think string array is located in data cache not in physical
> memory, after I call copy_from_user, kernel will allocate page for it,
> then we can access it, is it right?

As far as any code running on the CPU is concerned, caches are
completely transparent.  (This is not always true for devices, but the
DMA mapping API takes care of that.)


Regards,
Clemens
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ