Received: by 10.223.176.5 with SMTP id f5csp1207009wra; Tue, 6 Feb 2018 14:50:23 -0800 (PST) X-Google-Smtp-Source: AH8x226xMsGLcfYz8hKZH0RHBvcvY/sECOOg2cx+Ic0mDUaCkkaq2M3nCXL31IHl1y+uBiVL2jB3 X-Received: by 10.98.150.14 with SMTP id c14mr1986295pfe.210.1517957423504; Tue, 06 Feb 2018 14:50:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517957423; cv=none; d=google.com; s=arc-20160816; b=W8Kj5v/g5xofuiJYnfS1F8P5LhnQimYfAI1RJJE+q+RoqUotKa2jy1WyaG6K+nBxCF WTX8KetlKJrhB3yf/hmKJMiCcogO+p/qeLkR9ZIC3fLxihlSGBsb8A+lxwCFN0gFt7pw sUngtxweyADh0iNNyRqXDlHRvzKPx9LECRdQ5pbctwKsEMWzfca3qxxssaFN/NRNODmN 7KNsZYTZ1ViPbJuq+Pjs0kmz9DjI82s+mNwlnnuHy7dPxMzXirsej2PFFgLsrji+tR6J y2j66N7dI6TJHKx496FmO0HWZRRT/UtJXM8mi/dmgb0zmhkHRXP4tmTe+fjNLQn4I1Bl O2aw== 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:arc-authentication-results; bh=XPB6dNZ8A+YPFr5lUMgHAE8B/Nk+PyGmYhmEkIXCMZQ=; b=qyjxFxQJ7DeiGfEji8FNJZr2fUHVzMo1dciUxs1r7EnhirCQAIEdTySLGUa1meHyi4 IjCHpyk5mN3MKUNDITcNDx2VN6tmMSRy4yxOuAwt9CcwfrtVdJQKm0lQMF0FzyxbuAE4 ZAn1aiQzP2xDA/a+B7JxxCqGaXhEEqlU9lSfGn5Imz8gVF0znYU7cj/TxpCjg47S2k8U k7l9S8OfxfmgIsvw+6GwTrkMuj2PugGmpy7B10ykogKyyxifSKCkQh3wd9/Tnl2B4PE+ TkR9fFwx39lrzjA12RRYYAWe4AABpzC4GzhAv3EAlDaAkIvQoC+FTSm+WI9a/xDkKJX5 /sDQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10-v6si22624plo.518.2018.02.06.14.50.09; Tue, 06 Feb 2018 14:50:23 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753773AbeBFWtO (ORCPT + 99 others); Tue, 6 Feb 2018 17:49:14 -0500 Received: from mail-ot0-f196.google.com ([74.125.82.196]:37129 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753753AbeBFWtM (ORCPT ); Tue, 6 Feb 2018 17:49:12 -0500 Received: by mail-ot0-f196.google.com with SMTP id e64so3365138ote.4 for ; Tue, 06 Feb 2018 14:49:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=XPB6dNZ8A+YPFr5lUMgHAE8B/Nk+PyGmYhmEkIXCMZQ=; b=QD9dEldgEc4XCkNyvbEAiYNEMrUiWVa8OM3S+Dx3RMUMwK1A516ivfxuj/cuae8Cf4 lE0AiLfRldgxie4Qm2G3VgohD+qM9xl4etM3tzb79eBPHqBVavVrxpDP0L6tRFeV7BAJ +lB++jnNLZqmfong/BLZaCoZf3nVLNbSCjwvG4K03QpHOBGiSDGieY/l162iv45+f/C/ NwPv9HWEh/wcbDMvGbK6vxZOC2px13Q55+vOCWYhHkFvnky8EE0yGiuF4feEuvErXWH1 pJpNDVQHE/f6RMjevLWR/aLoHDWhK40XxAJLYfxerVI6tpCs2UXBcf4l6+mZu+QXwDGf oJfQ== X-Gm-Message-State: APf1xPC9g/gOMTcVTU6NdGxKYu9ojAYyKnOY+pOMHcsbDhVEU4rNlNuq 5AQ1m9QNQ0DBV1GjNoO9WVM24Q== X-Received: by 10.157.5.66 with SMTP id 60mr2820278otw.203.1517957351959; Tue, 06 Feb 2018 14:49:11 -0800 (PST) Received: from ?IPv6:2601:602:9802:a8dc::f21a? ([2601:602:9802:a8dc::f21a]) by smtp.gmail.com with ESMTPSA id m3sm46048oif.44.2018.02.06.14.49.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Feb 2018 14:49:10 -0800 (PST) Subject: Re: [PATCH v3] staging: android: ion: Zero CMA allocated memory To: Liam Mark , Sumit Semwal Cc: Dan Carpenter , Greg KH , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linaro-mm-sig@lists.linaro.org References: From: Laura Abbott Message-ID: Date: Tue, 6 Feb 2018 14:49:09 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/26/2018 09:48 AM, Liam Mark wrote: > Since commit 204f672255c2 ("staging: android: ion: Use CMA APIs directly") > the CMA API is now used directly and therefore the allocated memory is no > longer automatically zeroed. > > Explicitly zero CMA allocated memory to ensure that no data is exposed to > userspace. > Acked-by: Laura Abbott > Fixes: 204f672255c2 ("staging: android: ion: Use CMA APIs directly") > Signed-off-by: Liam Mark > --- > Changes in v2: > - Clean up the commit message. > - Add 'Fixes:' > > Changes in v3: > - Add support for highmem pages > > drivers/staging/android/ion/ion_cma_heap.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c > index 86196ffd2faf..fa3e4b7e0c9f 100644 > --- a/drivers/staging/android/ion/ion_cma_heap.c > +++ b/drivers/staging/android/ion/ion_cma_heap.c > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > > #include "ion.h" > > @@ -51,6 +52,22 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, > if (!pages) > return -ENOMEM; > > + if (PageHighMem(pages)) { > + unsigned long nr_clear_pages = nr_pages; > + struct page *page = pages; > + > + while (nr_clear_pages > 0) { > + void *vaddr = kmap_atomic(page); > + > + memset(vaddr, 0, PAGE_SIZE); > + kunmap_atomic(vaddr); > + page++; > + nr_clear_pages--; > + } > + } else { > + memset(page_address(pages), 0, size); > + } > + > table = kmalloc(sizeof(*table), GFP_KERNEL); > if (!table) > goto err; >