lkml.org 
[lkml]   [2015]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 4/4] iommu/vt-d: Do access checks before calling handle_mm_fault()
From
On Tue, Nov 10, 2015 at 5:26 AM, Joerg Roedel <joro@8bytes.org> wrote:
> +
> +static bool access_error(struct vm_area_struct *vma, struct page_req_dsc *req)
> +{
> + return !((req->rd_req && (vma->vm_flags & VM_READ)) ||
> + (req->wr_req && (vma->vm_flags & VM_WRITE)) ||
> + (req->exe_req && (vma->vm_flags & VM_EXEC)));
> +}

This seems odd.

Shouldn't it be

return ((req->rd_req && !(vma->vm_flags & VM_READ)) ||
(req->wr_req && !(vma->vm_flags & VM_WRITE)) ||
(req->exe_req && !(vma->vm_flags & VM_EXEC)));

instead?

Of course, if you just used the VM_xyz flags internally itself, this
would all be easier, and you'd end up with something like

/* Do we have requested bits that aren't in the allowed set? */
return (requested & ~vma->vm_flags) != 0;

instead..

Linus


\
 
 \ /
  Last update: 2015-11-10 19:01    [W:0.065 / U:0.812 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site