Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2919BC3F2D2 for ; Mon, 2 Mar 2020 11:53:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EE7662086A for ; Mon, 2 Mar 2020 11:53:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XaAMHhG/"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="E+QvBteS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE7662086A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sjtBIiPfffDqq/gvAvJv+pdmeKRrpKm5nBRPRMHausc=; b=XaAMHhG/rGHtql 2XtkvP1l75HwYjcTQf+L4Yw3ZYbw4u0DZMkK5WTMRJbovuP7MIeqmH/ewlKNeSxbzs9R+1l55txty SWe+I4WDU9FeYLPEQRaxgyzuvwbbxBokvZ4R6rP7Pai4Md1ejS/QlBVd9alwrPXZb0D7nenaYyV/Z XykoB1/5BsbOeEe/XMSUdlssPqsdirBqLF6prSZStCUM3VYDK1paHVV8+/YRe2k0cx59/5ObVgOKl 6onh4/+Zn0b/X0mOg61+sOlztJujdSLUq98fsanoH1lf0XMe6GpYIIAN7acyYsNYN0mEC2d5pS6Ub 8HGJ4M20hsraZGHmG/Cg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8jdE-000318-HG; Mon, 02 Mar 2020 11:53:08 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8jdB-00030c-Ql for linux-arm-kernel@lists.infradead.org; Mon, 02 Mar 2020 11:53:07 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 76CC82086A; Mon, 2 Mar 2020 11:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583149985; bh=4bF0iGc4sgOfDaTmJQybE+jlOjpOkg2FBwoN4lDOHYY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=E+QvBteSFpfwnMgtRm9B+mdyId+y4UxlnbaZ8xGCfA98gSqmGPTCojyFkNAW5d7D5 FXUwBQMnGcgpnJwm2QSpTJVx3X1kzoODS/6hcj5iMwNuxq5h52Y4DOPh/dMp5zd0nP HJjjikEhWwXk83t9TOQ3TKzLsXddqxTn4jY6y/HE= Date: Mon, 2 Mar 2020 11:53:01 +0000 From: Will Deacon To: Robin Murphy , joro@8bytes.org Subject: Re: [PATCH] iommu/io-pgtable-arm: Fix IOVA validation for 32-bit Message-ID: <20200302115300.GA9233@willie-the-truck> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200302_035305_894157_3018A87E X-CRM114-Status: GOOD ( 17.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: iommu@lists.linux-foundation.org, Stephan Gerhold , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Feb 28, 2020 at 02:18:55PM +0000, Robin Murphy wrote: > Since we ony support the TTB1 quirk for AArch64 contexts, and > consequently only for 64-bit builds, the sign-extension aspect of the > "are all bits above IAS consistent?" check should implicitly only apply > to 64-bit IOVAs. Change the type of the cast to ensure that 32-bit longs > don't inadvertently get sign-extended, and thus considered invalid, if > they happen to be above 2GB in the TTB0 region. > > Reported-by: Stephan Gerhold > Signed-off-by: Robin Murphy > > --- > > Logically there may also have been a UBSAN "shift greater than size of > type" warning too, but arch/arm doesn't support UBSAN_SANITIZE_ALL, > and that's now my only easy "spin up a 32-bit VM" option to hand :) > > drivers/iommu/io-pgtable-arm.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Acked-by: Will Deacon Joerg -- pleae can you take this as a fix for 5.6? Thanks, Will > diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c > index 983b08477e64..04fbd4bf0ff9 100644 > --- a/drivers/iommu/io-pgtable-arm.c > +++ b/drivers/iommu/io-pgtable-arm.c > @@ -468,7 +468,7 @@ static int arm_lpae_map(struct io_pgtable_ops *ops, unsigned long iova, > arm_lpae_iopte *ptep = data->pgd; > int ret, lvl = data->start_level; > arm_lpae_iopte prot; > - long iaext = (long)iova >> cfg->ias; > + long iaext = (s64)iova >> cfg->ias; > > /* If no access, then nothing to do */ > if (!(iommu_prot & (IOMMU_READ | IOMMU_WRITE))) > @@ -645,7 +645,7 @@ static size_t arm_lpae_unmap(struct io_pgtable_ops *ops, unsigned long iova, > struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops); > struct io_pgtable_cfg *cfg = &data->iop.cfg; > arm_lpae_iopte *ptep = data->pgd; > - long iaext = (long)iova >> cfg->ias; > + long iaext = (s64)iova >> cfg->ias; > > if (WARN_ON(!size || (size & cfg->pgsize_bitmap) != size)) > return 0; > -- > 2.23.0.dirty > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel