Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp582929imm; Wed, 13 Jun 2018 05:24:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL4NSNNV+TqIQdeURldCnXJhV9xUqHEUVQfhkShGF7YONWpt3xXX5Na3i3OfvNSPDY1Glk9 X-Received: by 2002:a65:4b82:: with SMTP id t2-v6mr3833050pgq.175.1528892684872; Wed, 13 Jun 2018 05:24:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528892684; cv=none; d=google.com; s=arc-20160816; b=aRiVkRVUFW7ADBQ1j0Evkp1yGQknKgIRyYdWLzwzR8GwonUdglG/wJCPljMXCFN91a 6YxbAJETnD5rXPjYNGda/VQGQieToUp9E1QsbQ/utJxLozijVMjq0rMvR0+O4r9+2XCo LRT4sX0AzmisRSMs3LERYWn57AVcmvQw+OGpwEkb8KKZR2GLjQCaUdA4KgXq0vWQ6rs5 Iq3+s74zEU/dgTVVvTRR3hiMHPu3GBc2aCxCbrfuq/kRVpei+CXdOg17QQTt6+fMEKUE A0XMoCkd4PCv+7JnLZzTY5J0en59BzYA/2FKGchmfhMLQkTYSmiOIR1TIxtIne8sKqoQ fbrQ== 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=fJihSswcbsj16ee6bnFV5DWujsO+wz/juQ1eNFJA2h0=; b=bVjy1piPB1K50JLUVR6wxpinQoaYqLqtNkthR4ywpRWhA68aHzUdR3YzwXqniRQuHm n44QCX3A4TgIsNUi6GsWAC78ZI2y7/3176V2113xp6fnvgN0iaCfzGsaBzeP1955EAod 4qg9NOdG8zWPLaxVoWRSOX6EQIlWRP6BX78A0Y2PzJ7+mkVQ5mhWne9AD4pii3Zmdl0R L03tERrdhlD6KSiN27cWBa5Rz89BQNlZ92JsmodamoMUn4nJZR2vZAuBxGQ/coGL64dA BtXGNf84ujp/hvoPpiBzb5sQYnkaLNlM5ttpI2agIleBvzHYNh8ISCnGXdNsgyLmjzDA YL4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=TjkFEIUK; 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 f11-v6si2287557pga.463.2018.06.13.05.24.30; Wed, 13 Jun 2018 05:24:44 -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=TjkFEIUK; 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 S935419AbeFMMYH (ORCPT + 99 others); Wed, 13 Jun 2018 08:24:07 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:34500 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935274AbeFMMYG (ORCPT ); Wed, 13 Jun 2018 08:24:06 -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=fJihSswcbsj16ee6bnFV5DWujsO+wz/juQ1eNFJA2h0=; b=TjkFEIUKawi17brJcEkYsPnoz FjbZ7hjuuebogRXvnr0c9+b2zLlFiyT3nuCmP73Ai5LhkzlD1FVC5nEtUc49YWz96ah8bLpI3C6LD XginU7vMvPBYXfnP+3T+Pc0Bx0XDVSWVesgGCIMwUegu+jM/ZDY9ylWdOXqUi3krsDbl/g3vWj1t3 bpP3wDAFvTuKJ2GBwUjQ6zD4l9rdicIJuATFP7RQBZVvnb9UAgkBppNzzNIwlKWBaK20qU03UImyk g0ydKZgzFNMdS3bGtHu5J2beSrZclGL4qHwNVsJU+AZXhPlLLn7pbQ7UXg3ITNM6zaefjVCupmPwp 3Lpm7M8gQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fT4oj-0005Lv-64; Wed, 13 Jun 2018 12:24:01 +0000 Date: Wed, 13 Jun 2018 05:24:01 -0700 From: Matthew Wilcox 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: <20180613122359.GA8695@bombadil.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) 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. I think the documentation for this function needs improving. For example, GFP_ATOMIC does not work (it takes a mutex lock, so it can sleep). At the very least, the kernel-doc needs: * Context: Process context (may sleep even if GFP flags indicate otherwise). Unless someone wants to rework this allocator to use spinlocks instead of mutexes ...