Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2744613yba; Mon, 15 Apr 2019 19:20:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/9ONWVFygvZ3pF/pgvKeIQGIXFYtwhSrc1JXXVbsJO2/APpp90Zp2uBxckCjuomFASSDZ X-Received: by 2002:a62:4115:: with SMTP id o21mr78961238pfa.153.1555381224727; Mon, 15 Apr 2019 19:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555381224; cv=none; d=google.com; s=arc-20160816; b=EA5vMJsiscRoDHE55xT4qWGc/7a9znkag5jOrHf6qU1p1jp0v2PzTyFT+ty+BU2k/1 9cgPIugL1x5thhJ9ZT2miKMo04C7tEe7szqhiaDDFdFeySn45MQ17y1R/DvbMMTSiYME 1DtbwUgS76cgulXv/N49/EnVwnQUI90pUe6lxXEmSmc3XrTb1zbHEtSWw6RnyVRZxI+6 uB33ou5SKI35HxyOgVQ4UFPp8MCI889HJrFUD2F99il+6KRNh2oQTZuUJvg4dUV4O3oi Cknw8/5aCat0ouD7RS3wIR6Z3ToEJViDWBMIptCy40ThzhsIeoyjDGainIIy+IQCy9B/ cN6A== 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; bh=UCqn4xJsfn6LSF38geTP0GiT3GQOfaOQ+QhzCgzo1co=; b=YiLGEfqF5B1DBx5dwmBA1dHTC8oGlbHdwfPNAYF8wvxq9E6MDBtoBNfYqeQVpGeItU QQs8PgZMaX1UaIzBd80iTxQFR2pmGOpWDPz+M11LZ9ahstFBqpzz5hnE3bAdA9N92RjN Lr1lKE2EQo8TFRRAr34iG2TWmBu5CA/CbNr5I2o0EyM/q94qR3d11ipYb5fI45WLejML K0VkE582Jw7EJd2YezEaREk6lYxpnGramrLNFYGpUELcF5fXt3y5Fp+64ZUAOgV1kgSz ehfRwzdUNwRQQXXI9k+1B9BT9jhS1of3zvDzPgnJ8pWkH5xVq13i98Akd6fdsUjLPjFR uDJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=egV7tTkp; 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 f10si44746542pgv.589.2019.04.15.19.19.56; Mon, 15 Apr 2019 19:20:24 -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=egV7tTkp; 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 S1726054AbfDPCS6 (ORCPT + 99 others); Mon, 15 Apr 2019 22:18:58 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:40842 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbfDPCS5 (ORCPT ); Mon, 15 Apr 2019 22:18:57 -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=UCqn4xJsfn6LSF38geTP0GiT3GQOfaOQ+QhzCgzo1co=; b=egV7tTkpiN9UWTV3PXo4mGfLW tbeL71ZPBs4HFrlSAHPfvTx5o1bsD58ovucaD2v+AGmrP7XvuU7izDvOhAY3sqSPXU42U8Gb3pycu wXJ3K6Vbk/xXJ/HQYyn/Gwpw5kM8HAqi3pC7vlMBhzuPKGe5T9e9FP5ZkfxJ25pivvxM5iwZqz9jd ZHZ6gy1YHEIcLju7XgZkwVQMjQCOOBqM9z3F+MXW/gnUI1bRcGIBJr83/OlHMDhbi4wTOaFHLYIRc meSEFn5Bbi+peV/JaPozGSUudMpsq8SkY17MhfLYr+A6jeSyE/r2AzgFz9MxL4aYdkeFilGuP/jN3 YBRDv9a/A==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGDgS-0004Ef-Gw; Tue, 16 Apr 2019 02:18:52 +0000 Date: Mon, 15 Apr 2019 19:18:52 -0700 From: Matthew Wilcox To: Herbert Xu Cc: Kees Cook , Eric Biggers , Rik van Riel , linux-crypto , Dmitry Vyukov , Geert Uytterhoeven , linux-security-module , Linux ARM , Linux Kernel Mailing List , Laura Abbott , linux-mm@kvack.org Subject: Re: [PATCH] crypto: testmgr - allocate buffers with __GFP_COMP Message-ID: <20190416021852.GA18616@bombadil.infradead.org> References: <20190411192607.GD225654@gmail.com> <20190411192827.72551-1-ebiggers@kernel.org> <20190415022412.GA29714@bombadil.infradead.org> <20190415024615.f765e7oagw26ezam@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190415024615.f765e7oagw26ezam@gondor.apana.org.au> 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 Mon, Apr 15, 2019 at 10:46:15AM +0800, Herbert Xu wrote: > On Sun, Apr 14, 2019 at 07:24:12PM -0700, Matthew Wilcox wrote: > > On Thu, Apr 11, 2019 at 01:32:32PM -0700, Kees Cook wrote: > > > > @@ -156,7 +156,8 @@ static int __testmgr_alloc_buf(char *buf[XBUFSIZE], int order) > > > > int i; > > > > > > > > for (i = 0; i < XBUFSIZE; i++) { > > > > - buf[i] = (char *)__get_free_pages(GFP_KERNEL, order); > > > > + buf[i] = (char *)__get_free_pages(GFP_KERNEL | __GFP_COMP, > > > > + order); > > > > > > Is there a reason __GFP_COMP isn't automatically included in all page > > > allocations? (Or rather, it seems like the exception is when things > > > should NOT be considered part of the same allocation, so something > > > like __GFP_SINGLE should exist?.) > > > > The question is not whether or not things should be considered part of the > > same allocation. The question is whether the allocation is of a compound > > page or of N consecutive pages. Now you're asking what the difference is, > > and it's whether you need to be able to be able to call compound_head(), > > compound_order(), PageTail() or use a compound_dtor. If you don't, then > > you can save some time at allocation & free by not specifying __GFP_COMP. > > Thanks for clarifying Matthew. > > Eric, this means that we should not use __GFP_COMP here just to > silent what is clearly a broken warning. I agree; if the crypto code is never going to try to go from the address of a byte in the allocation back to the head page, then there's no need to specify GFP_COMP. But that leaves us in the awkward situation where HARDENED_USERCOPY_PAGESPAN does need to be able to figure out whether 'ptr + n - 1' lies within the same allocation as ptr. Without using a compound page, there's no indication in the VM structures that these two pages were allocated as part of the same allocation. We could force all multi-page allocations to be compound pages if HARDENED_USERCOPY_PAGESPAN is enabled, but I worry that could break something. We could make it catch fewer problems by succeeding if the page is not compound. I don't know, these all seem like bad choices to me.