On 2017-08-21 04:01 PM, Jerome Glisse wrote: >> From this explanation, I think that the user's supplied VA should be >> tested that its a valid writable area of the user. >> How do you test for that ? could you point me to such a code in the kernel ? >> From looking at other drivers that pin host memory, like mellanox nic, >> they don't do any special testing for the address they receive from >> the user. > GUP (get_user_page()) will perform proper check on your behalf. > I am assuming those driver use GUP. On APUs, the GPU can address memory directly through ATS. So it doesn't use GUP. The GPU uses the same page tables as the CPU, so uses the same access bits to check permissions on the fly. On dGPU, when we use VRAM for scratch backing, that doesn't use GUP. In theory it should be possible to use GUP (using our userptr mechanism). In that case GUP would check the access permissions of the underlying mapping. Regards, Felix > > Jérôme