Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3815542yba; Tue, 16 Apr 2019 21:11:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWKT1x4ShZ8DiEDA2OOUkvZ1Un541kECcPidiXg1mSdDF54JzDnrbsp+seeorkUHgYs0R4 X-Received: by 2002:a17:902:4827:: with SMTP id s36mr86851886pld.296.1555474276101; Tue, 16 Apr 2019 21:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555474276; cv=none; d=google.com; s=arc-20160816; b=kVG8tZcmlKzqBApXLprN19bkZm7BmEUAUuqhctFawxI04h/VgTFAmOBUPr/0s4TTnW IeDWvmMyvt9XmHn4Xw+xNQjNBXEcPplaLzgelFkyaXP861yPtY0JyNxGIkRwDqfbir0m gk6JOJQ+qswFOwSzEeE21hA552WDp25LDEIeGdEIhQg2Aa7hz3TMiBU0s2nWChn85oHf FbiydKnQYocgB3YsuHWxa3je8XsOfWbGR1cgtXcTHwgQY9042MU+uKitLI0q1NUsTjPw TK18RgP2w+YSsI7lNOxzgwQVLyU5W9Bf9wBESnfIBwpF1bCheC9+L+OuAP5PXAF7hOX3 72aA== 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=Em4HpOp3QfI9scdNSfMBzQDhJV4iaM3Bd30fC2vkXHU=; b=FdH8IExVV7uqG15FqS9IN1+lM18eZ5J8/w/AYmBtCLqN7+irFzIcnFP/7IlOqWX+ez 6k43ID/zDgT9asSpuCFwoXXqoXYVGjOqyp//1wK3b+0/vDPw2Y1pdiwA2XxKwU6qoMJD nYSGe+EWwlwILcR5peFnOLMtNF81VGVbG+ykbtkNRSkaq7DNpUXfWQ+LzT1SZ2ioskHK dcUTta9so8v1kKOAFHJJQ2fSL+ORtfewYqykVZjBgDgAh8MJKeto01Sw98gL336TKQ4f Wkx1EYtKCWOp7Ab0jEo91t/+rVLltq10a8b+ZQ2oo2f3qu+Ut6r/XU37pH5d6bBoWF1Z DVlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=CON7p5qb; 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 k6si31171406pfc.122.2019.04.16.21.11.00; Tue, 16 Apr 2019 21:11:16 -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=CON7p5qb; 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 S1726434AbfDQEIa (ORCPT + 99 others); Wed, 17 Apr 2019 00:08:30 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37466 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725320AbfDQEIa (ORCPT ); Wed, 17 Apr 2019 00:08:30 -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=Em4HpOp3QfI9scdNSfMBzQDhJV4iaM3Bd30fC2vkXHU=; b=CON7p5qb8+GWuIuaXABny5e1b 78XtNR3iadVEg2rNXkBrCWv715s3AtTYJMLTdNT0QCRRdQ9fJWPSUQukE+LPNMhSr/fd10/w9l/Hv Wz0AxaKBh/AeKrFFkj2x+XQBZjkfhjM5PcwIXKXslLN6KOny76URhvSqY42AecAmCwEZLapoJKSgv sQQ45ZOYF0EGWTc/Ld4hZS8RUtZF2g6iRfTWKYYjcDEpKnjk8HRF+FkF9VvkYRZtxqji86Hy8FSOT VDOBV85w1wdqy2/Y2Sw9nkmwjNCMyg4hUXDTwK39ZKai6BMQFvhoilI0BHoa+dcfib0I2PptYbriB QVwqb5ZiQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGbry-0002lh-TV; Wed, 17 Apr 2019 04:08:22 +0000 Date: Tue, 16 Apr 2019 21:08:22 -0700 From: Matthew Wilcox To: Kees Cook Cc: Herbert Xu , Eric Biggers , Rik van Riel , linux-crypto , Dmitry Vyukov , Geert Uytterhoeven , linux-security-module , Linux ARM , Linux Kernel Mailing List , Laura Abbott , Linux-MM Subject: Re: [PATCH] crypto: testmgr - allocate buffers with __GFP_COMP Message-ID: <20190417040822.GB7751@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> <20190416021852.GA18616@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: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.