Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3958694yba; Tue, 9 Apr 2019 08:13:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRflQ+3PruZXDh48n5LQ47uSqleKwDz/wikM60w345w3baF9iOBb25/0NWjPcWqO/hUZzO X-Received: by 2002:a62:2a97:: with SMTP id q145mr37361536pfq.22.1554822833118; Tue, 09 Apr 2019 08:13:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554822833; cv=none; d=google.com; s=arc-20160816; b=AEu4PGzxho9P+Yh6hfcHUsA71GtOAuoOjDBniTsRlL/lqKJuci1XeqcoPwBwTec+ka 0eTrBOw8adi/4kJrBnudL+Xixs2y3C5dFVeoPCk5i1Z11+TKSzItOW4PBrzxXpzHU/FW k2IXcUR0gmuxktyFJVCvWxHfyZ3RetycnoH29kqWxmfpC79dNojIyL2WW+75JMR5qiky DNlsP2RRdtcc20aJ2EOcIIXJeYsdh+akAtOgsUtDodLQtJOi5cWVIx1TpCmUgt+yeUhh z6M6q1EgMLL73IG7hmmkuUGqAIQ6LZaKRcKsEBQB6B/Wkc75T1Go1MwCJt/dbGwSiPRL dbjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=TwjSWDF2WRYzMDWAFF/Is7PHuMvhHAKEgCnC1lQFSDA=; b=l2KjoV2JcDpW0/6vmiCABaJ0kIn14Dkw9fbEkRN8DKPSoQi+W/14RsekR1DkPZwsWH Cf6qARl0Qlpq3LxkIeCjAfxtjrzpWOe2/J3CzqEjjBcPJsP27dUMygCilnaUr7BCTHuv tzk/7HHgs5kPSrq0o5eJbxCMNixnkExYb4+WRvyf3UJcvh9rMO/ahiiJ0lEPyrGcYDyf zm4xNCiirDPEVE8qsYDicf1YOx55heIXtu4co1R2hsge02HQ8aylIlGdEyI0qd9RSRRA L59bnmZae1PagKheSnY73xaXikExY6HI2FMTukFhyeVXtJPbcRqJ7i/CYrVSDt5D8CnM n0sQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y11si22272757pgp.495.2019.04.09.08.13.36; Tue, 09 Apr 2019 08:13:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbfDIPMz (ORCPT + 99 others); Tue, 9 Apr 2019 11:12:55 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:39732 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726465AbfDIPMz (ORCPT ); Tue, 9 Apr 2019 11:12:55 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9087115AB; Tue, 9 Apr 2019 08:12:54 -0700 (PDT) Received: from [10.1.196.75] (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 365E33F68F; Tue, 9 Apr 2019 08:12:53 -0700 (PDT) Subject: Re: [PATCH 02/21] arm64/iommu: improve mmap bounds checking To: Christoph Hellwig Cc: Joerg Roedel , Catalin Marinas , Will Deacon , Tom Lendacky , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20190327080448.5500-1-hch@lst.de> <20190327080448.5500-3-hch@lst.de> <3629087c-a8cb-d66e-840b-cfee125bdf4c@arm.com> <20190407065923.GA9086@lst.de> From: Robin Murphy Message-ID: <45672f18-c741-601d-6bb2-92f50b77e981@arm.com> Date: Tue, 9 Apr 2019 16:12:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190407065923.GA9086@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/04/2019 07:59, Christoph Hellwig wrote: > On Fri, Apr 05, 2019 at 06:30:52PM +0100, Robin Murphy wrote: >> On 27/03/2019 08:04, Christoph Hellwig wrote: >>> The nr_pages checks should be done for all mmap requests, not just those >>> using remap_pfn_range. >> >> Hmm, the logic in iommu_dma_mmap() inherently returns an error for the "off >>> = nr_pages" case already. It's also supposed to be robust against the >> "vma_pages(vma) > nr_pages - off" condition, although by making the partial >> mapping and treating it as a success, rather than doing nothing and >> returning an error. What's the exact motivation here? > > Have one error check at the front of the function that is identical > to the mmap checks in the other dma_map_ops instances so that: > > a) we get the same error behavior for partial requests everywhere > b) we can lift these checks into common code in the next round. > Fair enough, but in that case why isn't the dma_mmap_from_coherent() path also covered? Robin.