Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752564AbbKJRnG (ORCPT ); Tue, 10 Nov 2015 12:43:06 -0500 Received: from mail-ig0-f170.google.com ([209.85.213.170]:33234 "EHLO mail-ig0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751559AbbKJRnF (ORCPT ); Tue, 10 Nov 2015 12:43:05 -0500 MIME-Version: 1.0 In-Reply-To: <1447162006-20672-5-git-send-email-joro@8bytes.org> References: <1447162006-20672-1-git-send-email-joro@8bytes.org> <1447162006-20672-5-git-send-email-joro@8bytes.org> Date: Tue, 10 Nov 2015 09:43:03 -0800 X-Google-Sender-Auth: DVqUCfvUQOTg7xc-1VaaoHCMaSo Message-ID: Subject: Re: [PATCH 4/4] iommu/vt-d: Do access checks before calling handle_mm_fault() From: Linus Torvalds To: Joerg Roedel Cc: "open list:AMD IOMMU (AMD-VI)" , Oded Gabbay , David Woodhouse , Linux Kernel Mailing List , Joerg Roedel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1112 Lines: 33 On Tue, Nov 10, 2015 at 5:26 AM, Joerg Roedel 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/