Received: by 10.213.65.68 with SMTP id h4csp873932imn; Tue, 27 Mar 2018 10:21:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx48AuL9e5huEbr9PxQPhDpq9YFWOCuS4wjznZn0MQOw9yBga+LheRJky/YrLRgJXb5ErkJr5 X-Received: by 10.99.104.131 with SMTP id d125mr127661pgc.9.1522171271194; Tue, 27 Mar 2018 10:21:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522171271; cv=none; d=google.com; s=arc-20160816; b=b9b/2GuX93CAJUA96bhaReVDwcMAUVAe8TIwvwAzuzqEeHbX/3oyWXSLkFf4TniKpu F3F+WVZu4bmz+FgaaPKasPkFK+EuzmssoOA5hL8Ve2DPdHgtKRkjUi1KAReiigN74KzY v49H9K9bALg/fYBgKrza4c7QQT9gbl4q+Ngqy46AUaPkQU/4w+3B2dEec28ChzF/cixl 8PafnA7M+42qQ45wv+Q8oZPXpriBvjIffABn38blBKE4rtDZQcZHc9+cpjwc69d3ZUi2 gQfYvNbhwtU1XkTYnR++sVrB9Tr4yEDRfzIvS0Urtq6qd3WBl5PJZ2++K86dtwGwdxK9 bxjQ== 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:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=pgSadQ/hRtksvrijG02qdab08/M+vcuAfZRMEmP0E1U=; b=s/aazWNo0YzbjRUKaKhReMUYOs9B41r88w7vriw1pbCD9+sgGx442xnfrWgsXIN8s7 uskoe5NL4R7L0xqqEuBJuHaw9OVF8Eh2xbkB80/Iqv3/u2JLIRdMaCZaRcYdw30vOXgn o5s5nsgO2mhSt4Na2V8itesY/kzadNTPAOwOIAh7c4vxGoYQeds7SsQe69hi1qapUEIK yYlVHundIH3C/d9S3aqEz3i2g1cwOKKjagNzhZ+kxEZpNTgJTNsMMj+reA4mog8yxfGV ebXYj4W1aOawelQLHjd/bf7uwGKwk/wHiFpnL/5NHvHDydvYzC8X+2POvKpcC79bkgSW gQfQ== 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 85si1223198pfz.271.2018.03.27.10.20.56; Tue, 27 Mar 2018 10:21:11 -0700 (PDT) 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 S1755122AbeC0QiG (ORCPT + 99 others); Tue, 27 Mar 2018 12:38:06 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46586 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755089AbeC0QiC (ORCPT ); Tue, 27 Mar 2018 12:38:02 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A84F5FCA; Tue, 27 Mar 2018 16:38:01 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liam Mark , Laura Abbott Subject: [PATCH 4.14 094/101] staging: android: ion: Zero CMA allocated memory Date: Tue, 27 Mar 2018 18:28:06 +0200 Message-Id: <20180327162755.773175076@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162749.993880276@linuxfoundation.org> References: <20180327162749.993880276@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Liam Mark commit 6d79bd5bb6c79a9dba4842040c9adf39e7806330 upstream. 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 Acked-by: Laura Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_cma_heap.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) --- 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_h 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;