Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1870347imu; Fri, 14 Dec 2018 01:55:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/XUYUP5iLvo+LLOuO7j4Rwdldj9EcgsbQf9X5uyGVlz0dajgtZ0vSG9p3QUnk1zGB29n0pc X-Received: by 2002:a17:902:6bc7:: with SMTP id m7mr2304187plt.106.1544781349881; Fri, 14 Dec 2018 01:55:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544781349; cv=none; d=google.com; s=arc-20160816; b=G8SpHdVDnFF9lfCIfLPwS3p25Mn3ZFhoHIwgIcDlJ/CDPq+z6uVzY8ge7dnwyb8wYW g4LMjc+YKINO65TcSXof26t04vZ+RFeTG18pSSYhejcWd79VAIxULnrpuTQ5KINns2Rs 2DMcR6JpqAsSnJ9g09zQN6MfQUTkasgFgaDUYhpH6+4jQH4+9cyGb69q5Td3YDW+d8FH iXtooen49vPzW/NelGrjp6ehrgJTBB/NNqwyK+57obDHg52kD7OteCzG9BSDlRn99T+p GpTOKV56IatuM7zUnyb5TtjG6VqJ/ITOcdVW2MTccG4AfXM9S7wdintuPg4So5S637uO rRUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=ZmOXgJcbHhufParBJqg3xoT0d8IDsJkN3yKsm3zgfSE=; b=x8ycwJqRUiSJZETYrYlCbVjuhD5Xy0K3BShewmNVVH6hxAHacuejduqAazJUzhTFQ3 UaqNIJfDnbxxEK2yiIQFgAQzNR79s+kMuzei0XqZYL40z6mvo6Ql4jrxwCHVKuPV28Au ENO9ybI3JOCKtoQAaTi7R65s5yjf8HgGkNjvmayW++HZjBqLzt3Bp6/0/atRGl1awVly wXA2JRPtUSBnD96OTWbQSj0zKBtAnexLhNoB2Tpv9Yqsf5OO7/vyy3WA/4Tj+LhmyYd0 tvx1OzlNyAsoVwnMSYTkrg1maTaQBbBAfwHyAJWE2xqqr7FCn8aO+F1lmusraQxmonrw Uuug== 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 l8si3798867pgr.345.2018.12.14.01.55.34; Fri, 14 Dec 2018 01:55:49 -0800 (PST) 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 S1728951AbeLNJyq (ORCPT + 99 others); Fri, 14 Dec 2018 04:54:46 -0500 Received: from mail-vs1-f68.google.com ([209.85.217.68]:40866 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726494AbeLNJyp (ORCPT ); Fri, 14 Dec 2018 04:54:45 -0500 Received: by mail-vs1-f68.google.com with SMTP id z3so3010879vsf.7; Fri, 14 Dec 2018 01:54:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZmOXgJcbHhufParBJqg3xoT0d8IDsJkN3yKsm3zgfSE=; b=SFIhtsZEu/GSbo74Wbms3iTK2ekg2LHz0ZvuKNGGFniH2w3KmmZVuhtFm77CmD+eIS KdUFx9hrBHn3U20JZcN3aRGyiGTSqGnhw/9Ee3rZcPCmt/C7VnyFZevE3Gx7G+YGsatU 4ZK9lZy0vDbT8P0UD501qc8+k1MGxhkO7zAl65Nvru65toAEoOb7p1KItUfGW6dgwbfV lIW00pZ2+OdLKcuT6q5IdgE8S16eb+v3mKVPSW8S5uJcnnupayn1rkO25jLh+6eh09he /wXpfnrF939myp7AXksqMTyvhv6YjFKouIDnEfFRFCTWOfCoZzR79YREi3XWOVzd53Xj Sx3Q== X-Gm-Message-State: AA+aEWZF4GxK3Py0yHXuEmD2lukgC+AM1mD/uA8BcFsleNHYUbPMS7gL YS4wF+vlLIg5wj4A0lKNguvVk5BtYAdRJAMKDJs= X-Received: by 2002:a67:d119:: with SMTP id u25mr898856vsi.63.1544781284417; Fri, 14 Dec 2018 01:54:44 -0800 (PST) MIME-Version: 1.0 References: <20181214082515.14835-1-hch@lst.de> <20181214082515.14835-2-hch@lst.de> In-Reply-To: <20181214082515.14835-2-hch@lst.de> From: Geert Uytterhoeven Date: Fri, 14 Dec 2018 10:54:32 +0100 Message-ID: Subject: Re: [PATCH 1/2] dma-mapping: zero memory returned from dma_alloc_* To: Christoph Hellwig Cc: Linux IOMMU , Michal Simek , ashutosh.dixit@intel.com, alpha , arcml , linux-c6x-dev@linux-c6x.org, linux-m68k , Openrisc , Parisc List , linux-s390 , sparclinux , linux-xtensa@linux-xtensa.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christoph, On Fri, Dec 14, 2018 at 9:26 AM Christoph Hellwig wrote: > If we want to map memory from the DMA allocator to userspace it must be > zeroed at allocation time to prevent stale data leaks. We already do > this on most common architectures, but some architectures don't do this > yet, fix them up, either by passing GFP_ZERO when we use the normal page > allocator or doing a manual memset otherwise. > > Signed-off-by: Christoph Hellwig Thanks for your patch! > --- a/arch/m68k/kernel/dma.c > +++ b/arch/m68k/kernel/dma.c > @@ -32,7 +32,7 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, > size = PAGE_ALIGN(size); > order = get_order(size); > > - page = alloc_pages(flag, order); > + page = alloc_pages(flag | GFP_ZERO, order); > if (!page) > return NULL; There's second implementation below, which calls __get_free_pages() and does an explicit memset(). As __get_free_pages() calls alloc_pages(), perhaps it makes sense to replace the memset() by GFP_ZERO, to increase consistency? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds