From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161576AbdAHJpV (ORCPT ); Sun, 8 Jan 2017 04:45:21 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:52684 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032883AbdAHJoc (ORCPT ); Sun, 8 Jan 2017 04:44:32 -0500 Date: Sun, 8 Jan 2017 01:44:25 -0800 From: Christoph Hellwig To: Kees Cook Cc: Christoph Hellwig , Dave Jones , Linux Kernel Subject: Re: sg_io HARDENED_USERCOPY_PAGESPAN trace Message-ID: <20170108094425.GB17725@infradead.org> References: <20161228214016.leperioiukslpho4@codemonkey.org.uk> <20161229075642.GA30837@infradead.org> <20161229154351.6zrxuagi62pga6mt@codemonkey.org.uk> <20161230133712.GA27511@infradead.org> <20161230150139.ulljsnnqntzku7tq@codemonkey.org.uk> <20161230151049.GA20387@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 03, 2017 at 01:48:03PM -0800, Kees Cook wrote: > There are a lot of cases of "missing" __GFP_COMP, which is why > HARDENED_USERCOPY_PAGESPAN defaults to "n". > > > If this is on a devie using blk-mq the block core will use high > > order allocations (as high as possible) to allocate the requests > > for each queue, so struct request could very well span multiple > > pages. But I don't see what __GFP_COMP would have to do with > > user copy annoations. As all requests for a queue are freed > > togeth again there is no point in setting __GFP_COMP for the > > request allocations. > > Does it hurt anything to mark these pages as allocated "together" via > __GFP_COMP? It don't think it would hurt the block code - it only allocates the pages once, and frees them once. But I think hijacking your feature on top of a totally unrelated flag is a horrible idea. __GFP_COMP is about refcounting the allocation, not about anything else. The prime use case of high order allocations is to use them as a single memory object, which might include user copies. So as-is I think HARDENED_USERCOPY_PAGESPAN is a misfeature, it needs to be opt-in for allocations where we might not copy over the span of pages, not opt-out. And I suspect there aren't going to be all that many opt-out candidates. > > -Kees > > -- > Kees Cook > Nexus Security ---end quoted text---