Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3953496yba; Wed, 17 Apr 2019 01:11:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGqIp0VV6hkfFuscO16kEfUp53adHgpKLkq+xEfUfRQMhlQuZMP17bPnBg7jzITYAtIx5N X-Received: by 2002:a62:1bc7:: with SMTP id b190mr89029172pfb.29.1555488660550; Wed, 17 Apr 2019 01:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555488660; cv=none; d=google.com; s=arc-20160816; b=QDrJ9bLcMzRJ/TaEpEShfqOnxWnl1Fm/dAeYi9r58x4JbN0BJoP7djCpjx+De7GwcF LhvMaJF5L3WS4TKzU1FRps95n98rYGuJfCiDGq/UtxxET2DSIzCh0PUozL8LfbqnWx08 418x3MegZ+a93eGQdSRxlUYUaPXE26jvwMDF0oOsSxSFVfaoeTi5kSGV8NiKFW1YRKV9 8SWQFSkmE5Ljj/KgeZx0lR/9/bD+zRXje94vk6NHFoIkPOHr2FgFaTXrZrQwftGstFli wNYUWk7w0+udWxq8QCVkMaSFiDvrlp/CfsHc91MJD1ETMPIloeY+z4xMLfzoITL2hwCM y5cQ== 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=SYuZrgQB7tJG7K7f5LjyBEKaXZO/UGBfG4FuxsfdE1o=; b=JZvbYwwEgIINKISVDOk6fjPBYOLVja3HJclUhFjPS+XVxmzcccaIM9tIvmKKZ5kRQp /9Hzv78kVMBzyhz1vX8Ko1bGqcnUpVG4KNx0nDELWGsiZVP7e7YIESnSQU0/cBub18Ba 1fKqND0bGSbre/DOzXvBm4V9XQ5/5geDghjEqqhQK5Cfa2Br/LvHIyj6MFdrGzjfOVXH CB162086zGay2Y74siiUnDvJ5L2xxBpDkzY3a8FoiQfCdLtoHlxtyx7EFepjjKwODhae x/4jFAlYUd8sYvLrzSLtyTyh/juAfbosKAnDfIhW5OFZqSqOCtFvrrGB9LUi5WwPgeQj /URg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=jrHBLtqh; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l189si47068365pgd.291.2019.04.17.01.10.44; Wed, 17 Apr 2019 01:11:00 -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 (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=jrHBLtqh; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731268AbfDQIJx (ORCPT + 99 others); Wed, 17 Apr 2019 04:09:53 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:48958 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728143AbfDQIJu (ORCPT ); Wed, 17 Apr 2019 04:09:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: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=SYuZrgQB7tJG7K7f5LjyBEKaXZO/UGBfG4FuxsfdE1o=; b=jrHBLtqh/DMPI1om+61hhVpcB n8FRHS0icipmzIceW19zbPG8NLeJ2chHhS2LCguRJL2nKWwMTCs0dgqSEykSqcvTghjoc4G5iBsGB 7AtlZx0McyFUjB5I5IAIzwyh4ZWARQpVwiSIAOBVYRI2ShdM8YzrmcT249NhjvPNc8UXrIPFOn72H t9JE5CJDrBpI9ykx/cY4zLHxaJ4E7ErOMHV65gfGCjxb8BRmKhtza0QkFuWBtnFqENTkjeG5A1gA7 s2+SLKOR7iw8y3dR2q72GePIJKw2JaM2E/e+ZWCprYAKpqJai2dBLOUcCixRU/FCIODy9rzWXod5O ZBsX5BqxA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:52136) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hGfdG-0000L3-7q; Wed, 17 Apr 2019 09:09:26 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.89) (envelope-from ) id 1hGfd9-0000gr-CZ; Wed, 17 Apr 2019 09:09:19 +0100 Date: Wed, 17 Apr 2019 09:09:19 +0100 From: Russell King - ARM Linux admin To: Matthew Wilcox Cc: Kees Cook , Linux ARM , Herbert Xu , Rik van Riel , Linux Kernel Mailing List , Eric Biggers , Linux-MM , linux-security-module , Geert Uytterhoeven , linux-crypto , Laura Abbott , Dmitry Vyukov Subject: Re: [PATCH] crypto: testmgr - allocate buffers with __GFP_COMP Message-ID: <20190417080919.54wywpzrt3psn4vj@shell.armlinux.org.uk> References: <20190411192607.GD225654@gmail.com> <20190411192827.72551-1-ebiggers@kernel.org> <20190415022412.GA29714@bombadil.infradead.org> <20190415024615.f765e7oagw26ezam@gondor.apana.org.au> <20190416021852.GA18616@bombadil.infradead.org> <20190417040822.GB7751@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190417040822.GB7751@bombadil.infradead.org> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 16, 2019 at 09:08:22PM -0700, Matthew Wilcox wrote: > On Mon, Apr 15, 2019 at 10:14:51PM -0500, Kees Cook wrote: > > On Mon, Apr 15, 2019 at 9:18 PM Matthew Wilcox wrote: > > > 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. > > > > If GFP_COMP is _not_ the correct signal about adjacent pages being > > part of the same allocation, then I agree: we need to drop this check > > entirely from PAGESPAN. Is there anything else that indicates this > > property? (Or where might we be able to store that info?) > > As far as I know, the page allocator does not store size information > anywhere, unless you use GFP_COMP. That's why you have to pass > the 'order' to free_pages() and __free_pages(). It's also why > alloc_pages_exact() works (follow all the way into split_page()). > > > There are other pagespan checks, though, so those could stay. But I'd > > really love to gain page allocator allocation size checking ... > > I think that's a great idea, but I'm not sure how you'll be able to > do that. However, we have had code (maybe historically now) that has allocated a higher order page and then handed back pages that it doesn't need - for example, when the code requires multiple contiguous pages but does not require a power-of-2 size of contiguous pages. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up