From: Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
To: Linus Torvalds
<torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Cc: "open list:AMD IOMMU (AMD-VI)"
<iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>,
David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
Linux Kernel Mailing List
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH 4/4] iommu/vt-d: Do access checks before calling handle_mm_fault()
Date: Tue, 10 Nov 2015 18:57:32 +0100 [thread overview]
Message-ID: <20151110175731.GC13027@8bytes.org> (raw)
In-Reply-To: <CA+55aFwXn2ak_zjKyVGznYwoCDewHicFYX-ngLtrofDPyQ0N=w@mail.gmail.com>
On Tue, Nov 10, 2015 at 09:43:03AM -0800, Linus Torvalds wrote:
> On Tue, Nov 10, 2015 at 5:26 AM, Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.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?
Yes, thats better, it solves the multiple-bits-set problem too, which
David mentioned.
> 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..
But this is probably the best solution, some architecture page-fault
handlers do something similar. I'll update the patch and use this for
the AMD part too.
Thanks,
Joerg
WARNING: multiple messages have this Message-ID (diff)
From: Joerg Roedel <joro@8bytes.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "open list:AMD IOMMU (AMD-VI)" <iommu@lists.linux-foundation.org>,
Oded Gabbay <oded.gabbay@gmail.com>,
David Woodhouse <dwmw2@infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Joerg Roedel <jroedel@suse.de>
Subject: Re: [PATCH 4/4] iommu/vt-d: Do access checks before calling handle_mm_fault()
Date: Tue, 10 Nov 2015 18:57:32 +0100 [thread overview]
Message-ID: <20151110175731.GC13027@8bytes.org> (raw)
In-Reply-To: <CA+55aFwXn2ak_zjKyVGznYwoCDewHicFYX-ngLtrofDPyQ0N=w@mail.gmail.com>
On Tue, Nov 10, 2015 at 09:43:03AM -0800, Linus Torvalds wrote:
> 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?
Yes, thats better, it solves the multiple-bits-set problem too, which
David mentioned.
> 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..
But this is probably the best solution, some architecture page-fault
handlers do something similar. I'll update the patch and use this for
the AMD part too.
Thanks,
Joerg
next prev parent reply other threads:[~2015-11-10 17:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 13:26 [PATCH 0/4] Implement access checks in iommu page fault paths Joerg Roedel
2015-11-10 13:26 ` Joerg Roedel
[not found] ` <1447162006-20672-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2015-11-10 13:26 ` [PATCH 1/4] iommu/amd: Do proper access checking before calling handle_mm_fault() Joerg Roedel
2015-11-10 13:26 ` Joerg Roedel
2015-11-10 13:26 ` [PATCH 2/4] iommu/amd: Correctly set flags for handle_mm_fault call Joerg Roedel
2015-11-10 13:26 ` Joerg Roedel
2015-11-10 13:26 ` [PATCH 3/4] iommu/amd: Cleanup error handling in do_fault() Joerg Roedel
2015-11-10 13:26 ` Joerg Roedel
2015-11-10 13:26 ` [PATCH 4/4] iommu/vt-d: Do access checks before calling handle_mm_fault() Joerg Roedel
2015-11-10 13:26 ` Joerg Roedel
[not found] ` <1447162006-20672-5-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2015-11-10 14:45 ` David Woodhouse
2015-11-10 14:45 ` David Woodhouse
2015-11-10 14:52 ` Joerg Roedel
2015-11-10 17:43 ` Linus Torvalds
2015-11-10 17:43 ` Linus Torvalds
2015-11-10 17:57 ` Joerg Roedel [this message]
2015-11-10 17:57 ` Joerg Roedel
-- strict thread matches above, loose matches on Subject: below --
2015-11-17 15:11 [PATCH 0/4 v2] Implement access checks in iommu page fault paths Joerg Roedel
[not found] ` <1447773099-2444-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2015-11-17 15:11 ` [PATCH 4/4] iommu/vt-d: Do access checks before calling handle_mm_fault() Joerg Roedel
2015-11-17 15:11 ` Joerg Roedel
[not found] ` <1447773099-2444-5-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2015-11-20 15:35 ` David Woodhouse
2015-11-20 15:35 ` David Woodhouse
2015-12-14 14:41 ` Joerg Roedel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151110175731.GC13027@8bytes.org \
--to=joro-zlv9swrftaidnm+yrofe0a@public.gmane.org \
--cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=jroedel-l3A5Bk7waGM@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.