Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp615586imm; Wed, 13 Jun 2018 05:54:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJRC6SGMMSBI2/Z0Na4xP416GRU013X0Oty38xLjowVKNBRB1CZ4RwNfBJYC3W2C4Qf61El X-Received: by 2002:a17:902:b40f:: with SMTP id x15-v6mr5162049plr.270.1528894453277; Wed, 13 Jun 2018 05:54:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528894453; cv=none; d=google.com; s=arc-20160816; b=PtEHsX1Xqb0Sdxl2D47Cwyvx3j1MWGJSxpCSaeX7sVAL10O5MCSVURkFsS6DeZZjN+ O+tSL4SbL8AOrNjESCi9dhdhJ/XnetJtOfaQXm4KuICCrAkE83dIVt2jwEis//syaDHx f/uXbM6oues+LrZ/mFuT5dnL72OLJOVkulOjLJ09oZ0mwCZ1NMsXRDP4Nmf144hlnj4Y 6N6BspsB6LlI7dV9P4zR1LpKXyKahHVq3dVFJK8fDtKSPdD+tOlRo8EypzIbPBVdVTWl tmvStHr8R1O2ns+Q2b+Fg67Nx5CPUHU5ZJK527iLn1s0srOH+IHYVlMBwmxmmPqjOyb1 Cp4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=D9rzPKRFtH/sZB2O9Arkk0qJAeA0idf9L92Jr8EZ8H0=; b=LNNQLOFola7eIXS7c9UsnPsrkMxPWP2njRBdaOp/P0PXIqxNyrdrXjx0DSKvlbW9pd ukZF/24qAU+NosFXyAVJF/mhfQPF/pY7rpvvGpelgHVT/o0+6pRZcRigJwBMUyHiIo2q 7p3PL+OPFp9/kJu/KBmnsaLqejxmAUkbbBn3jACMB7Tgq1j1PXPqHbJkl1LWmzWctYuU C4ikt9XT5U4HO0s4un5HhEyY85aootkojhcB4r8Wtc+fR9mHxazYezfp2+C2Us+n6JI5 thoImAYvs3zLTQbU4rzOVOPoWSFLiGbIjRBFKRQzPex6VbpUNdqeh3aEfwpPrSYdHt+l mM6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FJf9KBN8; 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 x2-v6si2588219pfn.315.2018.06.13.05.53.58; Wed, 13 Jun 2018 05:54:13 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FJf9KBN8; 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 S935477AbeFMMwp (ORCPT + 99 others); Wed, 13 Jun 2018 08:52:45 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:55132 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754495AbeFMMwo (ORCPT ); Wed, 13 Jun 2018 08:52:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=D9rzPKRFtH/sZB2O9Arkk0qJAeA0idf9L92Jr8EZ8H0=; b=FJf9KBN8vIXN+eqbQdC487UIZ tHshKuSD7wuCn6HE3wvQ4bSCewy0dxLy5i642YWsKBmGK7o66y7BjgOsTo3fsYWEkbm+/vFrRqaTY T5aBQSblGAoeJYotab2dsDNaEjEfmsMoqmlRU+h7R7Zv0cVTIO+znHfXJQULsABQrju10Wq/hVw90 vvyxteB+NivlFHEUtoKKlkp9AklBuQ5m9ZrDphlv0JGShq2yIKWzWZsAdI1ZIBpqDzpXxKjhAJ9Gy dIq1CVqPbb7Q1kAQ6ELSFea1jpxmQhdmkl2VfMrXKsnR82XLuscxzU3lwFpQjIqxPY+XTgKmWQpC5 90zl2WIXQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fT5GU-0006Pt-If; Wed, 13 Jun 2018 12:52:42 +0000 Date: Wed, 13 Jun 2018 05:52:42 -0700 From: Christoph Hellwig To: Marek Szyprowski Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Andrew Morton , Michal Nazarewicz , Joonsoo Kim , Vlastimil Babka Subject: Re: [PATCH] mm: cma: honor __GFP_ZERO flag in cma_alloc() Message-ID: <20180613125242.GA32016@infradead.org> References: <20180613085851eucas1p20337d050face8ff8ea87674e16a9ccd2~3rI_9nj8b0455904559eucas1p2C@eucas1p2.samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180613085851eucas1p20337d050face8ff8ea87674e16a9ccd2~3rI_9nj8b0455904559eucas1p2C@eucas1p2.samsung.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 13, 2018 at 10:58:37AM +0200, Marek Szyprowski wrote: > cma_alloc() function has gfp mask parameter, so users expect that it > honors typical memory allocation related flags. The most imporant from > the security point of view is handling of __GFP_ZERO flag, because memory > allocated by this function usually can be directly remapped to userspace > by device drivers as a part of multimedia processing and ignoring this > flag might lead to leaking some kernel structures to userspace. > Some callers of this function (for example arm64 dma-iommu glue code) > already assumed that the allocated buffers are cleared when this flag > is set. To avoid such issues, add simple code for clearing newly > allocated buffer when __GFP_ZERO flag is set. Callers will be then > updated to skip implicit clearing or adjust passed gfp flags. dma mapping implementations need to zero all memory returned anyway (even if a few implementation don't do that yet). I'd rather keep the zeroing in the common callers.