Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2103346ybl; Thu, 30 Jan 2020 11:24:47 -0800 (PST) X-Google-Smtp-Source: APXvYqy2cS8oW9pZTe8oPoXUyghrhydsh9/ixXF2ZF2RO3kxxKfRanYA4a8AyhcswUNvoZHzzWXg X-Received: by 2002:a9d:6290:: with SMTP id x16mr4661474otk.343.1580412287720; Thu, 30 Jan 2020 11:24:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580412287; cv=none; d=google.com; s=arc-20160816; b=tsCJMPLGqX/5aO0aGKeClZtG6RlQ2AbK2qzoGcXYMyuT+sGIW8VqXhXacqSsY0nLYY 293CItxl1VYSIFbgO6PK5+Ng8OdrqWi6lxcZFAD7t/+9x+POA7ICaLWENCHsevHZOmkb OozKbBSL6J671XMJQ7MvUn1sMrSv8d7wxVTMOhh+9cmaf8djeV4v+OAE6VLDF0T4u9N4 bVKkysiDzDje6VuaBHhx+9AVgcKwtNsovr+fD5VgCPdDSuahWiG236WRm54Vz1fQVaD4 t1ouC66FFOp7iht+Fhk5HaRF5CgmK6NLL9vkMavUN0Q9n/6X8Ihp/Ed7ikQx0/nZNAZh pd0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=STfgILZYJSeHL29PKr26PXRGNaaOXbLTCRy3jhx8noU=; b=N8eknTImOC/W0PTl63TJomUThZZ6v0onksFzFdD5rMAfA9xg8UIhEM/oLtgiD4rvEN RMzyJ8vAhFTuCkSGfYftjNBfssh+WOOPzhQGBWTJ4mMCwYnHJC6yC+7SlTDoeMuqwVXh mhVxLL5KZdoi0Nw6uAljsgqppFsQT3qzygVnDj6POAa7OM6yC8zxvWeGX619DUh8t9+o oMyHqzs3JFqnn4Ns409pA0514pgWq+q5V5k42UcC8TWehE8wYUQZLXtt/4H78PI0Jpyt XiuoErSbVN2xtWPBAFgeL/JHGst+lcVeafpBIybnUzeA2Zf2nHnNPs6LrwGh5hD+dsRS uvRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jqYeVsah; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si3567648ota.322.2020.01.30.11.24.36; Thu, 30 Jan 2020 11:24:47 -0800 (PST) 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=pass header.i=@chromium.org header.s=google header.b=jqYeVsah; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727546AbgA3TXm (ORCPT + 99 others); Thu, 30 Jan 2020 14:23:42 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:53994 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727438AbgA3TXl (ORCPT ); Thu, 30 Jan 2020 14:23:41 -0500 Received: by mail-pj1-f66.google.com with SMTP id n96so1760761pjc.3 for ; Thu, 30 Jan 2020 11:23:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=STfgILZYJSeHL29PKr26PXRGNaaOXbLTCRy3jhx8noU=; b=jqYeVsahhF99yBrSGAvuHdMSc2W97p/s3hZt9gt9YFSuOjK3g3byaqJC2nQE+QDIfI Z8NqxNikaMbSwQW2aQmx4Z02ThbSexr8D1XYxdrnXThBpe0rcHGSppH4YG+Li4+wqP63 2itQvwz4W2zBZh2IImAm5jdwB75aiWKl25l50= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=STfgILZYJSeHL29PKr26PXRGNaaOXbLTCRy3jhx8noU=; b=Hr54Ox1ZPJbRGp+1glA5oSSlyGZMI6yBWigfDlFiyaiTLlAJg4JSzGC83HkLIZCgQk lq4I8XpaI0SdHXBXvpHSc03ib44WbDDJL8WYgSD3tZ8A3GLrOe9Lm9zwIt1v8VqLHXd1 UY0ICL3GunatMnikqlEE+hhxFdrMlv+/wdvNVR/wGuL64EcIplxPkxZh7KrIz0RxpZJs C2FLJYk0CCwTpByScmDTKwDVnrweQCV0OsjRadj1hUQW0kaRUst2hBoh9AdsMq7tz2m+ zVBpTGxNNgC5nXemuWNgkebFJLo5vqfYHg3fGjqTNQIKPAHZx0rI1f+Dfnu5py0Lnrcd O8OQ== X-Gm-Message-State: APjAAAWBvs9H5+ScpPmeINMePXOZb+fB3b3nAN4OAcPTg08giypuruzP hjegSGVIRk2iG2CxyviTT7yL5w== X-Received: by 2002:a17:90a:7784:: with SMTP id v4mr7802031pjk.134.1580412220763; Thu, 30 Jan 2020 11:23:40 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id b185sm7608776pfa.102.2020.01.30.11.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 11:23:39 -0800 (PST) Date: Thu, 30 Jan 2020 11:23:38 -0800 From: Kees Cook To: Christian Borntraeger Cc: Christoph Hellwig , Christopher Lameter , Jiri Slaby , Julian Wiedmann , Ursula Braun , Alexander Viro , linux-kernel@vger.kernel.org, David Windsor , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , linux-mm@kvack.org, linux-xfs@vger.kernel.org, Linus Torvalds , Andy Lutomirski , "David S. Miller" , Laura Abbott , Mark Rutland , "Martin K. Petersen" , Paolo Bonzini , Christoffer Dall , Dave Kleikamp , Jan Kara , Luis de Bethencourt , Marc Zyngier , Rik van Riel , Matthew Garrett , linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org, kernel-hardening@lists.openwall.com, Vlastimil Babka , Michal Kubecek Subject: Re: [kernel-hardening] [PATCH 09/38] usercopy: Mark kmalloc caches as usercopy caches Message-ID: <202001300945.7D465B5F5@keescook> References: <201911121313.1097D6EE@keescook> <201911141327.4DE6510@keescook> <202001271519.AA6ADEACF0@keescook> <5861936c-1fe1-4c44-d012-26efa0c8b6e7@de.ibm.com> <202001281457.FA11CC313A@keescook> <6844ea47-8e0e-4fb7-d86f-68046995a749@de.ibm.com> <20200129170939.GA4277@infradead.org> <771c5511-c5ab-3dd1-d938-5dbc40396daa@de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <771c5511-c5ab-3dd1-d938-5dbc40396daa@de.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 29, 2020 at 06:19:56PM +0100, Christian Borntraeger wrote: > On 29.01.20 18:09, Christoph Hellwig wrote: > > On Wed, Jan 29, 2020 at 06:07:14PM +0100, Christian Borntraeger wrote: > >>> DMA can be done to NORMAL memory as well. > >> > >> Exactly. > >> I think iucv uses GFP_DMA because z/VM needs those buffers to reside below 2GB (which is ZONA_DMA for s390). > > > > The normal way to allocate memory with addressing limits would be to > > use dma_alloc_coherent and friends. Any chance to switch iucv over to > > that? Or is there no device associated with it? > > There is not necessarily a device for that. It is a hypervisor interface (an > instruction that is interpreted by z/VM). We do have the netiucv driver that > creates a virtual nic, but there is also AF_IUCV which works without a device. > > But back to the original question: If we mark kmalloc caches as usercopy caches, > we should do the same for DMA kmalloc caches. As outlined by Christoph, this has > nothing to do with device DMA. Hm, looks like it's allocated from the low 16MB. Seems like poor naming! :) There seems to be a LOT of stuff using GFP_DMA, and it seems unlikely those are all expecting low addresses? Since this has only been a problem on s390, should just s390 gain the weakening of the usercopy restriction? Something like: diff --git a/mm/slab_common.c b/mm/slab_common.c index 1907cb2903c7..c5bbc141f20b 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -1303,7 +1303,9 @@ void __init create_kmalloc_caches(slab_flags_t flags) kmalloc_caches[KMALLOC_DMA][i] = create_kmalloc_cache( kmalloc_info[i].name[KMALLOC_DMA], kmalloc_info[i].size, - SLAB_CACHE_DMA | flags, 0, 0); + SLAB_CACHE_DMA | flags, 0, + IS_ENABLED(CONFIG_S390) ? + kmalloc_info[i].size : 0); } } #endif -- Kees Cook