Received: by 10.223.176.46 with SMTP id f43csp553289wra; Wed, 24 Jan 2018 02:20:10 -0800 (PST) X-Google-Smtp-Source: AH8x2275X40fp6Ep43cxbBCLgmLSHbxsVmvWYnD6TMIiB4unMu4j1Nxl2BxbQtXfLlGRL/hI+caf X-Received: by 10.101.100.132 with SMTP id e4mr8589549pgv.398.1516789210054; Wed, 24 Jan 2018 02:20:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516789210; cv=none; d=google.com; s=arc-20160816; b=b7sbFzFDuZBdYrtLnDdUBPkheLO9KmP5v9teY7Vcqpx6G5bIs8Fm3MNtieKNIkqH3U KDf0Dcu1q7t9rZNmFc4n75Sao5bO4coq6hpQXls1LgKZELXUU6P19OYHfHNqzeM3wbc6 MwdUqO8kfIdkJRyLR1D8kSCfHcXsoW5h9X1nuZtTLf1W24LsnEQwNdW+g4a8AUPk64Y8 XkOqjZFA6sdj/ih9mJ4Hcfe2NNRrI/R949X8U1osXNFZqUkcMpnMMYFptUCYjfitLLPc G9YMX/+vDKcZ4RPnO/GfWfD+AdE3zBN+d2ToflLXSNzXdgOmZLKh65QHk3PdUCKW53S4 izbQ== 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=Ac9hk/OHR4Spy5H8Wa6TFUsj0R0pdjq2C9uO/q5/+J8=; b=SG/uBGEQtHNQY0lvarEmL0hefsS4+Nfcp2AQcTeIBtXwB1S3gbnVz/VP4EF/oSZSbW WHF7ip10etsDbKRpAliwR7XIVI9AlVuwXXl5ItbJsQNRBFNMlIUvwcBFgXrJJr8teYCR H/EFhTKXYvFLQF5n5dIKJhBZADSp8gkK6Qj8CBI+OOjsgQ8Z+pA2xP61Idc1RlYE9BC6 X+KR5bx1oBIuIP1ruLew22CHSZVha9k2lic3V5Uc5I7yMnxislSjeiQtSDHkiuYRC39w ZqOZI4Mf6rRoE7tXa2qLMBQ9dzdULQ+N35uLlEPDBkGsI+NJs/hLgauRyz9p1b2rZ16U SOBw== 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 n16si15815374pgc.589.2018.01.24.02.19.55; Wed, 24 Jan 2018 02:20:10 -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 S932941AbeAXKTb (ORCPT + 99 others); Wed, 24 Jan 2018 05:19:31 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38523 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932634AbeAXKTa (ORCPT ); Wed, 24 Jan 2018 05:19:30 -0500 Received: by mail-wm0-f66.google.com with SMTP id 141so7429247wme.3 for ; Wed, 24 Jan 2018 02:19:29 -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=Ac9hk/OHR4Spy5H8Wa6TFUsj0R0pdjq2C9uO/q5/+J8=; b=ZyzO2s3v3EHhHoSMiSR/ZgE4Ivqf5oxlilwY0QCJKjqyK4xekFMsJS1964m+NzS6Su Q1CA2nJhUnrgnPkdIG/duVBOaWIV+bT7OODcC+kfsWJUAbLO2oJ02OYToDese9kbLlnp NDls/3VwgebK71n03Z7OqH9RMXWC8PFF/B1kIj8pv5JBn0Z3cB5Xw8UZQcBqnG8l6T1K 7/5ORAfctSgmlnamXqSqq06oerRzJx2/6fuJMCtIP1KCwL4BQGPb9EWfO4Q9X/TR/QMD vUh2iOXf66aEQsmSyMBE6xMs2uEXnvUFfQ79z0DkRHRaawvz27ya0Zsjxjo3F/MGRWmT 1JVg== X-Gm-Message-State: AKwxytcct+5VkDqPIWMqoCZaMtUMXTjK2SSXvbJ2jhMipHvE2co2WsZW qXCFaJZpua7bnjVV6ciKENQyAQ== X-Received: by 10.80.244.23 with SMTP id r23mr22980588edm.2.1516789169011; Wed, 24 Jan 2018 02:19:29 -0800 (PST) Received: from localhost.localdomain ([213.175.37.12]) by smtp.gmail.com with ESMTPSA id k12sm13319797edl.86.2018.01.24.02.19.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jan 2018 02:19:27 -0800 (PST) Subject: Re: [PATCH v2] staging: android: ion: Zero CMA allocated memory To: Liam Mark , Sumit Semwal Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, Dan Carpenter , Greg KH , linaro-mm-sig@lists.linaro.org References: From: Laura Abbott Message-ID: Date: Wed, 24 Jan 2018 02:19:27 -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/22/2018 09:46 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. > > Fixes: 204f672255c2 ("staging: android: ion: Use CMA APIs directly") > Signed-off-by: Liam Mark > --- > Changes in v2: > - Clean up the commit message. > - Add 'Fixes:' > > drivers/staging/android/ion/ion_cma_heap.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c > index 86196ffd2faf..91a98785607a 100644 > --- a/drivers/staging/android/ion/ion_cma_heap.c > +++ b/drivers/staging/android/ion/ion_cma_heap.c > @@ -51,6 +51,8 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, > if (!pages) > return -ENOMEM; > > + memset(page_address(pages), 0, size); > + This won't work for highmem pages. You need to zero by page via kmap_atomic in that case. You can use PageHighMem to separate the paths. Thanks, Laura > table = kmalloc(sizeof(*table), GFP_KERNEL); > if (!table) > goto err; >