Received: by 10.223.176.46 with SMTP id f43csp978692wra; Fri, 26 Jan 2018 09:49:28 -0800 (PST) X-Google-Smtp-Source: AH8x226v2GJtI6Y4lg8tkbdmzZ77jFfJWcc+Oteo1XiEoNEUwha3A7XytsDHxbp4DafUz1w4FBS8 X-Received: by 10.99.163.84 with SMTP id v20mr5366951pgn.399.1516988968246; Fri, 26 Jan 2018 09:49:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516988968; cv=none; d=google.com; s=arc-20160816; b=ORHhEBjwX30avVs6bP96rT/WhBAZ+BUO6jq40909t5dy4OjeYWmYA8UJtwMYkbPCHn WCTFNz8/yUDsJZWUAdPovHoAFwEbvX0FcSgVr5Ru5jZADS943XVIlH0qjkM5bK40kY/R CIz1JoljjeUzwvox/UXBYL9dmELlw/NiRzBP/ojRlFCyP2A0udtIzXbfrrZhDtXafNSb 1zQuWGo0foxbpqcMh0vZEYCU1Mtx/ZA3yi2u0moWJRHkctDqksThb9HqwA7rvhxKeTzs SyiqIGD2Don1DcQ+plyPnsrs+4ZoEbqPU2sk3sZzbS434AQROU3nco7flENCLRGeqYK+ IyvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=iPEQpXVgi9yghgY0AMcCxxw3yzOS/d6loQZk+wFkBGE=; b=P4qoOpfJ2ATt3NrkVqlC8nR9aObP2Ww06rzoMlKN1SHg5tsCR1Xo8xymvor51bljI5 QU6UIyMMqSlT6Ttw20obh+QzTS+x8cwijILHcDiqXKvxOZSAKv8M/U+oiEpXBqdN5N7N 8yM27oL9DeLsvecgTXG3mfZhNtcVEMMdWG5cpFkxeji3DzzW4VLdZ6XDlEwA33b7FFuf +0uPmONo64eyKOQU82XL09YetnJ/oywb8igF9HgkJNCicN/KqBfAlXPtb8LIuwP1DYna lhujyDZeatB36nc+96B9uGWUotHdYxUjLtB45QXoC1vu8s3QReCD0Esry7hLGMGeRb/E F7Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=kh9DdwoF; dkim=pass header.i=@codeaurora.org header.s=default header.b=kh9DdwoF; 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 b17si6613016pfd.406.2018.01.26.09.49.14; Fri, 26 Jan 2018 09:49:28 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=kh9DdwoF; dkim=pass header.i=@codeaurora.org header.s=default header.b=kh9DdwoF; 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 S1752029AbeAZRsV (ORCPT + 99 others); Fri, 26 Jan 2018 12:48:21 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:44898 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751588AbeAZRsU (ORCPT ); Fri, 26 Jan 2018 12:48:20 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id ED035608CB; Fri, 26 Jan 2018 17:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516988899; bh=lBeEDcRc4yL5MPYpOv684iD11/TjyFPwMH0VYGpdq5A=; h=Date:From:To:cc:Subject:From; b=kh9DdwoFE3CqOm6AluqtrN92MeBSGQfjHotitqXmICygRBtLOB4cIPlscY9qSOV4Y ArfGHGA7KYf49LES0AGpWiAgEIpaDCiy4IB+xIkhgtihBuTuPoxH3OGJQyT3RS234r 2AOcEpu6DI4b/oscR09+pCUJ3tfpgeDgw+U+1lwo= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from lmark-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lmark@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2889160452; Fri, 26 Jan 2018 17:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516988899; bh=lBeEDcRc4yL5MPYpOv684iD11/TjyFPwMH0VYGpdq5A=; h=Date:From:To:cc:Subject:From; b=kh9DdwoFE3CqOm6AluqtrN92MeBSGQfjHotitqXmICygRBtLOB4cIPlscY9qSOV4Y ArfGHGA7KYf49LES0AGpWiAgEIpaDCiy4IB+xIkhgtihBuTuPoxH3OGJQyT3RS234r 2AOcEpu6DI4b/oscR09+pCUJ3tfpgeDgw+U+1lwo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2889160452 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=lmark@codeaurora.org Date: Fri, 26 Jan 2018 09:48:18 -0800 (PST) From: Liam Mark X-X-Sender: lmark@lmark-linux.qualcomm.com To: Laura Abbott , Sumit Semwal cc: Dan Carpenter , Greg KH , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH v3] staging: android: ion: Zero CMA allocated memory Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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:' 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; -- 1.8.5.2 Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project