Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5632899iog; Thu, 23 Jun 2022 02:06:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sB/EaZ6Lqzei9/tVr13dG/S+Wk1iy1rQxkDzDdjGWDFwwXvtmH2SypEN8DXW8jMMBynAIf X-Received: by 2002:a05:6402:3329:b0:435:8136:cb70 with SMTP id e41-20020a056402332900b004358136cb70mr9115982eda.106.1655975201699; Thu, 23 Jun 2022 02:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655975201; cv=none; d=google.com; s=arc-20160816; b=Jd7nGneuRk1jvPFxrNWF2cz33BmqcacL30RVsPTPaSq8pPRrB0kE/SnZmhOr+sA1rc bQsbaLz67PruXz+AcFEdi7P1dHBU5zQTzYyBpmk1eJ12kknw6/JKQAUThRcW6+onk93k bbBl85gqEw4QU00w2tt+ie6hjjcu47PmlRriuLel+r9x4agwf1vJFrCjahWjDhe3jxAR ntlgZH13mV2/O5shdxNZ5QTmaYqo6bjNBceZWMTIqQkHnfh8Coy/AskrPTF1zcD3VDbl oqYCx78rIV7dljX8hcrLURV++ngkgVnk6RKquMVLF2WSfkw1GXwcWgYjiXale6u2hjnK x3UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=0zYJGODHaNCahj7AwqqtK9slJYTTcH9MaSS4HsW0XZI=; b=lU35EevfUmmqP6lwfOix1BgeG4sBN5o9mHhaKq/2yx5rRGbmEG/t1/3QyRPt54p8Vg OiF7addP84VsyKBo2fda39x+1ZkAlOzDvFTsAKKQYLQp8GHdYBhfW0LPRBUKR/Omcm7Q igBX8svfw631Md1pw1sSRgEmobY3H8Hc570N5Q003mpjDqeJbpuUIl6QNdG4JcVCMBjT OTQ8wYl+LTJV25t36Ek6bm8xrcpEGN6y6aQ8hsMZcCbgsjHrsiF79FT3CNfOGLo3K06r 6K65W7Abjhzzuvoxq6hWAR87Nj5VPzWDhNKaYNi36sydf17wKinZC33JeSDxa0K+jgCJ Fvqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m18-20020a056402431200b00435d8d8821bsi951514edc.2.2022.06.23.02.06.13; Thu, 23 Jun 2022 02:06:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231124AbiFWJBn (ORCPT + 99 others); Thu, 23 Jun 2022 05:01:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbiFWJBm (ORCPT ); Thu, 23 Jun 2022 05:01:42 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4298246B10; Thu, 23 Jun 2022 02:01:40 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BB85912FC; Thu, 23 Jun 2022 02:01:40 -0700 (PDT) Received: from [10.57.85.4] (unknown [10.57.85.4]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 383EF3F792; Thu, 23 Jun 2022 02:01:39 -0700 (PDT) Message-ID: <59c365d8-4b76-4e57-794b-e1d4b3f0e2a5@arm.com> Date: Thu, 23 Jun 2022 10:01:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] dma-direct: use the correct size for dma_set_encrypted() Content-Language: en-GB To: Dexuan Cui , Christoph Hellwig Cc: "m.szyprowski@samsung.com" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "Michael Kelley (LINUX)" , Andrea Parri , Tianyu Lan References: <20220622191424.15777-1-decui@microsoft.com> <20220623054352.GA12543@lst.de> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-06-23 08:00, Dexuan Cui wrote: >> From: Christoph Hellwig >> Sent: Wednesday, June 22, 2022 10:44 PM >> To: Dexuan Cui >> ... >> On Wed, Jun 22, 2022 at 12:14:24PM -0700, Dexuan Cui wrote: >>> The third parameter of dma_set_encrypted() is a size in bytes rather than >>> the number of pages. >>> >>> Fixes: 4d0564785bb0 ("dma-direct: factor out dma_set_{de,en}crypted >> helpers") >>> Signed-off-by: Dexuan Cui >> >> see: >> >> commit 4a37f3dd9a83186cb88d44808ab35b78375082c9 (tag: >> dma-mapping-5.19-2022-05-25) >> Author: Robin Murphy >> Date: Fri May 20 18:10:13 2022 +0100 >> >> dma-direct: don't over-decrypt memory > > It looks like commit 4a37f3dd9a831 fixed a different issue? > > Here my patch is for the latest mainline: > > In dma_direct_alloc()'s error handling path, we pass 'size' to dma_set_encrypted(): > out_encrypt_pages: > if (dma_set_encrypted(dev, page_address(page), size)) > > However, in dma_direct_free(), we pass ' 1 << page_order ' to dma_set_encrypted(). > I think the ' 1 << page_order' is incorrect and it should be 'size' as well? I think technically you're both right - these instances clearly have a history tracing back to the original bug that my patch addressed, but the refactoring then made them into their own distinct bug in terms of the internal dma_set_encrypted() interface, per the commit message here. Apparently I failed to spot this when forward-porting 4a37f3dd9a831 from 5.10 (as the commit message says, don't ask... ;) ) - I guess I was only looking at where the set_memory_*() callsites had moved to. For this patch, Reviewed-by: Robin Murphy Thanks Robin.