From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC088AD3B for ; Fri, 23 Dec 2022 22:51:46 +0000 (UTC) Received: by mail-wr1-f54.google.com with SMTP id a17so5642615wrt.11 for ; Fri, 23 Dec 2022 14:51:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=zgisrB3GXNhfj5QT7PKxGigPHzkLxOAE80ws9v/ODJ8=; b=JE2sWa4Yu8dThdpQj3hdzwoPJgLu7Ek5c1lxnDvQGaciiOYLhqdLmVr3wa029wMEVA 6RuDnZ7fgmAgEVNjPeqrGXqldcw28ogkJ6BXpLLr9NvUcrUYREikb6fgHV9ykx57N+b0 V9UAD25tyEQHR6fEK2gnne+2qD00QGios7IH4uLz89LRIkYTx+OjTLSin4Kj2L5fCYb3 5Qf+3OlzC1jwjSB7w4NFkZwFxu7ra9pE3TarAc2MUmL9SJ/Zz9YaMN3OyRuYEbhUozU9 TmB/IqMvA70grEzKQMOr2medIZ0O/Svb79/FFFRpyFvMgOWvP8AprwywHQN9IADSATjH yLBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zgisrB3GXNhfj5QT7PKxGigPHzkLxOAE80ws9v/ODJ8=; b=Yzvsj7jFy0HjpXDJnUwDhrIfeiCYh9vDtSu09PO1+izgBZyH0RVeVdcsm2YGv1KAsU BmnpStAaDXh/hQeN7feUakqh7K09zmDajvyLD0m719JA9W4MWqpv0PGHdCVrzmr8m3Qs B7fFK59kpPb4If9CtX/3ZF+G457657xljjoKwjBbwk/xRd8qbCDRmVrT0WvvRCLLXqwW hZE565NOpz7GCocPDWlkXd1JaCMen/N4om8cgDUfm8WF67/XsKxjbefDkryYjJbsYoIn +4wd70fOGPf/zsVc5YIMEnCw70iJHDHfVRFuPASwglIIYdejPn/sdl8qOZ0/1aEkyIsT N3nQ== X-Gm-Message-State: AFqh2koXtlhpO3vvkNlrKPY8RvDgxyzrA8xFX2Q781fr+OoxJISTPlus ysW7JXyaVNjMkoxSB/tAACw= X-Google-Smtp-Source: AMrXdXtt+Ih5c4VxAqOcpkOcTe0xqgySyIhL7c0oN5cdG0RpuCrrNVzwFokN2JmYf7bRN2PMMucddQ== X-Received: by 2002:adf:de05:0:b0:260:4cca:ffb8 with SMTP id b5-20020adfde05000000b002604ccaffb8mr7179240wrm.36.1671835904860; Fri, 23 Dec 2022 14:51:44 -0800 (PST) Received: from ?IPV6:2a02:1810:3e1d:aa00:47f0:a197:6e87:4e8f? (ptr-1v3h17jmmq23dx2hcb3.18120a2.ip6.access.telenet.be. [2a02:1810:3e1d:aa00:47f0:a197:6e87:4e8f]) by smtp.gmail.com with ESMTPSA id p11-20020adfe60b000000b002366e3f1497sm4355665wrm.6.2022.12.23.14.51.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Dec 2022 14:51:44 -0800 (PST) Message-ID: <43ef46fc-2fbc-31b7-d683-f7496b39dae5@gmail.com> Date: Fri, 23 Dec 2022 23:51:43 +0100 Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] arch/arm/mm/dma-mapping.c: fix __alloc_from_pool returning a dirty buffer Content-Language: ru, nl, en-US To: Christoph Hellwig , linux@armlinux.org.uk Cc: iommu@lists.linux.dev, robin.murphy@arm.com, m.szyprowski@samsung.com, linux-arm-kernel@lists.infradead.org References: <14dccd8c-e29a-fe93-5d4c-f0c3ff4f2430@gmail.com> <20221223143938.GA29147@lst.de> From: Igor Klochko In-Reply-To: <20221223143938.GA29147@lst.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Thanks Christoph, Added fixes and a changelog. This issue is present in all current LTS versions. ---- Buffers allocated by __alloc_from_pool() should be zeroed out as done by other allocators. Certain drivers expect a clean buffer and clearing the buffer is beneficial from the security point of view. --- Fixes: 36d0fd2198da3 (*arm: use genalloc for the atomic pool*) Signed-off-by: Igor Klochko --- arch/arm/mm/dma-mapping.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index c135f6e37a00..bb2bb3ab497a 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -366,6 +366,7 @@ static void *__alloc_from_pool(size_t size, struct page **ret_page) *ret_page = phys_to_page(phys); ptr = (void *)val; + memset(ptr, 0, size); } return ptr; -- 2.39.0 Kind regards, Igor Klochko On 23/12/2022 15:39, Christoph Hellwig wrote: > On Fri, Dec 23, 2022 at 03:15:47PM +0100, Igor Klochko wrote: >> >> Hi, >> >> A small patch for __alloc_from_pool to clean the buffer before returning. > > This does look correct. The "normal" allocators seems to do the > memset through __dma_clear_buffer, but the __alloc_from_pool seems to be > missing it. Please write a proper changelog with a signoff, and > preferably a Fixes tag if you can find what introduced this. Also > the ARM code needs to go to the ARM maintainer and arm mailing list. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 34CACC10F1B for ; Sat, 24 Dec 2022 05:48:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EkvIEMbBXC5xZVNqoBIwsVlPUrh3XGzv5bZTK7UT5Jw=; b=f1ku9l2UTJzjto kNE1cpZs2UoUpdwD+cKq7NgMtj+JikL9FD7LYCECIfS4Hxh6h3axiXZ19TuLO9R7LD6Yrso71xyqc Hq9766ZVEp6YPaZvY6XmVpNbXlfKXe0FxR03gjxsga5EFwGdF8PaXqPhb+BnrenrHM8EHSxd0HwtO +KWWP0ma6r54i4VWyPYip9YvlZ7/bLq7GywYst/bmBGCOT+Dys1vG7AA3/uUmZuDS0Isx04kazTim qctxo+4OOh9esbtfSmzcSxUfyPQqXqrH7bG5ccFjM0PJ1Tu/WxnfX42PQhw9oiBrXqnhs9Ty1Ft1b ZGmR7x6THfykmXCMFcng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8xMj-00FC9B-9n; Sat, 24 Dec 2022 05:46:37 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8qtI-00Cpwd-4F for linux-arm-kernel@lists.infradead.org; Fri, 23 Dec 2022 22:51:49 +0000 Received: by mail-wr1-x42c.google.com with SMTP id h16so5638576wrz.12 for ; Fri, 23 Dec 2022 14:51:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=zgisrB3GXNhfj5QT7PKxGigPHzkLxOAE80ws9v/ODJ8=; b=JE2sWa4Yu8dThdpQj3hdzwoPJgLu7Ek5c1lxnDvQGaciiOYLhqdLmVr3wa029wMEVA 6RuDnZ7fgmAgEVNjPeqrGXqldcw28ogkJ6BXpLLr9NvUcrUYREikb6fgHV9ykx57N+b0 V9UAD25tyEQHR6fEK2gnne+2qD00QGios7IH4uLz89LRIkYTx+OjTLSin4Kj2L5fCYb3 5Qf+3OlzC1jwjSB7w4NFkZwFxu7ra9pE3TarAc2MUmL9SJ/Zz9YaMN3OyRuYEbhUozU9 TmB/IqMvA70grEzKQMOr2medIZ0O/Svb79/FFFRpyFvMgOWvP8AprwywHQN9IADSATjH yLBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zgisrB3GXNhfj5QT7PKxGigPHzkLxOAE80ws9v/ODJ8=; b=7uAVteFhq+NYhhH9xHJ6AdP2JejmakcCLWfs1NikxCzWLfFEqSt/+HoEJSgQhDDBQO rAF/09ujDVChjLH29eDGXbJGt+R/0AdXtI9OdFx1liNHQoCaxXNEHq6T9JVw+6lgmCoQ Vpu/ajRc3pg4moqLzUlddOaQ7tz53IGgicW0KZ6EA9/7/iSObrFBMzaahDgik1qfpXfS Li/p4cxzZ61DUrZf5QzaWs+liHpN7iMqMgUnpvTbLSoROASiJ/s3F6o7S0DXDAluSvnA NO9b+HGAX1M99ECiSsQZ6j2EqAXGlu+cGx9xtbMhao57giNpoZ8LrV2hXxtkGwoiLI4F 04xg== X-Gm-Message-State: AFqh2kp4WmqfF1cTjbgi828SiCcUF/KETC5Y7Z5GpfL6W+n+tB/Th/MY MdgSaJPyxh2YOTjDy3Ma3Ak= X-Google-Smtp-Source: AMrXdXtt+Ih5c4VxAqOcpkOcTe0xqgySyIhL7c0oN5cdG0RpuCrrNVzwFokN2JmYf7bRN2PMMucddQ== X-Received: by 2002:adf:de05:0:b0:260:4cca:ffb8 with SMTP id b5-20020adfde05000000b002604ccaffb8mr7179240wrm.36.1671835904860; Fri, 23 Dec 2022 14:51:44 -0800 (PST) Received: from ?IPV6:2a02:1810:3e1d:aa00:47f0:a197:6e87:4e8f? (ptr-1v3h17jmmq23dx2hcb3.18120a2.ip6.access.telenet.be. [2a02:1810:3e1d:aa00:47f0:a197:6e87:4e8f]) by smtp.gmail.com with ESMTPSA id p11-20020adfe60b000000b002366e3f1497sm4355665wrm.6.2022.12.23.14.51.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Dec 2022 14:51:44 -0800 (PST) Message-ID: <43ef46fc-2fbc-31b7-d683-f7496b39dae5@gmail.com> Date: Fri, 23 Dec 2022 23:51:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] arch/arm/mm/dma-mapping.c: fix __alloc_from_pool returning a dirty buffer Content-Language: ru, nl, en-US To: Christoph Hellwig , linux@armlinux.org.uk Cc: iommu@lists.linux.dev, robin.murphy@arm.com, m.szyprowski@samsung.com, linux-arm-kernel@lists.infradead.org References: <14dccd8c-e29a-fe93-5d4c-f0c3ff4f2430@gmail.com> <20221223143938.GA29147@lst.de> From: Igor Klochko In-Reply-To: <20221223143938.GA29147@lst.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221223_145148_222718_A93D532E X-CRM114-Status: GOOD ( 21.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Thanks Christoph, Added fixes and a changelog. This issue is present in all current LTS versions. ---- Buffers allocated by __alloc_from_pool() should be zeroed out as done by other allocators. Certain drivers expect a clean buffer and clearing the buffer is beneficial from the security point of view. --- Fixes: 36d0fd2198da3 (*arm: use genalloc for the atomic pool*) Signed-off-by: Igor Klochko --- arch/arm/mm/dma-mapping.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index c135f6e37a00..bb2bb3ab497a 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -366,6 +366,7 @@ static void *__alloc_from_pool(size_t size, struct page **ret_page) *ret_page = phys_to_page(phys); ptr = (void *)val; + memset(ptr, 0, size); } return ptr; -- 2.39.0 Kind regards, Igor Klochko On 23/12/2022 15:39, Christoph Hellwig wrote: > On Fri, Dec 23, 2022 at 03:15:47PM +0100, Igor Klochko wrote: >> >> Hi, >> >> A small patch for __alloc_from_pool to clean the buffer before returning. > > This does look correct. The "normal" allocators seems to do the > memset through __dma_clear_buffer, but the __alloc_from_pool seems to be > missing it. Please write a proper changelog with a signoff, and > preferably a Fixes tag if you can find what introduced this. Also > the ARM code needs to go to the ARM maintainer and arm mailing list. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel